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,246 +0,0 @@
|
|
|
1
|
-
import { constants } from "node:fs";
|
|
2
|
-
import { open, stat } from "node:fs/promises";
|
|
3
|
-
import { BROWSER_TRANSITION_ENTRY, BROWSER_RESULT_TOOLS, applyArtifactChanges, getBrowserRecord, snapshotFromDefinition, } from "./browser-transcript.js";
|
|
4
|
-
import { isRecord } from "./parsing.js";
|
|
5
|
-
import { getErrorCode } from "./process-errors.js";
|
|
6
|
-
import { projectJson, readRange, scanJournalMetadata, } from "./browser-journal-reader.js";
|
|
7
|
-
const REPLAY_CUSTOM_TYPES = new Set([
|
|
8
|
-
BROWSER_TRANSITION_ENTRY,
|
|
9
|
-
"agent-browser-recording-reservation",
|
|
10
|
-
"agent-browser-script-session",
|
|
11
|
-
]);
|
|
12
|
-
function branchEntries(entries, selectedLeaf) {
|
|
13
|
-
const byId = new Map();
|
|
14
|
-
for (const entry of entries) {
|
|
15
|
-
const id = entry.value.id;
|
|
16
|
-
if (typeof id !== "string" || byId.has(id)) {
|
|
17
|
-
throw new Error("Journal has a missing or duplicate native entry identity.");
|
|
18
|
-
}
|
|
19
|
-
byId.set(id, entry);
|
|
20
|
-
}
|
|
21
|
-
const branch = [];
|
|
22
|
-
const seen = new Set();
|
|
23
|
-
let leaf = selectedLeaf;
|
|
24
|
-
while (leaf !== null) {
|
|
25
|
-
if (seen.has(leaf)) {
|
|
26
|
-
throw new Error("Journal ancestry contains a cycle.");
|
|
27
|
-
}
|
|
28
|
-
seen.add(leaf);
|
|
29
|
-
const entry = byId.get(leaf);
|
|
30
|
-
if (!entry) {
|
|
31
|
-
throw new Error(`Selected journal entry ${leaf} is not persisted; browser work requires a committed conversation.`);
|
|
32
|
-
}
|
|
33
|
-
const parent = entry.value.parentId;
|
|
34
|
-
if (parent !== null && typeof parent !== "string") {
|
|
35
|
-
throw new Error("Invalid journal parent identity.");
|
|
36
|
-
}
|
|
37
|
-
branch.push(entry);
|
|
38
|
-
leaf = parent;
|
|
39
|
-
}
|
|
40
|
-
return branch.reverse();
|
|
41
|
-
}
|
|
42
|
-
function canonicalVersion(entry) {
|
|
43
|
-
return isRecord(entry.data) && isRecord(entry.data.event) && entry.data.event.version === 1;
|
|
44
|
-
}
|
|
45
|
-
function legacyCustom(entry) {
|
|
46
|
-
return (entry.type === "custom" &&
|
|
47
|
-
(entry.customType === BROWSER_TRANSITION_ENTRY ||
|
|
48
|
-
entry.customType === "agent-browser-script-session") &&
|
|
49
|
-
!canonicalVersion(entry));
|
|
50
|
-
}
|
|
51
|
-
function browserMessage(entry) {
|
|
52
|
-
const message = isRecord(entry.message) ? entry.message : undefined;
|
|
53
|
-
return message &&
|
|
54
|
-
typeof message.toolName === "string" &&
|
|
55
|
-
BROWSER_RESULT_TOOLS.has(message.toolName)
|
|
56
|
-
? message
|
|
57
|
-
: undefined;
|
|
58
|
-
}
|
|
59
|
-
function legacyBrowserResult(entry) {
|
|
60
|
-
const message = browserMessage(entry);
|
|
61
|
-
if (!message ||
|
|
62
|
-
!isRecord(message.details) ||
|
|
63
|
-
message.details.browserEventVersion === 1 ||
|
|
64
|
-
canonicalVersion(entry)) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return (message.details.sessionName !== undefined ||
|
|
68
|
-
message.details.artifactManifest !== undefined ||
|
|
69
|
-
message.details.electron !== undefined);
|
|
70
|
-
}
|
|
71
|
-
function validateMemoryEntry(entry) {
|
|
72
|
-
if (!isRecord(entry)) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (legacyCustom(entry) && !getBrowserRecord(entry)) {
|
|
76
|
-
throw new Error("Legacy browser records require stopped separate-copy conversion before replay.");
|
|
77
|
-
}
|
|
78
|
-
const message = browserMessage(entry);
|
|
79
|
-
if (entry.type === "message" &&
|
|
80
|
-
message &&
|
|
81
|
-
isRecord(message.details) &&
|
|
82
|
-
message.details.browserEventVersion !== 1 &&
|
|
83
|
-
!getBrowserRecord(entry)) {
|
|
84
|
-
throw new Error("Legacy browser observations require stopped separate-copy conversion before replay.");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function inMemoryEntries(manager, physical) {
|
|
88
|
-
const entries = physical ? manager.getEntries() : [];
|
|
89
|
-
if (!physical) {
|
|
90
|
-
const seen = new Set();
|
|
91
|
-
let leaf = manager.getLeafId();
|
|
92
|
-
while (leaf !== null) {
|
|
93
|
-
if (seen.has(leaf)) {
|
|
94
|
-
throw new Error("In-memory journal ancestry contains a cycle.");
|
|
95
|
-
}
|
|
96
|
-
seen.add(leaf);
|
|
97
|
-
const entry = manager.getEntry(leaf);
|
|
98
|
-
if (!isRecord(entry) || (entry.parentId !== null && typeof entry.parentId !== "string")) {
|
|
99
|
-
throw new Error("In-memory journal ancestry is incomplete.");
|
|
100
|
-
}
|
|
101
|
-
entries.push(entry);
|
|
102
|
-
leaf = entry.parentId;
|
|
103
|
-
}
|
|
104
|
-
entries.reverse();
|
|
105
|
-
}
|
|
106
|
-
for (const entry of entries) {
|
|
107
|
-
validateMemoryEntry(entry);
|
|
108
|
-
}
|
|
109
|
-
return entries;
|
|
110
|
-
}
|
|
111
|
-
class PublishedJournalReplay {
|
|
112
|
-
file;
|
|
113
|
-
projected = [];
|
|
114
|
-
definitions = new Map();
|
|
115
|
-
constructor(file) {
|
|
116
|
-
this.file = file;
|
|
117
|
-
}
|
|
118
|
-
async project(entries) {
|
|
119
|
-
for (const entry of entries) {
|
|
120
|
-
// Preserve journal order and bound selected envelope memory during replay.
|
|
121
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
122
|
-
await this.projectEntry(entry);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
async projectEntry(entry) {
|
|
126
|
-
const { value } = entry;
|
|
127
|
-
const definition = isRecord(value.data) && isRecord(value.data.snapshot) ? value.data.snapshot.id : undefined;
|
|
128
|
-
if (typeof definition === "string") {
|
|
129
|
-
if (this.definitions.has(definition)) {
|
|
130
|
-
throw new Error("Browser snapshot identity is defined more than once on this ancestry.");
|
|
131
|
-
}
|
|
132
|
-
this.definitions.set(definition, entry);
|
|
133
|
-
}
|
|
134
|
-
if (legacyCustom(value) || legacyBrowserResult(value)) {
|
|
135
|
-
throw new Error("This session contains legacy browser records. Convert a stopped separate copy with npm exec --package pi-agent-browser-native -- pi-agent-browser-convert before resuming browser work; the original journal is retained.");
|
|
136
|
-
}
|
|
137
|
-
if (!replayRelevant(value, definition)) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const fields = value.customType === BROWSER_TRANSITION_ENTRY || value.type === "message"
|
|
141
|
-
? [
|
|
142
|
-
["data", "event"],
|
|
143
|
-
["data", "snapshot", "id"],
|
|
144
|
-
]
|
|
145
|
-
: [["data"]];
|
|
146
|
-
const body = await projectJson(readRange(this.file, entry), fields);
|
|
147
|
-
this.projected.push({ ...value, ...body });
|
|
148
|
-
}
|
|
149
|
-
async resolveWinningDefinitions(physical) {
|
|
150
|
-
const { SessionPageState } = await import("./session-page-state.js");
|
|
151
|
-
const reduced = SessionPageState.fromBranch(this.projected);
|
|
152
|
-
const winners = new Set((physical ? [] : [...reduced.views().values()]).flatMap((page) => page.refSnapshot?.snapshotId !== undefined && page.refSnapshot.snapshotId.length > 0
|
|
153
|
-
? [page.refSnapshot.snapshotId]
|
|
154
|
-
: []));
|
|
155
|
-
for (const id of winners) {
|
|
156
|
-
// Each winning snapshot is materialized once, without retaining unrelated historical ref maps.
|
|
157
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
158
|
-
await this.resolveDefinition(id);
|
|
159
|
-
}
|
|
160
|
-
let manifest;
|
|
161
|
-
for (const entry of this.projected) {
|
|
162
|
-
manifest = applyArtifactChanges(manifest, getBrowserRecord(entry)?.event.artifacts);
|
|
163
|
-
}
|
|
164
|
-
return this.projected;
|
|
165
|
-
}
|
|
166
|
-
async resolveDefinition(id) {
|
|
167
|
-
const entry = this.definitions.get(id);
|
|
168
|
-
if (!entry) {
|
|
169
|
-
throw new Error(`Browser snapshot ${id} has no ancestral definition; inspect and take a fresh snapshot.`);
|
|
170
|
-
}
|
|
171
|
-
// ponytail: a requested individual snapshot must fit the consumer's memory; upgrade with native per-value paging if needed.
|
|
172
|
-
const body = await projectJson(readRange(this.file, entry), [["data", "snapshot"]], Infinity);
|
|
173
|
-
const destination = this.projected.find((candidate) => isRecord(candidate) && candidate.id === entry.value.id);
|
|
174
|
-
if (!isRecord(destination) || !isRecord(destination.data) || !isRecord(body?.data)) {
|
|
175
|
-
throw new Error("Winning browser snapshot could not be read.");
|
|
176
|
-
}
|
|
177
|
-
destination.data.snapshot = body.data.snapshot;
|
|
178
|
-
if (!isRecord(body.data.snapshot) || body.data.snapshot.id !== id) {
|
|
179
|
-
throw new Error("Winning browser snapshot identity is invalid.");
|
|
180
|
-
}
|
|
181
|
-
snapshotFromDefinition(body.data.snapshot);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function replayRelevant(value, definition) {
|
|
185
|
-
return ((value.type === "custom" &&
|
|
186
|
-
typeof value.customType === "string" &&
|
|
187
|
-
REPLAY_CUSTOM_TYPES.has(value.customType)) ||
|
|
188
|
-
(isRecord(value.data) && isRecord(value.data.event)) ||
|
|
189
|
-
definition !== undefined);
|
|
190
|
-
}
|
|
191
|
-
async function verifyCapturedFile(file, path, captured) {
|
|
192
|
-
const current = await file.stat();
|
|
193
|
-
const currentPath = await stat(path);
|
|
194
|
-
if (current.dev !== captured.dev ||
|
|
195
|
-
current.ino !== captured.ino ||
|
|
196
|
-
current.size < captured.size ||
|
|
197
|
-
currentPath.dev !== captured.dev ||
|
|
198
|
-
currentPath.ino !== captured.ino) {
|
|
199
|
-
throw new Error("Pi journal replaced or truncated during replay.");
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function validateJournalHeader(metadata, sessionId) {
|
|
203
|
-
const header = metadata.find((entry) => entry.value.type === "session");
|
|
204
|
-
if (header?.value.id !== sessionId) {
|
|
205
|
-
throw new Error("Pi session journal identity does not match the active session.");
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
async function openPublishedJournal(path) {
|
|
209
|
-
try {
|
|
210
|
-
return await open(path, constants.O_RDONLY);
|
|
211
|
-
}
|
|
212
|
-
catch (error) {
|
|
213
|
-
if (getErrorCode(error) === "ENOENT") {
|
|
214
|
-
return undefined;
|
|
215
|
-
}
|
|
216
|
-
throw error;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
export async function readBrowserEntries(manager, physical = false) {
|
|
220
|
-
const path = manager.getSessionFile();
|
|
221
|
-
if (path === undefined || path.length === 0) {
|
|
222
|
-
return inMemoryEntries(manager, physical);
|
|
223
|
-
}
|
|
224
|
-
const leaf = physical ? null : manager.getLeafId();
|
|
225
|
-
const file = await openPublishedJournal(path);
|
|
226
|
-
if (!file) {
|
|
227
|
-
return inMemoryEntries(manager, physical);
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
const captured = await file.stat();
|
|
231
|
-
if (!captured.isFile()) {
|
|
232
|
-
throw new Error("Pi session journal is not a regular file.");
|
|
233
|
-
}
|
|
234
|
-
const metadata = await scanJournalMetadata(file, captured.size);
|
|
235
|
-
validateJournalHeader(metadata, manager.getHeader()?.id ?? manager.getSessionId());
|
|
236
|
-
const records = metadata.filter((entry) => entry.value.type !== "session");
|
|
237
|
-
const replay = new PublishedJournalReplay(file);
|
|
238
|
-
await replay.project(physical ? records : branchEntries(records, leaf));
|
|
239
|
-
const entries = await replay.resolveWinningDefinitions(physical);
|
|
240
|
-
await verifyCapturedFile(file, path, captured);
|
|
241
|
-
return entries;
|
|
242
|
-
}
|
|
243
|
-
finally {
|
|
244
|
-
await file.close();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -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
|
-
}
|