pi-agent-browser-native 0.9.5 → 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 +19 -0
- package/README.md +3 -0
- package/dist/extensions/agent-browser/index.js +1214 -583
- 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 +11 -1
- package/docs/CODE_QUALITY.md +11 -0
- package/docs/COMMAND_REFERENCE.md +2 -2
- package/docs/PERFORMANCE.md +243 -0
- package/docs/REFERENCE.md +3 -3
- package/docs/SESSION_STORAGE.md +11 -3
- package/docs/SUPPORT_MATRIX.md +8 -4
- package/docs/TOOL_CONTRACT.md +4 -4
- package/docs/performance/2026-10-12.json +7257 -0
- package/package.json +13 -2
- package/scripts/build.mjs +16 -5
- package/scripts/config.mjs +1 -1
- package/scripts/convert-browser-session.mjs +1 -1
- 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 -231
- package/dist/extensions/agent-browser/lib/config.js +0 -69
- package/dist/extensions/agent-browser/lib/electron/cdp.js +0 -62
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +0 -274
- 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 -90
- 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 -340
- 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 -10
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +0 -201
- package/dist/extensions/agent-browser/lib/input-modes/job.js +0 -198
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +0 -116
- 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 -84
- 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 -203
- 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 -187
- 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 -174
- 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 -212
- 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 -169
- 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 -93
- 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 -68
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +0 -169
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +0 -182
- 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 -167
- 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 -183
- 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 -81
- 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 -211
- 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 -193
- package/dist/extensions/agent-browser/lib/web-search-request.js +0 -102
- 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 -167
- 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,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 {};
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { Readable } from "node:stream";
|
|
3
|
-
import { pipeline } from "node:stream/promises";
|
|
4
|
-
import tokenizeJson from "stream-json/parser.js";
|
|
5
|
-
import ignoreJson from "stream-json/filters/ignore.js";
|
|
6
|
-
import stringifyJson from "stream-json/stringer.js";
|
|
7
|
-
import disassembleJson from "stream-json/disassembler.js";
|
|
8
|
-
import { BROWSER_RESULT_TOOLS, BROWSER_STATE_FIELDS, BROWSER_TRANSITION_ENTRY, } from "./browser-transcript-contracts.js";
|
|
9
|
-
import { projectJson, readRange, } from "./browser-journal-reader.js";
|
|
10
|
-
import { isRecord } from "./parsing.js";
|
|
11
|
-
import { convertLegacyBrowserEntry, emptyProjection, } from "./browser-legacy-projection.js";
|
|
12
|
-
const DETAILS_FIELDS = [
|
|
13
|
-
...BROWSER_STATE_FIELDS,
|
|
14
|
-
"browserEventVersion",
|
|
15
|
-
"electron",
|
|
16
|
-
"compiledNetworkSourceLookup",
|
|
17
|
-
"sessionTabTarget",
|
|
18
|
-
"sessionTabTargetUnknown",
|
|
19
|
-
"sessionTabReopenPending",
|
|
20
|
-
"refSnapshot",
|
|
21
|
-
"refSnapshotInvalidation",
|
|
22
|
-
"artifactManifest",
|
|
23
|
-
"error",
|
|
24
|
-
"summary",
|
|
25
|
-
];
|
|
26
|
-
const LEGACY_FIELDS = [
|
|
27
|
-
["data", "event"],
|
|
28
|
-
["data", "snapshot"],
|
|
29
|
-
["data", "cleanup"],
|
|
30
|
-
["data", "sessionName"],
|
|
31
|
-
["data", "closeCommandArgs"],
|
|
32
|
-
["data", "launchAttempted"],
|
|
33
|
-
["data", "toolCallId"],
|
|
34
|
-
["data", "isError"],
|
|
35
|
-
["message", "toolName"],
|
|
36
|
-
["message", "toolCallId"],
|
|
37
|
-
["message", "isError"],
|
|
38
|
-
...["data", "message"].flatMap((root) => DETAILS_FIELDS.map((field) => [root, "details", field])),
|
|
39
|
-
...["data", "message"].flatMap((root) => ["command", "success", "lifecycle"]
|
|
40
|
-
.map((field) => [root, "details", "batchSteps", "*", field])
|
|
41
|
-
.concat([
|
|
42
|
-
["data", "lifecycle"],
|
|
43
|
-
["result", "lifecycle"],
|
|
44
|
-
].map((field) => [root, "details", "batchSteps", "*"].concat(field)))),
|
|
45
|
-
...["data", "message"].flatMap((root) => ["command", "success", "error"]
|
|
46
|
-
.map((field) => [root, "details", "data", "*", field])
|
|
47
|
-
.concat(["url", "title", "origin", "targetId"].map((field) => [
|
|
48
|
-
root,
|
|
49
|
-
"details",
|
|
50
|
-
"data",
|
|
51
|
-
"*",
|
|
52
|
-
"result",
|
|
53
|
-
field,
|
|
54
|
-
]))),
|
|
55
|
-
];
|
|
56
|
-
export async function sourceChecksum(file, size) {
|
|
57
|
-
const hash = createHash("sha256");
|
|
58
|
-
for await (const chunk of readRange(file, { offset: 0, length: size })) {
|
|
59
|
-
hash.update(chunk);
|
|
60
|
-
}
|
|
61
|
-
return hash.digest("hex");
|
|
62
|
-
}
|
|
63
|
-
export async function writeBytes(file,
|
|
64
|
-
// The native async iterator owns its cursor; yielded byte/string contents are read, never changed.
|
|
65
|
-
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types
|
|
66
|
-
chunks) {
|
|
67
|
-
for await (const chunk of chunks) {
|
|
68
|
-
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
69
|
-
let offset = 0;
|
|
70
|
-
while (offset < buffer.length) {
|
|
71
|
-
// Partial writes determine the offset for the next write.
|
|
72
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
73
|
-
const { bytesWritten } = await file.write(buffer, offset, buffer.length - offset);
|
|
74
|
-
if (bytesWritten === 0) {
|
|
75
|
-
throw new Error("Could not write converted journal.");
|
|
76
|
-
}
|
|
77
|
-
offset += bytesWritten;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async function* decodeRange(file, range) {
|
|
82
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
83
|
-
for await (const bytes of readRange(file, range)) {
|
|
84
|
-
yield decoder.decode(bytes, { stream: true });
|
|
85
|
-
}
|
|
86
|
-
const tail = decoder.decode();
|
|
87
|
-
if (tail.length > 0) {
|
|
88
|
-
yield tail;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async function rewriteMessage(file, range, destination, record) {
|
|
92
|
-
const tokenizer = tokenizeJson.asStream({ packValues: false, packKeys: true, streamKeys: false });
|
|
93
|
-
const filter = ignoreJson.asStream({
|
|
94
|
-
filter: /^(?:data|message\.details\.(?:refSnapshot|artifactManifest|browserEventVersion))$/,
|
|
95
|
-
});
|
|
96
|
-
async function* inject(
|
|
97
|
-
// Native token iteration advances a mutable cursor; token observations themselves remain readonly.
|
|
98
|
-
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types
|
|
99
|
-
tokens) {
|
|
100
|
-
let depth = 0;
|
|
101
|
-
for await (const token of tokens) {
|
|
102
|
-
if (token.name === "startObject" || token.name === "startArray") {
|
|
103
|
-
depth++;
|
|
104
|
-
}
|
|
105
|
-
if (token.name === "endObject" || token.name === "endArray") {
|
|
106
|
-
depth--;
|
|
107
|
-
if (depth === 0) {
|
|
108
|
-
const key = { name: "keyValue", value: "data" };
|
|
109
|
-
yield key;
|
|
110
|
-
yield* disassembleJson({ packValues: false, packKeys: true, streamKeys: false })(record);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
yield token;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const output = stringifyJson.asStream({ useKeyValues: true });
|
|
117
|
-
const processing = pipeline(Readable.from(decodeRange(file, range)), tokenizer, filter, inject, output);
|
|
118
|
-
try {
|
|
119
|
-
await Promise.all([writeBytes(destination, output), processing]);
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
tokenizer.destroy();
|
|
123
|
-
filter.destroy();
|
|
124
|
-
output.destroy();
|
|
125
|
-
}
|
|
126
|
-
await destination.write("\n");
|
|
127
|
-
}
|
|
128
|
-
function isLegacyBrowserEntry(value) {
|
|
129
|
-
if (value.type === "custom" &&
|
|
130
|
-
typeof value.customType === "string" &&
|
|
131
|
-
[BROWSER_TRANSITION_ENTRY, "agent-browser-script-session"].includes(value.customType)) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
return (isRecord(value.message) &&
|
|
135
|
-
typeof value.message.toolName === "string" &&
|
|
136
|
-
BROWSER_RESULT_TOOLS.has(value.message.toolName));
|
|
137
|
-
}
|
|
138
|
-
/** Owns branch projection and counters while streaming entries, never whole raw payloads. */
|
|
139
|
-
export class BrowserConversionWriter {
|
|
140
|
-
file;
|
|
141
|
-
stage;
|
|
142
|
-
sessionId;
|
|
143
|
-
checksum;
|
|
144
|
-
ids = new Set();
|
|
145
|
-
states = new Map();
|
|
146
|
-
convertedRecords = 0;
|
|
147
|
-
snapshotDefinitions = 0;
|
|
148
|
-
constructor(file, stage, sessionId, checksum) {
|
|
149
|
-
this.file = file;
|
|
150
|
-
this.stage = stage;
|
|
151
|
-
this.sessionId = sessionId;
|
|
152
|
-
this.checksum = checksum;
|
|
153
|
-
}
|
|
154
|
-
get counts() {
|
|
155
|
-
return {
|
|
156
|
-
entryCount: this.ids.size,
|
|
157
|
-
convertedRecords: this.convertedRecords,
|
|
158
|
-
snapshotDefinitions: this.snapshotDefinitions,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
async conversion(entry) {
|
|
162
|
-
if (entry.value.type === "session") {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
const id = entry.value.id;
|
|
166
|
-
if (typeof id !== "string" || this.ids.has(id)) {
|
|
167
|
-
throw new Error("Conversion source contains a missing or duplicate native entry ID.");
|
|
168
|
-
}
|
|
169
|
-
const parentId = entry.value.parentId;
|
|
170
|
-
if (parentId !== null && (typeof parentId !== "string" || !this.ids.has(parentId))) {
|
|
171
|
-
throw new Error("Conversion source contains a missing or forward parent.");
|
|
172
|
-
}
|
|
173
|
-
this.ids.add(id);
|
|
174
|
-
const parent = typeof parentId === "string"
|
|
175
|
-
? (this.states.get(parentId) ?? emptyProjection())
|
|
176
|
-
: emptyProjection();
|
|
177
|
-
if (!isLegacyBrowserEntry(entry.value)) {
|
|
178
|
-
this.states.set(id, parent);
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
const details = await projectJson(readRange(this.file, entry), LEGACY_FIELDS, Infinity);
|
|
182
|
-
const conversion = convertLegacyBrowserEntry({ ...entry.value, ...details }, parent, this.sessionId);
|
|
183
|
-
this.states.set(id, conversion.projection);
|
|
184
|
-
return conversion.record;
|
|
185
|
-
}
|
|
186
|
-
async write(entry, sourceSize) {
|
|
187
|
-
const record = await this.conversion(entry);
|
|
188
|
-
if (!record) {
|
|
189
|
-
await writeBytes(this.stage, readRange(this.file, entry));
|
|
190
|
-
if (entry.offset + entry.length === sourceSize) {
|
|
191
|
-
await this.completeLastLine(sourceSize);
|
|
192
|
-
}
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const data = {
|
|
196
|
-
...record,
|
|
197
|
-
archive: { sourceSha256: this.checksum, offset: entry.offset, length: entry.length },
|
|
198
|
-
};
|
|
199
|
-
if (entry.value.type === "message") {
|
|
200
|
-
await rewriteMessage(this.file, entry, this.stage, data);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
await this.stage.write(`${JSON.stringify({ ...entry.value, customType: BROWSER_TRANSITION_ENTRY, data })}\n`);
|
|
204
|
-
}
|
|
205
|
-
this.convertedRecords++;
|
|
206
|
-
if (record.snapshot !== undefined) {
|
|
207
|
-
this.snapshotDefinitions++;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
async completeLastLine(size) {
|
|
211
|
-
const lastByte = Buffer.alloc(1);
|
|
212
|
-
await this.file.read(lastByte, 0, 1, size - 1);
|
|
213
|
-
if (lastByte[0] !== 10) {
|
|
214
|
-
await this.stage.write("\n");
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import { link, lstat, mkdir, open, unlink } from "node:fs/promises";
|
|
4
|
-
import { dirname, resolve } from "node:path";
|
|
5
|
-
import { scanJournalMetadata } from "./browser-journal-reader.js";
|
|
6
|
-
import { getErrorCode } from "./process-errors.js";
|
|
7
|
-
import { BrowserConversionWriter, sourceChecksum } from "./browser-session-conversion-stream.js";
|
|
8
|
-
export { convertLegacyBrowserEntry, convertBrowserEntries } from "./browser-legacy-projection.js";
|
|
9
|
-
async function validateConversionPaths(options) {
|
|
10
|
-
if (!options.confirmedStopped) {
|
|
11
|
-
throw new Error("Stop/quiesce the exact session writer first, then pass --confirm-stopped. Conversion never stops a session.");
|
|
12
|
-
}
|
|
13
|
-
const source = resolve(options.source);
|
|
14
|
-
const destination = resolve(options.destination);
|
|
15
|
-
if (source === destination) {
|
|
16
|
-
throw new Error("Conversion requires a separate destination; originals are never rewritten.");
|
|
17
|
-
}
|
|
18
|
-
const sourceStat = await lstat(source);
|
|
19
|
-
if (!sourceStat.isFile() || sourceStat.isSymbolicLink()) {
|
|
20
|
-
throw new Error("Conversion source must be a regular file, not a symlink.");
|
|
21
|
-
}
|
|
22
|
-
const directory = dirname(destination);
|
|
23
|
-
await mkdir(directory, { mode: 0o700, recursive: true });
|
|
24
|
-
await validateDestination(directory, destination);
|
|
25
|
-
return { source, destination, directory, sourceStat };
|
|
26
|
-
}
|
|
27
|
-
async function validateDestination(directory, destination) {
|
|
28
|
-
const entry = await lstat(directory);
|
|
29
|
-
if (!entry.isDirectory() ||
|
|
30
|
-
entry.isSymbolicLink() ||
|
|
31
|
-
(process.platform !== "win32" &&
|
|
32
|
-
(entry.uid !== process.getuid?.() || (entry.mode & 0o077) !== 0))) {
|
|
33
|
-
throw new Error("Conversion destination must be a private current-user directory (0700 on POSIX), without symlinks.");
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
await lstat(destination);
|
|
37
|
-
throw new Error("Conversion destination is occupied.");
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (getErrorCode(error) !== "ENOENT") {
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async function verifySourceUnchanged(file, source, initial, checksum) {
|
|
46
|
-
const final = await file.stat();
|
|
47
|
-
const finalPath = await lstat(source);
|
|
48
|
-
if (final.dev !== initial.dev ||
|
|
49
|
-
final.ino !== initial.ino ||
|
|
50
|
-
final.size !== initial.size ||
|
|
51
|
-
final.mtimeMs !== initial.mtimeMs ||
|
|
52
|
-
finalPath.dev !== initial.dev ||
|
|
53
|
-
finalPath.ino !== initial.ino ||
|
|
54
|
-
(await sourceChecksum(file, initial.size)) !== checksum) {
|
|
55
|
-
throw new Error("Conversion source changed; no destination was published.");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async function syncPublishedDirectory(directory) {
|
|
59
|
-
const parent = await open(directory, constants.O_RDONLY);
|
|
60
|
-
try {
|
|
61
|
-
await parent.sync();
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
await parent.close();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/** Separate-copy publication only. The operator must quiesce the exact writer first. */
|
|
68
|
-
export async function convertBrowserSession(options) {
|
|
69
|
-
const { source, destination, directory, sourceStat } = await validateConversionPaths(options);
|
|
70
|
-
const file = await open(source, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
71
|
-
const stagePath = `${destination}.${randomUUID()}.tmp`;
|
|
72
|
-
let stage;
|
|
73
|
-
let published = false;
|
|
74
|
-
try {
|
|
75
|
-
const initial = await file.stat();
|
|
76
|
-
if (initial.dev !== sourceStat.dev || initial.ino !== sourceStat.ino) {
|
|
77
|
-
throw new Error("Conversion source changed before capture.");
|
|
78
|
-
}
|
|
79
|
-
const checksum = await sourceChecksum(file, initial.size);
|
|
80
|
-
const metadata = await scanJournalMetadata(file, initial.size, true);
|
|
81
|
-
const header = metadata.at(0);
|
|
82
|
-
if (header === undefined ||
|
|
83
|
-
header.value.type !== "session" ||
|
|
84
|
-
typeof header.value.id !== "string") {
|
|
85
|
-
throw new Error("Conversion source has no native session header.");
|
|
86
|
-
}
|
|
87
|
-
stage = await open(stagePath, "wx+", 0o600);
|
|
88
|
-
const writer = new BrowserConversionWriter(file, stage, header.value.id, checksum);
|
|
89
|
-
for (const entry of metadata) {
|
|
90
|
-
// Native ancestry and output byte ordering require each entry to finish before the next.
|
|
91
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
92
|
-
await writer.write(entry, initial.size);
|
|
93
|
-
}
|
|
94
|
-
await stage.sync();
|
|
95
|
-
const output = await stage.stat();
|
|
96
|
-
const destinationSha256 = await sourceChecksum(stage, output.size);
|
|
97
|
-
await verifySourceUnchanged(file, source, initial, checksum);
|
|
98
|
-
await stage.close();
|
|
99
|
-
stage = undefined;
|
|
100
|
-
await link(stagePath, destination); // Exclusive publication; never overwrite an existing destination.
|
|
101
|
-
published = true;
|
|
102
|
-
return {
|
|
103
|
-
version: 1,
|
|
104
|
-
source,
|
|
105
|
-
destination,
|
|
106
|
-
sessionId: header.value.id,
|
|
107
|
-
sourceSha256: checksum,
|
|
108
|
-
destinationSha256,
|
|
109
|
-
...writer.counts,
|
|
110
|
-
sourceBytes: initial.size,
|
|
111
|
-
destinationBytes: output.size,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
finally {
|
|
115
|
-
await stage?.close();
|
|
116
|
-
await file.close();
|
|
117
|
-
await unlink(stagePath).catch((error) => {
|
|
118
|
-
if (getErrorCode(error) !== "ENOENT") {
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
if (published && process.platform !== "win32") {
|
|
123
|
-
await syncPublishedDirectory(directory);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export const BROWSER_TRANSITION_ENTRY = "agent-browser-transition";
|
|
2
|
-
export const BROWSER_RESULT_TOOLS = new Set([
|
|
3
|
-
"agent_browser",
|
|
4
|
-
"agent_browser_code",
|
|
5
|
-
"agent_browser_action",
|
|
6
|
-
"agent_browser_qa",
|
|
7
|
-
"agent_browser_electron",
|
|
8
|
-
"agent_browser_source",
|
|
9
|
-
"agent_browser_network_source",
|
|
10
|
-
]);
|
|
11
|
-
export const BROWSER_STATE_FIELDS = [
|
|
12
|
-
"args",
|
|
13
|
-
"command",
|
|
14
|
-
"subcommand",
|
|
15
|
-
"sessionName",
|
|
16
|
-
"namespace",
|
|
17
|
-
"sessionMode",
|
|
18
|
-
"usedImplicitSession",
|
|
19
|
-
"managedSessionSocketDir",
|
|
20
|
-
"managedSessionDaemon",
|
|
21
|
-
"ownerSessionId",
|
|
22
|
-
"agentBrowserStarted",
|
|
23
|
-
"resultCategory",
|
|
24
|
-
"exitCode",
|
|
25
|
-
"closeAllApplied",
|
|
26
|
-
"attachedBrowserSession",
|
|
27
|
-
"readConfirmation",
|
|
28
|
-
"compatibilityWorkaround",
|
|
29
|
-
"managedSessionHeadedAutosaveDisabled",
|
|
30
|
-
"managedSessionHeadedAutosaveInterval",
|
|
31
|
-
"managedSessionOutcome",
|
|
32
|
-
"managedSessionCwd",
|
|
33
|
-
"managedSessionRestoreDisabled",
|
|
34
|
-
"nativeSucceeded",
|
|
35
|
-
];
|