pi-agent-browser-native 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -5
- package/README.md +120 -86
- package/dist/extensions/agent-browser/index.js +43065 -2016
- package/dist/extensions/agent-browser/lib/argv-descriptor.js +49 -26
- package/dist/extensions/agent-browser/lib/argv-grammar.js +82 -93
- package/dist/extensions/agent-browser/lib/bash-guard.js +129 -126
- package/dist/extensions/agent-browser/lib/batch-lifecycle.js +113 -49
- package/dist/extensions/agent-browser/lib/browser-execution-claim-codec.js +61 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claim-storage.js +232 -0
- package/dist/extensions/agent-browser/lib/browser-execution-claims.js +202 -0
- package/dist/extensions/agent-browser/lib/browser-execution-identity.js +77 -0
- package/dist/extensions/agent-browser/lib/browser-journal-branch.js +98 -0
- package/dist/extensions/agent-browser/lib/browser-journal-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-journal-projection.js +221 -0
- package/dist/extensions/agent-browser/lib/browser-journal-reader.js +89 -0
- package/dist/extensions/agent-browser/lib/browser-journal-replay.js +246 -0
- package/dist/extensions/agent-browser/lib/browser-journal.js +103 -394
- package/dist/extensions/agent-browser/lib/browser-legacy-pages.js +220 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-projection.js +282 -0
- package/dist/extensions/agent-browser/lib/browser-legacy-types.js +1 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion-stream.js +217 -0
- package/dist/extensions/agent-browser/lib/browser-session-conversion.js +80 -335
- package/dist/extensions/agent-browser/lib/browser-transcript-contracts.js +35 -0
- package/dist/extensions/agent-browser/lib/browser-transcript-validation.js +166 -0
- package/dist/extensions/agent-browser/lib/browser-transcript.js +137 -81
- package/dist/extensions/agent-browser/lib/browser-value-parsing.js +15 -0
- package/dist/extensions/agent-browser/lib/command-capabilities.js +340 -0
- package/dist/extensions/agent-browser/lib/command-policy.js +107 -88
- package/dist/extensions/agent-browser/lib/command-taxonomy.js +49 -322
- package/dist/extensions/agent-browser/lib/config-policy.js +138 -343
- package/dist/extensions/agent-browser/lib/config-providers.js +71 -0
- package/dist/extensions/agent-browser/lib/config-validation.js +218 -0
- package/dist/extensions/agent-browser/lib/config.js +19 -7
- package/dist/extensions/agent-browser/lib/electron/cdp.js +15 -7
- package/dist/extensions/agent-browser/lib/electron/cleanup.js +134 -55
- package/dist/extensions/agent-browser/lib/electron/discovery-darwin.js +109 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-desktop.js +136 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-evidence.js +89 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-linux.js +93 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-packages.js +162 -0
- package/dist/extensions/agent-browser/lib/electron/discovery-types.js +2 -0
- package/dist/extensions/agent-browser/lib/electron/discovery.js +140 -549
- package/dist/extensions/agent-browser/lib/electron/launch-monitor.js +102 -0
- package/dist/extensions/agent-browser/lib/electron/launch-process.js +209 -0
- package/dist/extensions/agent-browser/lib/electron/launch-types.js +2 -0
- package/dist/extensions/agent-browser/lib/electron/launch.js +249 -354
- package/dist/extensions/agent-browser/lib/executable-path.js +21 -12
- package/dist/extensions/agent-browser/lib/execution-cwd.js +35 -18
- package/dist/extensions/agent-browser/lib/input-modes/electron.js +162 -121
- package/dist/extensions/agent-browser/lib/input-modes/job.js +116 -313
- package/dist/extensions/agent-browser/lib/input-modes/lookup-network-evidence.js +104 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-plan.js +132 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-redaction.js +57 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-source-evidence.js +151 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookup-workspace.js +142 -0
- package/dist/extensions/agent-browser/lib/input-modes/lookups.js +57 -412
- package/dist/extensions/agent-browser/lib/input-modes/params.js +63 -17
- package/dist/extensions/agent-browser/lib/input-modes/qa-analysis.js +268 -0
- package/dist/extensions/agent-browser/lib/input-modes/qa-presentation.js +117 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-child.js +396 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-protocol.js +86 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-types.js +1 -0
- package/dist/extensions/agent-browser/lib/input-modes/script-validation.js +60 -0
- package/dist/extensions/agent-browser/lib/input-modes/script.js +60 -409
- package/dist/extensions/agent-browser/lib/input-modes/semantic-action.js +218 -128
- package/dist/extensions/agent-browser/lib/input-modes/shared.js +15 -4
- package/dist/extensions/agent-browser/lib/input-modes/types.js +56 -7
- package/dist/extensions/agent-browser/lib/json-schema.js +22 -10
- package/dist/extensions/agent-browser/lib/launch-scoped-flags.js +17 -5
- package/dist/extensions/agent-browser/lib/managed-session-policy-lock.js +92 -425
- package/dist/extensions/agent-browser/lib/managed-session-posix-storage.js +58 -0
- package/dist/extensions/agent-browser/lib/managed-session-project-identity.js +244 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-context.js +84 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-policy.js +119 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore-state.js +83 -0
- package/dist/extensions/agent-browser/lib/managed-session-restore.js +168 -300
- package/dist/extensions/agent-browser/lib/managed-session-snapshot-records.js +277 -0
- package/dist/extensions/agent-browser/lib/managed-session-snapshots.js +128 -305
- package/dist/extensions/agent-browser/lib/managed-session-storage.js +56 -253
- package/dist/extensions/agent-browser/lib/native-confirmation.js +140 -0
- package/dist/extensions/agent-browser/lib/native-output.js +44 -9
- package/dist/extensions/agent-browser/lib/orchestration/batch-stdin.js +107 -66
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-merge.js +14 -6
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/artifact-paths.js +109 -57
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/browser-observation-result.js +82 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/click-dispatch.js +171 -57
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostic-values.js +31 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/diagnostics.js +152 -781
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-observation.js +202 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/electron-text-diagnostics.js +109 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/fill-diagnostics.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-action-recovery.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-actions.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-content.js +123 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-details.js +156 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-electron.js +179 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-evidence.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-missing-binary.js +89 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-recovery.js +97 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-redaction.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result-timeout.js +110 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/final-result.js +41 -538
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/index.js +204 -108
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/interaction-diagnostics.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-close.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-inspection.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/managed-session-daemon-policy.js +127 -199
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/native-helper-observation.js +65 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/observation-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/overlay-diagnostics.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/network-page-filter.js +113 -30
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/scroll-shims.js +109 -28
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter-data.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-filter.js +138 -253
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/snapshot-rendered-text.js +147 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare/wait-timeouts.js +59 -24
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-artifacts.js +159 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-command.js +131 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-daemon.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-failure.js +42 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-guards.js +242 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-input.js +75 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-observations.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-selection.js +254 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-page-state.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-refs.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-resources.js +114 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-semantic.js +121 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-session-plan.js +222 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare-timeouts.js +68 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prepare.js +176 -1114
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-analysis.js +191 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-confirmation.js +152 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-electron.js +150 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle-phase.js +115 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-lifecycle.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-managed.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native-phase.js +93 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-native.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-navigation.js +316 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-ownership.js +28 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-page-phase.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-presentation.js +333 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication-phase.js +71 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-publication.js +201 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-receipts.js +183 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-refs.js +200 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output-tabs.js +142 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/process-output.js +18 -910
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/prompt-guards.js +23 -13
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-receipt-reconciliation.js +198 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery-presentation.js +154 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/recording-recovery.js +68 -151
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-capture.js +14 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/screenshot-observation.js +169 -46
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-commands.js +130 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-electron.js +210 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-observations.js +61 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-outcomes.js +187 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-refs.js +171 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state-tabs.js +228 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/session-state.js +77 -753
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/text-visibility-diagnostics.js +182 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-diagnostics.js +256 -0
- package/dist/extensions/agent-browser/lib/orchestration/browser-run/timeout-progress.js +108 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-artifact-observation.js +39 -0
- package/dist/extensions/agent-browser/lib/orchestration/code-image-observation.js +119 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/branch.js +92 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup-result.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/cleanup.js +78 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/discovery.js +106 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/index.js +48 -816
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/policy.js +86 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-collection.js +69 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-data.js +167 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe-presentation.js +164 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/probe.js +161 -0
- package/dist/extensions/agent-browser/lib/orchestration/electron-host/status.js +165 -0
- package/dist/extensions/agent-browser/lib/orchestration/execution-queue.js +21 -9
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifact-preflight.js +211 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-artifacts.js +23 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-attachment-replay.js +99 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-branch-restore.js +275 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-code.js +280 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-admission.js +303 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-output.js +36 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-result.js +335 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-run.js +227 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-command-state.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-electron-ownership.js +204 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-locks.js +139 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-execution-queue.js +24 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-coordination.js +98 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-host-run.js +295 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-intent-replay.js +41 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-invocation.js +7 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-lifecycle.js +102 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-managed-ownership.js +133 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-observation.js +120 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-prompt.js +180 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-recording.js +290 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-resource-replay.js +269 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-result-state.js +113 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-runtime.js +146 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-script-leases.js +58 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-tool-boundary.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/extension-version-check.js +54 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan-types.js +1 -0
- package/dist/extensions/agent-browser/lib/orchestration/input-plan.js +261 -185
- package/dist/extensions/agent-browser/lib/orchestration/input-redaction.js +62 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-config.js +144 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-root-launch.js +77 -0
- package/dist/extensions/agent-browser/lib/orchestration/native-session-defaults.js +210 -139
- package/dist/extensions/agent-browser/lib/orchestration/operation-paths.js +124 -58
- package/dist/extensions/agent-browser/lib/orchestration/output-file.js +198 -98
- package/dist/extensions/agent-browser/lib/orchestration/script-mode.js +199 -96
- package/dist/extensions/agent-browser/lib/owned-managed-session-context.js +55 -0
- package/dist/extensions/agent-browser/lib/page-target-batch.js +118 -0
- package/dist/extensions/agent-browser/lib/page-target-guards.js +50 -0
- package/dist/extensions/agent-browser/lib/page-target-navigation.js +104 -0
- package/dist/extensions/agent-browser/lib/page-target-validation.js +59 -243
- package/dist/extensions/agent-browser/lib/parsing.js +13 -4
- package/dist/extensions/agent-browser/lib/pi-tool-rendering.js +134 -68
- package/dist/extensions/agent-browser/lib/playbook.js +18 -14
- package/dist/extensions/agent-browser/lib/process-child.js +284 -0
- package/dist/extensions/agent-browser/lib/process-environment.js +22 -6
- package/dist/extensions/agent-browser/lib/process-errors.js +23 -0
- package/dist/extensions/agent-browser/lib/process-identity.js +47 -15
- package/dist/extensions/agent-browser/lib/process-socket-storage.js +256 -0
- package/dist/extensions/agent-browser/lib/process-stdout.js +74 -0
- package/dist/extensions/agent-browser/lib/process.js +146 -537
- package/dist/extensions/agent-browser/lib/prompt-artifacts.js +287 -0
- package/dist/extensions/agent-browser/lib/prompt-policy.js +15 -194
- package/dist/extensions/agent-browser/lib/read-command.js +41 -0
- package/dist/extensions/agent-browser/lib/read-confirmation.js +138 -35
- package/dist/extensions/agent-browser/lib/recording-reservations.js +118 -45
- package/dist/extensions/agent-browser/lib/redaction-fields.js +75 -0
- package/dist/extensions/agent-browser/lib/redaction-json.js +149 -0
- package/dist/extensions/agent-browser/lib/redaction-url.js +88 -0
- package/dist/extensions/agent-browser/lib/results/action-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/action-recommendations.js +28 -271
- package/dist/extensions/agent-browser/lib/results/artifact-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/results/artifact-manifest.js +96 -94
- package/dist/extensions/agent-browser/lib/results/artifact-recommendations.js +73 -0
- package/dist/extensions/agent-browser/lib/results/categories.js +111 -54
- package/dist/extensions/agent-browser/lib/results/confirmation.js +29 -10
- package/dist/extensions/agent-browser/lib/results/editable-ref-evidence.js +62 -27
- package/dist/extensions/agent-browser/lib/results/electron-recommendations.js +83 -0
- package/dist/extensions/agent-browser/lib/results/envelope-decoding.js +48 -0
- package/dist/extensions/agent-browser/lib/results/envelope.js +93 -66
- package/dist/extensions/agent-browser/lib/results/evidence-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/failure-recommendations.js +180 -0
- package/dist/extensions/agent-browser/lib/results/network-routes.js +86 -45
- package/dist/extensions/agent-browser/lib/results/network.js +35 -12
- package/dist/extensions/agent-browser/lib/results/next-actions.js +49 -19
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-files.js +320 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-format.js +138 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-images.js +113 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifact-verification.js +145 -0
- package/dist/extensions/agent-browser/lib/results/presentation/artifacts.js +99 -552
- package/dist/extensions/agent-browser/lib/results/presentation/batch-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-recording.js +118 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-redaction.js +68 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-rendering.js +135 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-step.js +227 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch-summary.js +91 -0
- package/dist/extensions/agent-browser/lib/results/presentation/batch.js +91 -460
- package/dist/extensions/agent-browser/lib/results/presentation/browser-profile-recovery.js +9 -5
- package/dist/extensions/agent-browser/lib/results/presentation/command-presenters.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/common.js +26 -9
- package/dist/extensions/agent-browser/lib/results/presentation/content.js +86 -29
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-a11y.js +67 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-health.js +79 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-identity.js +199 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-logs.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network-actions.js +216 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-network.js +124 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-redaction.js +64 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-storage.js +209 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-stream.js +69 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostic-summary.js +222 -0
- package/dist/extensions/agent-browser/lib/results/presentation/diagnostics.js +103 -1019
- package/dist/extensions/agent-browser/lib/results/presentation/early-result.js +70 -0
- package/dist/extensions/agent-browser/lib/results/presentation/errors.js +130 -60
- package/dist/extensions/agent-browser/lib/results/presentation/input-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/large-output.js +60 -145
- package/dist/extensions/agent-browser/lib/results/presentation/navigation.js +147 -88
- package/dist/extensions/agent-browser/lib/results/presentation/notices.js +75 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/presentation/observation-rendering.js +127 -0
- package/dist/extensions/agent-browser/lib/results/presentation/outcomes.js +120 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-completion.js +77 -0
- package/dist/extensions/agent-browser/lib/results/presentation/output-spill.js +51 -0
- package/dist/extensions/agent-browser/lib/results/presentation/registry.js +117 -237
- package/dist/extensions/agent-browser/lib/results/presentation/semantic-action.js +35 -21
- package/dist/extensions/agent-browser/lib/results/presentation/skills.js +104 -73
- package/dist/extensions/agent-browser/lib/results/presentation/source.js +109 -0
- package/dist/extensions/agent-browser/lib/results/presentation.js +17 -248
- package/dist/extensions/agent-browser/lib/results/recommendation-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/results/recording.js +52 -14
- package/dist/extensions/agent-browser/lib/results/recovery-actions.js +14 -5
- package/dist/extensions/agent-browser/lib/results/recovery-next-actions.js +30 -22
- package/dist/extensions/agent-browser/lib/results/selector-recovery-target.js +83 -0
- package/dist/extensions/agent-browser/lib/results/selector-recovery.js +123 -123
- package/dist/extensions/agent-browser/lib/results/snapshot-compact.js +266 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-content.js +32 -0
- package/dist/extensions/agent-browser/lib/results/snapshot-high-value-controls.js +104 -71
- package/dist/extensions/agent-browser/lib/results/snapshot-refs.js +31 -11
- package/dist/extensions/agent-browser/lib/results/snapshot-segments.js +125 -66
- package/dist/extensions/agent-browser/lib/results/snapshot-spill.js +26 -7
- package/dist/extensions/agent-browser/lib/results/snapshot.js +28 -248
- package/dist/extensions/agent-browser/lib/results/text.js +16 -5
- package/dist/extensions/agent-browser/lib/runtime-args-validation.js +133 -0
- package/dist/extensions/agent-browser/lib/runtime-compatibility.js +81 -0
- package/dist/extensions/agent-browser/lib/runtime-contracts.js +1 -0
- package/dist/extensions/agent-browser/lib/runtime-redaction.js +118 -0
- package/dist/extensions/agent-browser/lib/runtime-replay-events.js +144 -0
- package/dist/extensions/agent-browser/lib/runtime-session-identity.js +76 -0
- package/dist/extensions/agent-browser/lib/runtime-session-plan.js +114 -0
- package/dist/extensions/agent-browser/lib/runtime-session-replay.js +123 -0
- package/dist/extensions/agent-browser/lib/runtime-tab-correction.js +65 -0
- package/dist/extensions/agent-browser/lib/runtime-timeouts.js +28 -0
- package/dist/extensions/agent-browser/lib/runtime.js +137 -1037
- package/dist/extensions/agent-browser/lib/session-identity.js +51 -0
- package/dist/extensions/agent-browser/lib/session-page-observation.js +357 -0
- package/dist/extensions/agent-browser/lib/session-page-state.js +188 -324
- package/dist/extensions/agent-browser/lib/session-page-types.js +1 -0
- package/dist/extensions/agent-browser/lib/temp-artifact-budget.js +78 -0
- package/dist/extensions/agent-browser/lib/temp-mutation-queue.js +7 -0
- package/dist/extensions/agent-browser/lib/temp-root-ownership.js +234 -0
- package/dist/extensions/agent-browser/lib/temp-root.js +207 -0
- package/dist/extensions/agent-browser/lib/temp.js +33 -446
- package/dist/extensions/agent-browser/lib/tool-surface.js +94 -24
- package/dist/extensions/agent-browser/lib/upstream-version.js +3 -2
- package/dist/extensions/agent-browser/lib/web-search-providers.js +229 -0
- package/dist/extensions/agent-browser/lib/web-search-request.js +108 -0
- package/dist/extensions/agent-browser/lib/web-search-results.js +281 -0
- package/dist/extensions/agent-browser/lib/web-search-schema.js +82 -0
- package/dist/extensions/agent-browser/lib/web-search.js +109 -617
- package/dist/extensions/agent-browser/lib/webmcp-observation.js +13 -6
- package/dist/extensions/agent-browser/lib/windows-stock-launcher.js +63 -37
- package/dist/extensions/agent-browser/script-worker.js +80 -43
- package/dist/scripts/agent-browser-target.mjs +4 -2
- package/docs/ARCHITECTURE.md +22 -10
- package/docs/CODE_QUALITY.md +242 -0
- package/docs/COMMAND_REFERENCE.md +264 -229
- package/docs/ELECTRON.md +53 -44
- package/docs/RELEASE.md +21 -17
- package/docs/REQUIREMENTS.md +2 -0
- package/docs/SESSION_STORAGE.md +1 -1
- package/docs/SUPPORT_MATRIX.md +84 -77
- package/docs/TOOL_CONTRACT.md +165 -130
- package/docs/platform-smoke.md +5 -5
- package/package.json +143 -120
- package/scripts/agent-browser-capability-baseline.mjs +361 -957
- package/scripts/agent-browser-target.mjs +6 -2
- package/scripts/build.mjs +37 -8
- package/scripts/capability-core-commands.mjs +193 -0
- package/scripts/capability-options.mjs +283 -0
- package/scripts/capability-samples.mjs +133 -0
- package/scripts/capability-section.mjs +11 -0
- package/scripts/config.mjs +213 -114
- package/scripts/convert-browser-session.mjs +30 -9
- package/scripts/doctor-sources.mjs +195 -0
- package/scripts/doctor.mjs +92 -247
- package/scripts/platform-smoke/artifacts.mjs +38 -11
- package/scripts/platform-smoke/commands.mjs +104 -0
- package/scripts/platform-smoke/crabbox-runner.mjs +167 -80
- package/scripts/platform-smoke/doctor-support.mjs +157 -0
- package/scripts/platform-smoke/doctor-windows.mjs +230 -0
- package/scripts/platform-smoke/doctor.mjs +212 -320
- package/scripts/platform-smoke/lease-evidence.mjs +134 -0
- package/scripts/platform-smoke/suite-checks.mjs +98 -0
- package/scripts/platform-smoke/suite-evidence.mjs +281 -0
- package/scripts/platform-smoke/targets.mjs +158 -472
- package/scripts/platform-smoke.mjs +55 -40
- package/scripts/prepare.mjs +16 -7
|
@@ -1,65 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { linkSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { lstatSync, mkdirSync, readdirSync, realpathSync } from "node:fs";
|
|
3
2
|
import { homedir } from "node:os";
|
|
4
|
-
import {
|
|
3
|
+
import { isAbsolute, join, win32 } from "node:path";
|
|
5
4
|
import { canonicalizeAgentBrowserNamespace } from "./argv-grammar.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const PROJECT_GENERATION_MARKER_MAX_BYTES = 1_024;
|
|
15
|
-
const projectGenerationCache = new Map();
|
|
16
|
-
function isAbsoluteHome(path, platform) {
|
|
17
|
-
return platform === "win32" ? win32.isAbsolute(path) : isAbsolute(path);
|
|
18
|
-
}
|
|
19
|
-
function currentUid() {
|
|
20
|
-
return typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
21
|
-
}
|
|
22
|
-
function isTrustedPosixDirectory(path, requireCurrentOwner, platform = process.platform) {
|
|
23
|
-
const uid = currentUid();
|
|
24
|
-
if (uid === undefined)
|
|
25
|
-
return false;
|
|
26
|
-
const root = parse(path).root;
|
|
27
|
-
let cursor = root;
|
|
28
|
-
for (const component of path.slice(root.length).split("/").filter(Boolean)) {
|
|
29
|
-
cursor = join(cursor, component);
|
|
30
|
-
let entry;
|
|
31
|
-
try {
|
|
32
|
-
entry = lstatSync(cursor);
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
if (entry.isSymbolicLink() || !entry.isDirectory())
|
|
38
|
-
return false;
|
|
39
|
-
const androidSystemAncestor = platform === "android" && (cursor === "/data" || cursor === "/data/data") && entry.uid === 1000 && (entry.mode & 0o002) === 0;
|
|
40
|
-
const androidAppDirectory = platform === "android" && entry.uid === uid && entry.gid === uid && (entry.mode & 0o002) === 0;
|
|
41
|
-
if (!androidSystemAncestor && entry.uid !== 0 && entry.uid !== uid)
|
|
42
|
-
return false;
|
|
43
|
-
const writableByOthers = (entry.mode & 0o022) !== 0;
|
|
44
|
-
const rootOwnedStickyDirectory = entry.uid === 0 && (entry.mode & 0o1000) !== 0;
|
|
45
|
-
if (writableByOthers && !rootOwnedStickyDirectory && !androidSystemAncestor && !androidAppDirectory)
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const leaf = lstatSync(path);
|
|
50
|
-
return !requireCurrentOwner || leaf.uid === uid;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
5
|
+
import { isTrustedPosixDirectory } from "./managed-session-posix-storage.js";
|
|
6
|
+
import { getCurrentProcessUid } from "./process-identity.js";
|
|
7
|
+
import { getErrorCode } from "./process-errors.js";
|
|
8
|
+
export { isManagedSessionRestoreKey, createManagedSessionRestoreKey, getManagedSessionRestoreScope, hasManagedSessionRestoreProjectIdentity, resolveManagedSessionRestoreCheckoutRoot, } from "./managed-session-project-identity.js";
|
|
9
|
+
function validHomeCandidate(candidate, platform) {
|
|
10
|
+
return (candidate.length > 0 &&
|
|
11
|
+
candidate.trim() === candidate &&
|
|
12
|
+
(platform === "win32" ? win32.isAbsolute(candidate) : isAbsolute(candidate)));
|
|
55
13
|
}
|
|
56
14
|
export function resolveManagedSessionRestoreHome(parentEnv, platform = process.platform) {
|
|
57
15
|
const configuredHome = platform === "win32" ? parentEnv.USERPROFILE : parentEnv.HOME;
|
|
58
16
|
const candidate = configuredHome ?? homedir();
|
|
59
|
-
if (!
|
|
17
|
+
if (!validHomeCandidate(candidate, platform)) {
|
|
60
18
|
return undefined;
|
|
61
|
-
|
|
19
|
+
}
|
|
20
|
+
if (platform === "win32") {
|
|
62
21
|
return candidate;
|
|
22
|
+
}
|
|
63
23
|
try {
|
|
64
24
|
const canonical = realpathSync(candidate);
|
|
65
25
|
return isTrustedPosixDirectory(canonical, true, platform) ? canonical : undefined;
|
|
@@ -74,15 +34,18 @@ export function ensureOwnerOnlyDirectory(path, platform = process.platform) {
|
|
|
74
34
|
mkdirSync(path, { mode: 0o700 });
|
|
75
35
|
}
|
|
76
36
|
catch (error) {
|
|
77
|
-
if (error
|
|
37
|
+
if (getErrorCode(error) !== "EEXIST") {
|
|
78
38
|
return false;
|
|
39
|
+
}
|
|
79
40
|
}
|
|
80
41
|
const entry = lstatSync(path);
|
|
81
|
-
if (entry.isSymbolicLink() || !entry.isDirectory())
|
|
42
|
+
if (entry.isSymbolicLink() || !entry.isDirectory()) {
|
|
82
43
|
return false;
|
|
83
|
-
|
|
44
|
+
}
|
|
45
|
+
if (platform === "win32") {
|
|
84
46
|
return true;
|
|
85
|
-
|
|
47
|
+
}
|
|
48
|
+
const uid = getCurrentProcessUid();
|
|
86
49
|
return uid !== undefined && entry.uid === uid && (entry.mode & 0o077) === 0;
|
|
87
50
|
}
|
|
88
51
|
catch {
|
|
@@ -97,225 +60,65 @@ export function directoryContainsSymlink(path) {
|
|
|
97
60
|
return true;
|
|
98
61
|
}
|
|
99
62
|
}
|
|
100
|
-
function resolveGitCheckout(cwd, platform) {
|
|
101
|
-
let directory = cwd;
|
|
102
|
-
while (true) {
|
|
103
|
-
const dotGit = join(directory, ".git");
|
|
104
|
-
try {
|
|
105
|
-
const entry = lstatSync(dotGit);
|
|
106
|
-
if (entry.isDirectory() && !entry.isSymbolicLink())
|
|
107
|
-
return { gitDirectory: realpathSync(dotGit), worktreeDirectory: realpathSync(directory) };
|
|
108
|
-
if (!entry.isFile() || entry.isSymbolicLink() || entry.size > PROJECT_GENERATION_MARKER_MAX_BYTES)
|
|
109
|
-
return undefined;
|
|
110
|
-
if (platform !== "win32") {
|
|
111
|
-
const uid = currentUid();
|
|
112
|
-
if (uid === undefined || entry.uid !== uid || (entry.mode & 0o022) !== 0)
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
const match = /^gitdir:\s*(.+)\s*$/i.exec(readFileSync(dotGit, "utf8"));
|
|
116
|
-
if (!match?.[1])
|
|
117
|
-
return undefined;
|
|
118
|
-
return { gitDirectory: realpathSync(resolve(directory, match[1])), worktreeDirectory: realpathSync(directory) };
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
if (error.code !== "ENOENT")
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
const parent = dirname(directory);
|
|
125
|
-
if (parent === directory)
|
|
126
|
-
return undefined;
|
|
127
|
-
directory = parent;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function readProjectGenerationMarker(path, platform) {
|
|
131
|
-
try {
|
|
132
|
-
const entry = lstatSync(path);
|
|
133
|
-
if (entry.isSymbolicLink() || !entry.isFile() || entry.size > PROJECT_GENERATION_MARKER_MAX_BYTES)
|
|
134
|
-
return undefined;
|
|
135
|
-
if (platform !== "win32") {
|
|
136
|
-
const uid = currentUid();
|
|
137
|
-
if (uid === undefined || entry.uid !== uid || (entry.mode & 0o177) !== 0)
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
141
|
-
return parsed.version === 1 && typeof parsed.id === "string" && /^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i.test(parsed.id) ? parsed.id : undefined;
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
return undefined;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function getDirectoryFilesystemIdentity(path, platform) {
|
|
148
|
-
try {
|
|
149
|
-
const entry = statSync(path, { bigint: true });
|
|
150
|
-
if (!entry.isDirectory() || entry.dev <= 0n || entry.ino <= 0n)
|
|
151
|
-
return undefined;
|
|
152
|
-
// ponytail: Android reports mutable ctime as birthtime; use statx birthtime/inode generation when Node exposes either reliably.
|
|
153
|
-
return platform === "android"
|
|
154
|
-
? `${entry.dev}:${entry.ino}`
|
|
155
|
-
: entry.birthtimeNs > 0n ? `${entry.dev}:${entry.ino}:${entry.birthtimeNs}` : undefined;
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function resolveManagedSessionRestoreProjectCheckout(cwd, platform) {
|
|
162
|
-
let canonicalCwd;
|
|
163
|
-
try {
|
|
164
|
-
canonicalCwd = realpathSync(cwd);
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
if (platform !== "win32" && !isTrustedPosixDirectory(canonicalCwd, false, platform))
|
|
170
|
-
return undefined;
|
|
171
|
-
const checkout = resolveGitCheckout(canonicalCwd, platform);
|
|
172
|
-
if (!checkout)
|
|
173
|
-
return undefined;
|
|
174
|
-
if (platform !== "win32" && (!isTrustedPosixDirectory(checkout.worktreeDirectory, true, platform)
|
|
175
|
-
|| !isTrustedPosixDirectory(checkout.gitDirectory, true, platform)))
|
|
176
|
-
return undefined;
|
|
177
|
-
return { canonicalCwd, ...checkout };
|
|
178
|
-
}
|
|
179
|
-
export function resolveManagedSessionRestoreCheckoutRoot(cwd, platform = process.platform) {
|
|
180
|
-
return resolveManagedSessionRestoreProjectCheckout(cwd, platform)?.worktreeDirectory;
|
|
181
|
-
}
|
|
182
|
-
function resolveProjectGenerationIdentity(cwd, platform = process.platform) {
|
|
183
|
-
const checkout = resolveManagedSessionRestoreProjectCheckout(cwd, platform);
|
|
184
|
-
if (!checkout)
|
|
185
|
-
return undefined;
|
|
186
|
-
const { canonicalCwd } = checkout;
|
|
187
|
-
const gitFilesystemIdentity = getDirectoryFilesystemIdentity(checkout.gitDirectory, platform);
|
|
188
|
-
const worktreeFilesystemIdentity = getDirectoryFilesystemIdentity(checkout.worktreeDirectory, platform);
|
|
189
|
-
if (!gitFilesystemIdentity || !worktreeFilesystemIdentity)
|
|
190
|
-
return undefined;
|
|
191
|
-
const markerPath = join(checkout.gitDirectory, PROJECT_GENERATION_MARKER_NAME);
|
|
192
|
-
let marker = readProjectGenerationMarker(markerPath, platform);
|
|
193
|
-
const cached = projectGenerationCache.get(canonicalCwd);
|
|
194
|
-
if (cached
|
|
195
|
-
&& cached.gitDirectory === checkout.gitDirectory
|
|
196
|
-
&& cached.worktreeDirectory === checkout.worktreeDirectory
|
|
197
|
-
&& cached.gitFilesystemIdentity === gitFilesystemIdentity
|
|
198
|
-
&& cached.worktreeFilesystemIdentity === worktreeFilesystemIdentity
|
|
199
|
-
&& cached.marker === marker)
|
|
200
|
-
return cached.identity;
|
|
201
|
-
projectGenerationCache.delete(canonicalCwd);
|
|
202
|
-
try {
|
|
203
|
-
if (!marker) {
|
|
204
|
-
const content = JSON.stringify({ id: randomUUID(), version: 1 });
|
|
205
|
-
if (platform === "android") {
|
|
206
|
-
// ponytail: Android denies hard links in app storage; use renameat2(RENAME_NOREPLACE) if Node exposes it.
|
|
207
|
-
try {
|
|
208
|
-
writeFileSync(markerPath, content, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
if (error.code !== "EEXIST")
|
|
212
|
-
return undefined;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
const candidatePath = `${markerPath}.candidate-${process.pid}-${randomUUID()}`;
|
|
217
|
-
try {
|
|
218
|
-
writeFileSync(candidatePath, content, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
219
|
-
try {
|
|
220
|
-
linkSync(candidatePath, markerPath);
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
if (error.code !== "EEXIST")
|
|
224
|
-
return undefined;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
finally {
|
|
228
|
-
try {
|
|
229
|
-
unlinkSync(candidatePath);
|
|
230
|
-
}
|
|
231
|
-
catch { }
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
marker = readProjectGenerationMarker(markerPath, platform);
|
|
235
|
-
}
|
|
236
|
-
if (!marker)
|
|
237
|
-
return undefined;
|
|
238
|
-
const identity = `${platform}:${worktreeFilesystemIdentity}:${gitFilesystemIdentity}:${marker}`;
|
|
239
|
-
projectGenerationCache.set(canonicalCwd, {
|
|
240
|
-
gitDirectory: checkout.gitDirectory,
|
|
241
|
-
gitFilesystemIdentity,
|
|
242
|
-
identity,
|
|
243
|
-
marker,
|
|
244
|
-
worktreeDirectory: checkout.worktreeDirectory,
|
|
245
|
-
worktreeFilesystemIdentity,
|
|
246
|
-
});
|
|
247
|
-
return identity;
|
|
248
|
-
}
|
|
249
|
-
catch {
|
|
250
|
-
return undefined;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
export function hasManagedSessionRestoreProjectIdentity(cwd) {
|
|
254
|
-
return resolveProjectGenerationIdentity(cwd) !== undefined;
|
|
255
|
-
}
|
|
256
|
-
/** Keep fresh rotations from one Pi transcript in one private upstream restore pool. */
|
|
257
|
-
export function getManagedSessionRestoreScope(sessionName) {
|
|
258
|
-
return sessionName.replace(MANAGED_SESSION_FRESH_SUFFIX_PATTERN, "");
|
|
259
|
-
}
|
|
260
|
-
/** Stable for one Pi transcript and checkout generation; isolated from other concurrent transcripts. */
|
|
261
|
-
export function createManagedSessionRestoreKey(cwd, restoreScope = "", platform = process.platform) {
|
|
262
|
-
let canonicalCwd = resolve(cwd);
|
|
263
|
-
try {
|
|
264
|
-
canonicalCwd = realpathSync(canonicalCwd);
|
|
265
|
-
}
|
|
266
|
-
catch { }
|
|
267
|
-
const identity = resolveProjectGenerationIdentity(canonicalCwd, platform);
|
|
268
|
-
const material = identity ?? `unavailable:${canonicalCwd}`;
|
|
269
|
-
const digest = createHash("sha256")
|
|
270
|
-
.update(`restore-v3:${material}:scope:${restoreScope}`)
|
|
271
|
-
.digest("hex")
|
|
272
|
-
.slice(0, MANAGED_SESSION_RESTORE_KEY_HASH_LENGTH);
|
|
273
|
-
return `${MANAGED_SESSION_NAME_PREFIX}${digest}`;
|
|
274
|
-
}
|
|
275
63
|
function hasValidEncryptionKey(parentEnv) {
|
|
276
64
|
const value = parentEnv.AGENT_BROWSER_ENCRYPTION_KEY;
|
|
277
65
|
return typeof value === "string" && /^[a-f\d]{64}$/i.test(value);
|
|
278
66
|
}
|
|
279
67
|
export function getManagedRestoreSessionsDirectory(home, namespace) {
|
|
280
68
|
const canonicalNamespace = canonicalizeAgentBrowserNamespace(namespace);
|
|
281
|
-
return canonicalNamespace
|
|
69
|
+
return canonicalNamespace !== undefined && canonicalNamespace.length > 0
|
|
282
70
|
? join(home, ".agent-browser", "namespaces", canonicalNamespace, "state", "sessions")
|
|
283
71
|
: join(home, ".agent-browser", "sessions");
|
|
284
72
|
}
|
|
285
|
-
|
|
73
|
+
function ensureRestoreStateDirectory(root, namespace, platform) {
|
|
74
|
+
const canonicalNamespace = canonicalizeAgentBrowserNamespace(namespace);
|
|
75
|
+
const components = canonicalNamespace !== undefined && canonicalNamespace.length > 0
|
|
76
|
+
? ["namespaces", canonicalNamespace, "state", "sessions"]
|
|
77
|
+
: ["sessions"];
|
|
78
|
+
let path = root;
|
|
79
|
+
for (const component of components) {
|
|
80
|
+
path = join(path, component);
|
|
81
|
+
if (!ensureOwnerOnlyDirectory(path, platform)) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return path;
|
|
86
|
+
}
|
|
87
|
+
/** Require the native 256-bit key format and secure each automatic restore storage directory. */
|
|
286
88
|
export function ensureManagedSessionRestoreStorageIsSecure(parentEnv = process.env, platform = process.platform, namespace) {
|
|
287
|
-
|
|
288
|
-
if (encryptionKey !== undefined && !hasValidEncryptionKey(parentEnv))
|
|
89
|
+
if (parentEnv.AGENT_BROWSER_ENCRYPTION_KEY !== undefined && !hasValidEncryptionKey(parentEnv)) {
|
|
289
90
|
return false;
|
|
290
|
-
|
|
91
|
+
}
|
|
92
|
+
if (platform === "win32") {
|
|
291
93
|
return hasValidEncryptionKey(parentEnv);
|
|
94
|
+
}
|
|
292
95
|
const home = resolveManagedSessionRestoreHome(parentEnv, platform);
|
|
293
|
-
if (
|
|
96
|
+
if (home === undefined) {
|
|
294
97
|
return false;
|
|
98
|
+
}
|
|
295
99
|
const root = join(home, ".agent-browser");
|
|
296
|
-
if (!ensureOwnerOnlyDirectory(root, platform))
|
|
100
|
+
if (!ensureOwnerOnlyDirectory(root, platform)) {
|
|
297
101
|
return false;
|
|
298
|
-
const canonicalNamespace = canonicalizeAgentBrowserNamespace(namespace);
|
|
299
|
-
const stateComponents = canonicalNamespace
|
|
300
|
-
? ["namespaces", canonicalNamespace, "state", "sessions"]
|
|
301
|
-
: ["sessions"];
|
|
302
|
-
let path = root;
|
|
303
|
-
for (const component of stateComponents) {
|
|
304
|
-
path = join(path, component);
|
|
305
|
-
if (!ensureOwnerOnlyDirectory(path, platform))
|
|
306
|
-
return false;
|
|
307
102
|
}
|
|
308
|
-
|
|
103
|
+
const path = ensureRestoreStateDirectory(root, namespace, platform);
|
|
104
|
+
if (path === undefined || directoryContainsSymlink(path)) {
|
|
309
105
|
return false;
|
|
106
|
+
}
|
|
107
|
+
return secureRestoreTemporaryDirectory(path, platform);
|
|
108
|
+
}
|
|
109
|
+
function secureRestoreTemporaryDirectory(path, platform) {
|
|
310
110
|
const temporaryDirectory = join(path, ".tmp");
|
|
311
|
-
return ensureOwnerOnlyDirectory(temporaryDirectory, platform) &&
|
|
111
|
+
return (ensureOwnerOnlyDirectory(temporaryDirectory, platform) &&
|
|
112
|
+
!directoryContainsSymlink(temporaryDirectory));
|
|
312
113
|
}
|
|
313
114
|
export function getManagedSessionRestoreProtectedStorageEnv(restoreEnabled, parentEnv, platform = process.platform) {
|
|
314
|
-
if (!restoreEnabled)
|
|
115
|
+
if (!restoreEnabled) {
|
|
315
116
|
return {};
|
|
117
|
+
}
|
|
316
118
|
const home = resolveManagedSessionRestoreHome(parentEnv, platform);
|
|
317
|
-
if (
|
|
119
|
+
if (home === undefined) {
|
|
318
120
|
return {};
|
|
121
|
+
}
|
|
319
122
|
return {
|
|
320
123
|
AGENT_BROWSER_ENCRYPTION_KEY: parentEnv.AGENT_BROWSER_ENCRYPTION_KEY,
|
|
321
124
|
...(platform === "win32" ? { USERPROFILE: home } : { HOME: home }),
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { getExplicitNavigationTarget } from "./page-target-navigation.js";
|
|
2
|
+
import { isRecord } from "./parsing.js";
|
|
3
|
+
function isNonemptyString(value) {
|
|
4
|
+
return typeof value === "string" && value.length > 0;
|
|
5
|
+
}
|
|
6
|
+
function confirmationIdentity(value) {
|
|
7
|
+
if (!isNonemptyString(value.id) ||
|
|
8
|
+
!isNonemptyString(value.sessionName) ||
|
|
9
|
+
(value.namespace !== undefined && typeof value.namespace !== "string")) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return { id: value.id, sessionName: value.sessionName, namespace: value.namespace };
|
|
13
|
+
}
|
|
14
|
+
function guardedProvenance(value) {
|
|
15
|
+
if (!isNonemptyString(value.command) || !isNonemptyString(value.action)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const fresh = value.state === "cleared" &&
|
|
19
|
+
value.command === "snapshot" &&
|
|
20
|
+
value.action === "snapshot" &&
|
|
21
|
+
value.refSnapshotFresh === true;
|
|
22
|
+
return {
|
|
23
|
+
command: value.command,
|
|
24
|
+
action: value.action,
|
|
25
|
+
...(fresh ? { refSnapshotFresh: true } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function explicitReadCapabilities(value) {
|
|
29
|
+
return isRecord(value) && value.readRequiresConfirmation === true
|
|
30
|
+
? { readRequiresConfirmation: true }
|
|
31
|
+
: undefined;
|
|
32
|
+
}
|
|
33
|
+
export function parseReadConfirmation(value) {
|
|
34
|
+
if (!isRecord(value) ||
|
|
35
|
+
(value.source !== "native-explicit-url-read" && value.source !== "native-guarded-action") ||
|
|
36
|
+
(value.state !== "pending" && value.state !== "cleared")) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const identity = confirmationIdentity(value);
|
|
40
|
+
if (identity === undefined) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (value.source === "native-explicit-url-read") {
|
|
44
|
+
const capabilities = explicitReadCapabilities(value.capabilities);
|
|
45
|
+
return {
|
|
46
|
+
...identity,
|
|
47
|
+
source: value.source,
|
|
48
|
+
state: value.state,
|
|
49
|
+
...(capabilities !== undefined ? { capabilities } : {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const provenance = guardedProvenance(value);
|
|
53
|
+
return provenance === undefined
|
|
54
|
+
? undefined
|
|
55
|
+
: { ...identity, ...provenance, source: value.source, state: value.state };
|
|
56
|
+
}
|
|
57
|
+
function parsePendingControl(value) {
|
|
58
|
+
if (!isRecord(value) ||
|
|
59
|
+
value.confirmation_required !== true ||
|
|
60
|
+
!isNonemptyString(value.confirmation_id) ||
|
|
61
|
+
!isNonemptyString(value.action)) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
id: value.confirmation_id,
|
|
66
|
+
action: value.action,
|
|
67
|
+
capabilities: explicitReadCapabilities(value.capabilities),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const TAB_TRANSPORT_KEYS = new Set([
|
|
71
|
+
"confirmation_required",
|
|
72
|
+
"confirmation_id",
|
|
73
|
+
"action",
|
|
74
|
+
"capabilities",
|
|
75
|
+
"after_confirmation",
|
|
76
|
+
"guidance",
|
|
77
|
+
]);
|
|
78
|
+
function matchesTabContinuation(after, commandTokens) {
|
|
79
|
+
return (Array.isArray(after) &&
|
|
80
|
+
after.length === 2 &&
|
|
81
|
+
after[0] === "open" &&
|
|
82
|
+
isNonemptyString(after[1]) &&
|
|
83
|
+
after[1] === getExplicitNavigationTarget(commandTokens));
|
|
84
|
+
}
|
|
85
|
+
export function getNativeTabContinuationGuidance(commandTokens, data) {
|
|
86
|
+
if (commandTokens[0] !== "tab" || commandTokens[1] !== "new" || !isRecord(data)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const pending = parsePendingControl(data);
|
|
90
|
+
if (pending?.action !== "tab_new" ||
|
|
91
|
+
!Object.keys(data).every((key) => TAB_TRANSPORT_KEYS.has(key))) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
if (!matchesTabContinuation(data.after_confirmation, commandTokens)) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
// Transport prose only: approval creates the tab; the continuation is never stored or executed.
|
|
98
|
+
return typeof data.guidance === "string" && data.guidance.trim().length > 0
|
|
99
|
+
? data.guidance
|
|
100
|
+
: undefined;
|
|
101
|
+
}
|
|
102
|
+
export function getNativePendingControl(commandTokens, data) {
|
|
103
|
+
if (!isRecord(data)) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
// Only native control fields and validated tab transport. Page output is never provenance.
|
|
107
|
+
const controlKeys = new Set([
|
|
108
|
+
"confirmation_required",
|
|
109
|
+
"confirmation_id",
|
|
110
|
+
"action",
|
|
111
|
+
"capabilities",
|
|
112
|
+
]);
|
|
113
|
+
if (!Object.keys(data).every((key) => controlKeys.has(key)) &&
|
|
114
|
+
getNativeTabContinuationGuidance(commandTokens, data) === undefined) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
return parsePendingControl(data);
|
|
118
|
+
}
|
|
119
|
+
export function getConfirmedNativeResult(data, current) {
|
|
120
|
+
const action = current.source === "native-explicit-url-read" ? "read" : current.action;
|
|
121
|
+
return isRecord(data) &&
|
|
122
|
+
data.confirmed === true &&
|
|
123
|
+
data.action === action &&
|
|
124
|
+
isRecord(data.result)
|
|
125
|
+
? data.result
|
|
126
|
+
: undefined;
|
|
127
|
+
}
|
|
128
|
+
export function isSuccessfulNativeConfirmedClose(commandTokens, data) {
|
|
129
|
+
if (commandTokens[0] !== "confirm" ||
|
|
130
|
+
commandTokens.length !== 2 ||
|
|
131
|
+
!isRecord(data) ||
|
|
132
|
+
data.confirmed !== true ||
|
|
133
|
+
data.action !== "close") {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return (isRecord(data.result) &&
|
|
137
|
+
data.result.success === true &&
|
|
138
|
+
isRecord(data.result.data) &&
|
|
139
|
+
data.result.data.closed === true);
|
|
140
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { JsonSchema } from "./json-schema.js";
|
|
2
2
|
import { isRecord } from "./parsing.js";
|
|
3
|
+
import { isBooleanFlagEnabled } from "./argv-grammar.js";
|
|
3
4
|
import { finalizeAgentBrowserFailure } from "./pi-tool-rendering.js";
|
|
4
5
|
import { isPlainTextInspectionArgs } from "./runtime.js";
|
|
5
|
-
import { projectAgentBrowserObservation, OBSERVATION_INLINE_MAX_CHARS } from "./results/presentation/content.js";
|
|
6
|
+
import { projectAgentBrowserObservation, OBSERVATION_INLINE_MAX_CHARS, isStringArray, } from "./results/presentation/content.js";
|
|
7
|
+
import { renderAgentBrowserObservation } from "./results/presentation/large-output.js";
|
|
6
8
|
export const AGENT_BROWSER_NAMESPACE = {
|
|
7
9
|
name: "browser",
|
|
8
10
|
description: "Browser commands, bounded browser code, advanced UI checks, Electron, and optional web search.",
|
|
@@ -10,37 +12,70 @@ export const AGENT_BROWSER_NAMESPACE = {
|
|
|
10
12
|
};
|
|
11
13
|
export const AGENT_BROWSER_OUTPUT_SCHEMA = JsonSchema.Object({
|
|
12
14
|
success: JsonSchema.Boolean(),
|
|
13
|
-
resultCategory: JsonSchema.Union([
|
|
15
|
+
resultCategory: JsonSchema.Union([
|
|
16
|
+
JsonSchema.Literal("success"),
|
|
17
|
+
JsonSchema.Literal("failure"),
|
|
18
|
+
]),
|
|
14
19
|
data: JsonSchema.Optional(JsonSchema.Unsafe({})),
|
|
15
20
|
error: JsonSchema.Optional(JsonSchema.Unsafe({})),
|
|
16
21
|
summary: JsonSchema.Optional(JsonSchema.String()),
|
|
17
22
|
nextActions: JsonSchema.Optional(JsonSchema.Array(JsonSchema.Object({}))),
|
|
18
23
|
}, { additionalProperties: true });
|
|
24
|
+
function inputArgs(input) {
|
|
25
|
+
return isRecord(input) && isStringArray(input.args) ? input.args : undefined;
|
|
26
|
+
}
|
|
27
|
+
function isJsonRequest(input) {
|
|
28
|
+
return (isRecord(input) && ("code" in input || isBooleanFlagEnabled(inputArgs(input) ?? [], "--json")));
|
|
29
|
+
}
|
|
30
|
+
function isJsonValue(value) {
|
|
31
|
+
if (value === null ||
|
|
32
|
+
typeof value === "string" ||
|
|
33
|
+
typeof value === "number" ||
|
|
34
|
+
typeof value === "boolean") {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
return value.every(isJsonValue);
|
|
39
|
+
}
|
|
40
|
+
return isRecord(value) && Object.values(value).every(isJsonValue);
|
|
41
|
+
}
|
|
42
|
+
function serializedObservation(value) {
|
|
43
|
+
// Serialization keeps native JSON omission/coercion semantics; validate the decoded unknown boundary.
|
|
44
|
+
const decoded = JSON.parse(JSON.stringify(value));
|
|
45
|
+
if (!isJsonValue(decoded)) {
|
|
46
|
+
throw new Error("Browser observation did not serialize to a JSON value.");
|
|
47
|
+
}
|
|
48
|
+
return decoded;
|
|
49
|
+
}
|
|
19
50
|
/** Final public boundary, after execution, persistence, and any requested output export. */
|
|
20
51
|
export async function finalizeAgentBrowserNativeResult(result, input) {
|
|
21
52
|
const finalized = finalizeAgentBrowserFailure(result, input);
|
|
22
53
|
// Native help/version stays plain text; the entrypoint intentionally skips observation rendering for it.
|
|
23
|
-
if (
|
|
54
|
+
if (isPlainTextInspectionArgs(inputArgs(input) ?? [])) {
|
|
24
55
|
return finalized;
|
|
56
|
+
}
|
|
25
57
|
const succeeded = finalized.isError !== true;
|
|
26
58
|
// The normal entrypoint supplies the exact bounded projection, including its complete spill.
|
|
27
|
-
if (isRecord(result.structuredContent) && result.structuredContent.success === succeeded)
|
|
59
|
+
if (isRecord(result.structuredContent) && result.structuredContent.success === succeeded) {
|
|
28
60
|
return finalized;
|
|
61
|
+
}
|
|
29
62
|
const details = isRecord(result.details) ? result.details : {};
|
|
30
63
|
const observation = projectAgentBrowserObservation(details, succeeded);
|
|
31
64
|
if (JSON.stringify(observation).length > OBSERVATION_INLINE_MAX_CHARS) {
|
|
32
|
-
const { renderAgentBrowserObservation } = await import("./results/presentation/large-output.js");
|
|
33
65
|
const rendered = await renderAgentBrowserObservation({
|
|
34
|
-
content: finalized.content,
|
|
35
|
-
|
|
66
|
+
content: finalized.content,
|
|
67
|
+
details,
|
|
68
|
+
succeeded,
|
|
69
|
+
json: isJsonRequest(input),
|
|
36
70
|
// The caller's exact visible output stays inline (for example formatted search results); only the structured field is bounded.
|
|
37
71
|
preserveContent: true,
|
|
38
72
|
});
|
|
39
73
|
const { artifactManifest, ...renderedResult } = rendered;
|
|
40
74
|
return finalizeAgentBrowserFailure({
|
|
41
|
-
...finalized,
|
|
75
|
+
...finalized,
|
|
76
|
+
...renderedResult,
|
|
42
77
|
details: artifactManifest ? { ...details, artifactManifest } : details,
|
|
43
78
|
}, input);
|
|
44
79
|
}
|
|
45
|
-
return { ...finalized, structuredContent:
|
|
80
|
+
return { ...finalized, structuredContent: serializedObservation(observation) };
|
|
46
81
|
}
|