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,202 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { lstat, mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { getErrorCode } from "./process-errors.js";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { readProcessStartIdentity } from "./process-identity.js";
|
|
6
|
-
import { POLICY_LOCK_MAX_BYTES, } from "./browser-execution-claim-codec.js";
|
|
7
|
-
import { ensureCoordinationDirectory, getCoordinationDirectory, getBrowserExecutionLockPath, } from "./browser-execution-identity.js";
|
|
8
|
-
import { cleanDeadPolicyArtifacts, readClaim, readClaims, removeClaimOwnedBy, ownerAlive, waitForRetry, LOCK_OWNER_FILE, LOCK_TICKET_FILE, POLICY_LOCK_WAIT_MS, } from "./browser-execution-claim-storage.js";
|
|
9
|
-
function claimPrecedes(left, right) {
|
|
10
|
-
if (left.ticket === null) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
if (right.ticket === null) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return (left.ticket < right.ticket ||
|
|
17
|
-
(left.ticket === right.ticket && left.owner.token < right.owner.token));
|
|
18
|
-
}
|
|
19
|
-
async function hasPublishedLaterTicket(claim, ownClaim) {
|
|
20
|
-
if (claim.ticket !== null) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const current = await readClaim(claim.path);
|
|
24
|
-
return current?.owner.token === claim.owner.token && !claimPrecedes(current, ownClaim);
|
|
25
|
-
}
|
|
26
|
-
function relevantPredecessor(claim, ownClaim) {
|
|
27
|
-
if (claim.owner.token === ownClaim.owner.token || !claimPrecedes(claim, ownClaim)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
const ownSessions = ownClaim.owner.sessionNames;
|
|
31
|
-
const sessions = claim.owner.sessionNames;
|
|
32
|
-
return (ownSessions === null ||
|
|
33
|
-
sessions === null ||
|
|
34
|
-
ownSessions.some((session) => sessions.includes(session)));
|
|
35
|
-
}
|
|
36
|
-
async function claimBlocks(claim, ownClaim, budget) {
|
|
37
|
-
if (!relevantPredecessor(claim, ownClaim) || (await hasPublishedLaterTicket(claim, ownClaim))) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const alive = await ownerAlive(claim.owner, budget);
|
|
41
|
-
if (alive === false) {
|
|
42
|
-
await removeClaimOwnedBy(claim.path, claim.owner.token);
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
// Native identity queries can outlive the whole critical section. Re-read the immutable
|
|
46
|
-
// claim so an already released owner, or a newly published later ticket, cannot block us.
|
|
47
|
-
if (!(await claimStillExists(claim.path))) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
return !(await hasPublishedLaterTicket(claim, ownClaim));
|
|
51
|
-
}
|
|
52
|
-
async function claimStillExists(path) {
|
|
53
|
-
try {
|
|
54
|
-
await lstat(path);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
return getErrorCode(error) !== "ENOENT";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function anyPredecessorBlocks(claims, own, budget) {
|
|
62
|
-
for (const claim of claims) {
|
|
63
|
-
// Contender inspection/removal is ordered before the next ticket decision.
|
|
64
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
65
|
-
if (await claimBlocks(claim, own, budget)) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
async function prepareClaim(identity, budget) {
|
|
72
|
-
const directory = getCoordinationDirectory(process.platform);
|
|
73
|
-
if (!(await ensureCoordinationDirectory(directory, process.platform))) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
const basePath = getBrowserExecutionLockPath(identity);
|
|
77
|
-
const token = randomUUID();
|
|
78
|
-
const startIdentity = await readProcessStartIdentity(process.pid, process.platform, budget);
|
|
79
|
-
if (startIdentity === undefined || startIdentity.length === 0) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
const owner = {
|
|
83
|
-
pid: process.pid,
|
|
84
|
-
startIdentity,
|
|
85
|
-
token,
|
|
86
|
-
sessionNames: identity.sessionNames,
|
|
87
|
-
version: 4,
|
|
88
|
-
};
|
|
89
|
-
const content = JSON.stringify(owner);
|
|
90
|
-
if (Buffer.byteLength(content) > POLICY_LOCK_MAX_BYTES) {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
owner,
|
|
95
|
-
content,
|
|
96
|
-
basePath,
|
|
97
|
-
directory,
|
|
98
|
-
candidatePath: `${basePath}.candidate-${token}`,
|
|
99
|
-
path: `${basePath}.claim-${token}`,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
async function publishClaim(claim) {
|
|
103
|
-
await mkdir(claim.candidatePath, { mode: 0o700 });
|
|
104
|
-
await writeFile(join(claim.candidatePath, LOCK_OWNER_FILE), claim.content, {
|
|
105
|
-
encoding: "utf8",
|
|
106
|
-
flag: "wx",
|
|
107
|
-
mode: 0o600,
|
|
108
|
-
});
|
|
109
|
-
await rename(claim.candidatePath, claim.path);
|
|
110
|
-
}
|
|
111
|
-
async function publishTicket(claim) {
|
|
112
|
-
const claims = await readClaims(claim.basePath);
|
|
113
|
-
if (!claims) {
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
const maxTicket = claims.reduce((max, entry) => (entry.ticket === null ? max : Math.max(max, entry.ticket)), 0);
|
|
117
|
-
if (!Number.isSafeInteger(maxTicket + 1)) {
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
const ticket = { ticket: maxTicket + 1, token: claim.owner.token, version: 4 };
|
|
121
|
-
const candidate = join(claim.path, `.ticket-${claim.owner.token}.tmp`);
|
|
122
|
-
await writeFile(candidate, JSON.stringify(ticket), { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
123
|
-
await rename(candidate, join(claim.path, LOCK_TICKET_FILE));
|
|
124
|
-
return ticket.ticket;
|
|
125
|
-
}
|
|
126
|
-
function acquisitionCancelled(budget) {
|
|
127
|
-
return budget.signal?.aborted === true;
|
|
128
|
-
}
|
|
129
|
-
async function waitForTurn(claim, ticket, budget, deadline) {
|
|
130
|
-
while (budget.signal?.aborted !== true) {
|
|
131
|
-
// Each poll observes a fresh published ticket set after the previous delay.
|
|
132
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
133
|
-
const claims = await readClaims(claim.basePath);
|
|
134
|
-
if (!claims) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
const own = claims.find((entry) => entry.owner.token === claim.owner.token);
|
|
138
|
-
if (!own || own.ticket !== ticket) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
// Liveness checks and stale-claim removal must finish before acquisition.
|
|
142
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
143
|
-
if (!(await anyPredecessorBlocks(claims, own, budget))) {
|
|
144
|
-
// Opportunistic GC must finish before the final cancellation check.
|
|
145
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
146
|
-
await cleanDeadPolicyArtifacts(claim.directory, budget);
|
|
147
|
-
// GC stays within the wait budget but cannot revoke a turn this claim already won;
|
|
148
|
-
// only cancellation can. Callers enforce their own operation deadlines.
|
|
149
|
-
return !acquisitionCancelled(budget);
|
|
150
|
-
}
|
|
151
|
-
if (Date.now() >= deadline) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
// Polling respects ordering and cancellation; contenders cannot run concurrently here.
|
|
155
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
156
|
-
await waitForRetry(budget.signal);
|
|
157
|
-
}
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
function acquisitionDeadline(options) {
|
|
161
|
-
return options.deadline ?? Date.now() + (options.timeoutMs ?? POLICY_LOCK_WAIT_MS);
|
|
162
|
-
}
|
|
163
|
-
export async function acquireExecutionClaim(options) {
|
|
164
|
-
if (options.signal?.aborted === true) {
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
const deadline = acquisitionDeadline(options);
|
|
168
|
-
// timeoutMs: 0 retains the existing single-attempt policy probe contract.
|
|
169
|
-
const budget = {
|
|
170
|
-
signal: options.signal,
|
|
171
|
-
deadline: options.timeoutMs === 0 ? undefined : deadline,
|
|
172
|
-
};
|
|
173
|
-
const claim = await prepareClaim(options.identity, budget);
|
|
174
|
-
if (!claim) {
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
let published = false;
|
|
178
|
-
let acquired = false;
|
|
179
|
-
try {
|
|
180
|
-
await publishClaim(claim);
|
|
181
|
-
published = true;
|
|
182
|
-
const ticket = await publishTicket(claim);
|
|
183
|
-
if (ticket === undefined || !(await waitForTurn(claim, ticket, budget, deadline))) {
|
|
184
|
-
return undefined;
|
|
185
|
-
}
|
|
186
|
-
acquired = true;
|
|
187
|
-
return {
|
|
188
|
-
release: async () => {
|
|
189
|
-
await removeClaimOwnedBy(claim.path, claim.owner.token, Date.now() + POLICY_LOCK_WAIT_MS);
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
await rm(claim.candidatePath, { force: true, recursive: true }).catch(() => undefined);
|
|
198
|
-
if (published && !acquired) {
|
|
199
|
-
await removeClaimOwnedBy(claim.path, claim.owner.token, Date.now() + POLICY_LOCK_WAIT_MS);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { lstat, mkdir, realpath } from "node:fs/promises";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { canonicalizeAgentBrowserNamespace, foldAgentBrowserFilesystemIdentity, } from "./argv-grammar.js";
|
|
6
|
-
import { getAgentBrowserSocketDirValidationError, resolveAgentBrowserSocketDir, } from "./process-socket-storage.js";
|
|
7
|
-
import { getCurrentProcessUid } from "./process-identity.js";
|
|
8
|
-
import { getErrorCode } from "./process-errors.js";
|
|
9
|
-
export function getCoordinationDirectory(platform = process.platform) {
|
|
10
|
-
if (platform !== "win32") {
|
|
11
|
-
const uid = getCurrentProcessUid();
|
|
12
|
-
const suffix = uid === undefined ? "" : `-${uid}`;
|
|
13
|
-
return platform === "android"
|
|
14
|
-
? join(tmpdir(), `pi-agent-browser-policy${suffix}`)
|
|
15
|
-
: `/tmp/pi-agent-browser-policy${suffix}`;
|
|
16
|
-
}
|
|
17
|
-
const user = process.env.USERNAME ?? process.env.USER ?? "unknown";
|
|
18
|
-
const suffix = createHash("sha256").update(user).digest("hex").slice(0, 12);
|
|
19
|
-
return join(tmpdir(), `pi-agent-browser-policy-${suffix}`);
|
|
20
|
-
}
|
|
21
|
-
function directoryOwnerTrusted(entry, platform) {
|
|
22
|
-
if (platform === "win32") {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
const uid = getCurrentProcessUid();
|
|
26
|
-
return uid !== undefined && entry.uid === uid && (entry.mode & 0o077) === 0;
|
|
27
|
-
}
|
|
28
|
-
export async function ensureCoordinationDirectory(path, platform) {
|
|
29
|
-
try {
|
|
30
|
-
try {
|
|
31
|
-
await mkdir(path, { mode: 0o700 });
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (getErrorCode(error) !== "EEXIST") {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const entry = await lstat(path);
|
|
39
|
-
return !entry.isSymbolicLink() && entry.isDirectory() && directoryOwnerTrusted(entry, platform);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** Resolve only after native routing; omit sessionName for a namespace-wide operation. */
|
|
46
|
-
export async function resolveBrowserExecutionIdentity(options) {
|
|
47
|
-
const socketDir = resolveAgentBrowserSocketDir(options);
|
|
48
|
-
const namespace = canonicalizeAgentBrowserNamespace(options.namespace);
|
|
49
|
-
let socketContext;
|
|
50
|
-
if (process.platform === "win32") {
|
|
51
|
-
// Windows native TCP daemons are shared across storage roots; don't split their coordination.
|
|
52
|
-
socketContext = `win32-native:${namespace ?? ""}`;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
if (socketDir === undefined) {
|
|
56
|
-
throw new Error("Browser execution coordination requires the native socket directory.");
|
|
57
|
-
}
|
|
58
|
-
const error = await getAgentBrowserSocketDirValidationError(socketDir);
|
|
59
|
-
if (error !== undefined && error.length > 0) {
|
|
60
|
-
throw new Error(`Browser execution coordination cannot use socket storage: ${error}.`);
|
|
61
|
-
}
|
|
62
|
-
const root = await realpath(socketDir);
|
|
63
|
-
socketContext =
|
|
64
|
-
namespace !== undefined && namespace.length > 0
|
|
65
|
-
? join(root, "namespaces", namespace, "run")
|
|
66
|
-
: root;
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
socketContext: foldAgentBrowserFilesystemIdentity(socketContext, process.platform),
|
|
70
|
-
...(options.sessionName !== undefined
|
|
71
|
-
? { sessionName: foldAgentBrowserFilesystemIdentity(options.sessionName, process.platform) }
|
|
72
|
-
: {}),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export function getBrowserExecutionLockPath(identity) {
|
|
76
|
-
return join(getCoordinationDirectory(), `.pi-agent-browser-policy-${createHash("sha256").update(identity.socketContext).digest("hex")}.lock-v4`);
|
|
77
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { isRecord } from "./parsing.js";
|
|
2
|
-
/** An admitted branch follows native append-only identity/ancestry, never entry body snapshots. */
|
|
3
|
-
class CapturedBrowserBranch {
|
|
4
|
-
manager;
|
|
5
|
-
isGenerationCurrent;
|
|
6
|
-
sessionId;
|
|
7
|
-
anchorId;
|
|
8
|
-
trackedAnchor;
|
|
9
|
-
validatedAnchor;
|
|
10
|
-
validatedLeaf;
|
|
11
|
-
constructor(manager, isGenerationCurrent) {
|
|
12
|
-
this.manager = manager;
|
|
13
|
-
this.isGenerationCurrent = isGenerationCurrent;
|
|
14
|
-
this.sessionId = manager.getSessionId();
|
|
15
|
-
this.anchorId = manager.getLeafId();
|
|
16
|
-
this.trackedAnchor = this.anchorId;
|
|
17
|
-
}
|
|
18
|
-
isCurrent() {
|
|
19
|
-
if (!this.isGenerationCurrent() || this.manager.getSessionId() !== this.sessionId) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
if (this.anchorId !== this.trackedAnchor) {
|
|
23
|
-
this.clearCache();
|
|
24
|
-
this.trackedAnchor = this.anchorId;
|
|
25
|
-
}
|
|
26
|
-
const result = this.walk();
|
|
27
|
-
// Native entries/parents are append-only. Cache only after validation to a root or cached endpoint.
|
|
28
|
-
// ponytail: behind-host ancestor mutation without native reseed/generation is outside this contract; upgrade if Pi exposes ancestry revisions.
|
|
29
|
-
if (result.current && result.selected) {
|
|
30
|
-
this.validatedAnchor = result.anchor ?? this.validatedAnchor;
|
|
31
|
-
this.validatedLeaf = result.selected;
|
|
32
|
-
}
|
|
33
|
-
return result.current;
|
|
34
|
-
}
|
|
35
|
-
clearCache() {
|
|
36
|
-
this.validatedAnchor = undefined;
|
|
37
|
-
this.validatedLeaf = undefined;
|
|
38
|
-
}
|
|
39
|
-
entry(leaf) {
|
|
40
|
-
const entry = this.manager.getEntry(leaf);
|
|
41
|
-
if (!isRecord(entry) ||
|
|
42
|
-
entry.id !== leaf ||
|
|
43
|
-
(entry.parentId !== null && typeof entry.parentId !== "string")) {
|
|
44
|
-
throw new Error("Selected Pi journal ancestry is incomplete.");
|
|
45
|
-
}
|
|
46
|
-
return { value: entry, parentId: entry.parentId };
|
|
47
|
-
}
|
|
48
|
-
cached(leaf) {
|
|
49
|
-
if (leaf === this.anchorId) {
|
|
50
|
-
return this.validatedAnchor;
|
|
51
|
-
}
|
|
52
|
-
return leaf === (isRecord(this.validatedLeaf?.entry) ? this.validatedLeaf.entry.id : undefined)
|
|
53
|
-
? this.validatedLeaf
|
|
54
|
-
: undefined;
|
|
55
|
-
}
|
|
56
|
-
validCache(leaf, entry) {
|
|
57
|
-
const cached = this.cached(leaf);
|
|
58
|
-
if (!cached) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
// Keep indexed lookup: the native API also refreshes fork journal identity.
|
|
62
|
-
if (cached.entry === entry.value && cached.parentId === entry.parentId) {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
this.clearCache();
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
walk() {
|
|
69
|
-
let leaf = this.manager.getLeafId();
|
|
70
|
-
// Empty selection is not a universal ancestor of independent roots.
|
|
71
|
-
let current = this.anchorId === null && leaf === null;
|
|
72
|
-
const seen = new Set();
|
|
73
|
-
let selected;
|
|
74
|
-
let anchor;
|
|
75
|
-
while (leaf !== null) {
|
|
76
|
-
if (typeof leaf !== "string" || seen.has(leaf)) {
|
|
77
|
-
throw new Error("Selected Pi journal ancestry is invalid or cyclic.");
|
|
78
|
-
}
|
|
79
|
-
seen.add(leaf);
|
|
80
|
-
const entry = this.entry(leaf);
|
|
81
|
-
selected ??= { entry: entry.value, parentId: entry.parentId };
|
|
82
|
-
if (this.validCache(leaf, entry)) {
|
|
83
|
-
current = true;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
if (leaf === this.anchorId) {
|
|
87
|
-
current = true;
|
|
88
|
-
anchor = { entry: entry.value, parentId: entry.parentId };
|
|
89
|
-
}
|
|
90
|
-
leaf = entry.parentId;
|
|
91
|
-
}
|
|
92
|
-
return { current, selected, anchor };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/** Capture before waiting: native branch selection precedes awaited session_tree handlers. */
|
|
96
|
-
export function captureBrowserBranch(manager, isGenerationCurrent) {
|
|
97
|
-
return new CapturedBrowserBranch(manager, isGenerationCurrent);
|
|
98
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { Readable, Writable } from "node:stream";
|
|
2
|
-
import { pipeline } from "node:stream/promises";
|
|
3
|
-
import { isRecord } from "./parsing.js";
|
|
4
|
-
import { normalizeProcessError } from "./process-errors.js";
|
|
5
|
-
const ENVELOPE_MAX_BYTES = 16 * 1024 * 1024;
|
|
6
|
-
function matches(field, key) {
|
|
7
|
-
return field === key || (field === "*" && typeof key === "number");
|
|
8
|
-
}
|
|
9
|
-
function selectedPath(path, fields) {
|
|
10
|
-
return fields.some((field) => field.every((key, index) => matches(key, path[index])) ||
|
|
11
|
-
path.every((key, index) => matches(field[index], key)));
|
|
12
|
-
}
|
|
13
|
-
/** Own only selected JSON values; discarded token streams still receive full syntax validation. */
|
|
14
|
-
class JsonProjection {
|
|
15
|
-
fields;
|
|
16
|
-
maxBytes;
|
|
17
|
-
stack = [];
|
|
18
|
-
root;
|
|
19
|
-
literal;
|
|
20
|
-
inKey = false;
|
|
21
|
-
keyText = "";
|
|
22
|
-
bytes = 0;
|
|
23
|
-
constructor(fields, maxBytes) {
|
|
24
|
-
this.fields = fields;
|
|
25
|
-
this.maxBytes = maxBytes;
|
|
26
|
-
}
|
|
27
|
-
result() {
|
|
28
|
-
return isRecord(this.root) ? this.root : undefined;
|
|
29
|
-
}
|
|
30
|
-
reserve(size) {
|
|
31
|
-
this.bytes += size;
|
|
32
|
-
if (this.bytes > this.maxBytes) {
|
|
33
|
-
throw new Error("Selected journal envelope exceeds its bounded read size.");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
path() {
|
|
37
|
-
const frame = this.stack.at(-1);
|
|
38
|
-
return frame ? [...frame.path, frame.key ?? frame.index] : [];
|
|
39
|
-
}
|
|
40
|
-
excluded() {
|
|
41
|
-
const frame = this.stack.at(-1);
|
|
42
|
-
return frame !== undefined && frame.value === undefined;
|
|
43
|
-
}
|
|
44
|
-
frame() {
|
|
45
|
-
const frame = this.stack.at(-1);
|
|
46
|
-
if (!frame) {
|
|
47
|
-
throw new Error("Journal JSON container is missing.");
|
|
48
|
-
}
|
|
49
|
-
return frame;
|
|
50
|
-
}
|
|
51
|
-
put(value) {
|
|
52
|
-
const parent = this.stack.at(-1);
|
|
53
|
-
if (!parent) {
|
|
54
|
-
this.root = value;
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (parent.value && value !== undefined) {
|
|
58
|
-
if (Array.isArray(parent.value)) {
|
|
59
|
-
parent.value[parent.index] = value;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (parent.key === undefined) {
|
|
63
|
-
throw new Error("Journal object key is missing.");
|
|
64
|
-
}
|
|
65
|
-
Object.defineProperty(parent.value, parent.key, {
|
|
66
|
-
value,
|
|
67
|
-
writable: true,
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
parent.key = undefined;
|
|
74
|
-
parent.index += 1;
|
|
75
|
-
}
|
|
76
|
-
consume(token) {
|
|
77
|
-
if (token.name === "startKey") {
|
|
78
|
-
this.inKey = true;
|
|
79
|
-
this.keyText = "";
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (token.name === "endKey") {
|
|
83
|
-
this.inKey = false;
|
|
84
|
-
this.frame().key = this.keyText;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (this.inKey) {
|
|
88
|
-
this.consumeKey(token);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
switch (token.name) {
|
|
92
|
-
case "startObject":
|
|
93
|
-
case "startArray":
|
|
94
|
-
this.startContainer(token.name);
|
|
95
|
-
break;
|
|
96
|
-
case "endObject":
|
|
97
|
-
case "endArray": {
|
|
98
|
-
const frame = this.stack.pop();
|
|
99
|
-
if (!frame) {
|
|
100
|
-
throw new Error("Journal JSON container is missing.");
|
|
101
|
-
}
|
|
102
|
-
this.put(frame.value);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
case "startString":
|
|
106
|
-
case "startNumber":
|
|
107
|
-
this.literal = {
|
|
108
|
-
value: "",
|
|
109
|
-
selected: !this.excluded() && selectedPath(this.path(), this.fields),
|
|
110
|
-
number: token.name === "startNumber",
|
|
111
|
-
};
|
|
112
|
-
break;
|
|
113
|
-
case "stringChunk":
|
|
114
|
-
case "numberChunk":
|
|
115
|
-
this.consumeLiteral(token.value);
|
|
116
|
-
break;
|
|
117
|
-
case "endString":
|
|
118
|
-
case "endNumber":
|
|
119
|
-
this.endLiteral();
|
|
120
|
-
break;
|
|
121
|
-
case "trueValue":
|
|
122
|
-
case "falseValue":
|
|
123
|
-
case "nullValue":
|
|
124
|
-
this.consumeConstant(token.name);
|
|
125
|
-
break;
|
|
126
|
-
case "keyValue":
|
|
127
|
-
case "numberValue":
|
|
128
|
-
case "stringValue":
|
|
129
|
-
case "whitespace":
|
|
130
|
-
// The unpacked tokenizer emits chunk events; packed/whitespace tokens need no projection.
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
consumeKey(token) {
|
|
135
|
-
if (token.name !== "stringChunk" || this.excluded()) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const path = this.frame().path;
|
|
139
|
-
const wholeContainer = this.fields.some((field) => field.every((key, index) => matches(key, path[index])));
|
|
140
|
-
if (wholeContainer || this.keyText.length <= 1024) {
|
|
141
|
-
if (wholeContainer) {
|
|
142
|
-
this.reserve(Buffer.byteLength(token.value));
|
|
143
|
-
}
|
|
144
|
-
this.keyText += token.value;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
startContainer(name) {
|
|
148
|
-
if (this.stack.length >= 1024) {
|
|
149
|
-
throw new Error("Journal JSON nesting exceeds 1024 levels.");
|
|
150
|
-
}
|
|
151
|
-
// Excluded containers cannot contain a requested descendant; don't allocate their keys/paths.
|
|
152
|
-
const currentPath = this.excluded() ? [] : this.path();
|
|
153
|
-
const selected = !this.excluded() && selectedPath(currentPath, this.fields);
|
|
154
|
-
if (selected) {
|
|
155
|
-
this.reserve(32);
|
|
156
|
-
}
|
|
157
|
-
let value;
|
|
158
|
-
if (selected) {
|
|
159
|
-
value = name === "startObject" ? {} : [];
|
|
160
|
-
}
|
|
161
|
-
this.stack.push({ path: currentPath, index: 0, value });
|
|
162
|
-
}
|
|
163
|
-
consumeLiteral(value) {
|
|
164
|
-
if (this.literal?.selected === true) {
|
|
165
|
-
this.reserve(Buffer.byteLength(value));
|
|
166
|
-
this.literal.value += value;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
endLiteral() {
|
|
170
|
-
const literal = this.literal;
|
|
171
|
-
let value;
|
|
172
|
-
if (literal?.selected === true) {
|
|
173
|
-
value = literal.number ? Number(literal.value) : literal.value;
|
|
174
|
-
}
|
|
175
|
-
this.put(value);
|
|
176
|
-
this.literal = undefined;
|
|
177
|
-
}
|
|
178
|
-
consumeConstant(name) {
|
|
179
|
-
const selected = !this.excluded() && selectedPath(this.path(), this.fields);
|
|
180
|
-
if (selected) {
|
|
181
|
-
this.reserve(8);
|
|
182
|
-
}
|
|
183
|
-
let value;
|
|
184
|
-
if (selected) {
|
|
185
|
-
value = name === "nullValue" ? null : name === "trueValue";
|
|
186
|
-
}
|
|
187
|
-
this.put(value);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/** Validate discarded values too; the parser never packs their strings or numbers. */
|
|
191
|
-
export async function projectJson(
|
|
192
|
-
// The native async iterator owns a mutable cursor; this reader consumes bytes without mutating them.
|
|
193
|
-
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types
|
|
194
|
-
input, fields, maxBytes = ENVELOPE_MAX_BYTES) {
|
|
195
|
-
const { parser } = await import("stream-json/parser.js");
|
|
196
|
-
async function* decode() {
|
|
197
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
198
|
-
for await (const chunk of input) {
|
|
199
|
-
yield decoder.decode(chunk, { stream: true });
|
|
200
|
-
}
|
|
201
|
-
const tail = decoder.decode();
|
|
202
|
-
if (tail.length > 0) {
|
|
203
|
-
yield tail;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const projection = new JsonProjection(fields, maxBytes);
|
|
207
|
-
const sink = new Writable({
|
|
208
|
-
objectMode: true,
|
|
209
|
-
write(token, _encoding, done) {
|
|
210
|
-
try {
|
|
211
|
-
projection.consume(token);
|
|
212
|
-
done();
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
done(normalizeProcessError(error));
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
await pipeline(Readable.from(decode()), parser.asStream({ packValues: false, streamValues: true }), sink);
|
|
220
|
-
return projection.result();
|
|
221
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { projectJson } from "./browser-journal-projection.js";
|
|
2
|
-
export { projectJson } from "./browser-journal-projection.js";
|
|
3
|
-
const CHUNK_BYTES = 64 * 1024;
|
|
4
|
-
export async function* readRange(file, range) {
|
|
5
|
-
let position = range.offset;
|
|
6
|
-
const end = range.offset + range.length;
|
|
7
|
-
while (position < end) {
|
|
8
|
-
const buffer = Buffer.allocUnsafe(Math.min(CHUNK_BYTES, end - position));
|
|
9
|
-
// The next range read depends on the bytes actually returned by this read.
|
|
10
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
11
|
-
const { bytesRead } = await file.read(buffer, 0, buffer.length, position);
|
|
12
|
-
if (bytesRead === 0) {
|
|
13
|
-
throw new Error("Journal changed or truncated during read.");
|
|
14
|
-
}
|
|
15
|
-
position += bytesRead;
|
|
16
|
-
yield buffer.subarray(0, bytesRead);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/** Byte framing, not readline: even one discarded value can exceed V8's string limit. */
|
|
20
|
-
class JournalLineFramer {
|
|
21
|
-
start;
|
|
22
|
-
nonblank = false;
|
|
23
|
-
constructor(offset) {
|
|
24
|
-
this.start = offset;
|
|
25
|
-
}
|
|
26
|
-
*accept(buffer, position) {
|
|
27
|
-
for (let index = 0; index < buffer.length; index++) {
|
|
28
|
-
const byte = buffer[index];
|
|
29
|
-
if (byte === 10) {
|
|
30
|
-
if (this.nonblank) {
|
|
31
|
-
yield { offset: this.start, length: position + index + 1 - this.start };
|
|
32
|
-
}
|
|
33
|
-
this.start = position + index + 1;
|
|
34
|
-
this.nonblank = false;
|
|
35
|
-
}
|
|
36
|
-
else if (![9, 13, 32].includes(byte)) {
|
|
37
|
-
this.nonblank = true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
final(end, sealed) {
|
|
42
|
-
return this.nonblank && sealed ? { offset: this.start, length: end - this.start } : undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export async function* journalRanges(file, end, sealed = false, offset = 0) {
|
|
46
|
-
let position = offset;
|
|
47
|
-
const framer = new JournalLineFramer(offset);
|
|
48
|
-
while (position < end) {
|
|
49
|
-
const buffer = Buffer.allocUnsafe(Math.min(CHUNK_BYTES, end - position));
|
|
50
|
-
// Byte offsets and line framing depend on the preceding read's actual length.
|
|
51
|
-
// oxlint-disable-next-line no-await-in-loop
|
|
52
|
-
const { bytesRead } = await file.read(buffer, 0, buffer.length, position);
|
|
53
|
-
if (bytesRead === 0) {
|
|
54
|
-
throw new Error("Journal truncated during read.");
|
|
55
|
-
}
|
|
56
|
-
yield* framer.accept(buffer.subarray(0, bytesRead), position);
|
|
57
|
-
position += bytesRead;
|
|
58
|
-
}
|
|
59
|
-
const final = framer.final(end, sealed);
|
|
60
|
-
if (final) {
|
|
61
|
-
yield final;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const STRUCTURAL_FIELDS = [
|
|
65
|
-
["type"],
|
|
66
|
-
["id"],
|
|
67
|
-
["parentId"],
|
|
68
|
-
["timestamp"],
|
|
69
|
-
["version"],
|
|
70
|
-
["customType"],
|
|
71
|
-
["data", "event", "version"],
|
|
72
|
-
["data", "snapshot", "id"],
|
|
73
|
-
["message", "toolName"],
|
|
74
|
-
["message", "details", "browserEventVersion"],
|
|
75
|
-
["message", "details", "sessionName"],
|
|
76
|
-
["message", "details", "artifactManifest", "version"],
|
|
77
|
-
["message", "details", "electron", "action"],
|
|
78
|
-
];
|
|
79
|
-
export async function scanJournalMetadata(file, end, sealed = false) {
|
|
80
|
-
const entries = [];
|
|
81
|
-
for await (const range of journalRanges(file, end, sealed)) {
|
|
82
|
-
const value = await projectJson(readRange(file, range), STRUCTURAL_FIELDS);
|
|
83
|
-
if (!value) {
|
|
84
|
-
throw new Error(`Expected a journal object at byte ${range.offset}.`);
|
|
85
|
-
}
|
|
86
|
-
entries.push({ ...range, value });
|
|
87
|
-
}
|
|
88
|
-
return entries;
|
|
89
|
-
}
|