@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 0.1.4-dev.0098fdb4e213
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/README.md +306 -1
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +121 -0
- package/dist/bridge/bridge-chat.types.js +416 -0
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +18 -1
- package/dist/bridge/bridge.service.d.ts +216 -4
- package/dist/bridge/bridge.service.js +2574 -90
- package/dist/bridge/bridge.types.d.ts +245 -2
- package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
- package/dist/bridge/dispatch-result-outbox.js +87 -0
- package/dist/bridge/dispatch-result-worker.d.ts +2 -0
- package/dist/bridge/dispatch-result-worker.js +122 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/internals.d.ts +2 -0
- package/dist/bridge/internals.js +1 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +25 -0
- package/dist/bridge/readiness-result-outbox.js +74 -0
- package/dist/bridge/readiness-result-worker.d.ts +2 -0
- package/dist/bridge/readiness-result-worker.js +121 -0
- package/dist/bridge/runner-host-capabilities.d.ts +20 -0
- package/dist/bridge/runner-host-capabilities.js +110 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +33 -2
- package/dist/cleanup/cleanup.service.js +477 -3
- package/dist/cleanup/cleanup.types.d.ts +16 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/index.d.ts +1 -1
- package/dist/cleanup/index.js +1 -1
- package/dist/cleanup/internals.d.ts +2 -2
- package/dist/cleanup/internals.js +1 -1
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.d.ts +2 -0
- package/dist/cli/cli.help.js +279 -0
- package/dist/cli/cli.service.d.ts +69 -12
- package/dist/cli/cli.service.js +557 -382
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +13 -0
- package/dist/cli/local-config.js +82 -6
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
- package/dist/runtime/attempt-database-broker.d.ts +89 -0
- package/dist/runtime/attempt-database-broker.js +390 -0
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +18 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +140 -0
- package/dist/runtime/attempt-path-operation.d.ts +21 -0
- package/dist/runtime/attempt-path-operation.js +94 -0
- package/dist/runtime/attempt-private-directory.d.ts +6 -0
- package/dist/runtime/attempt-private-directory.js +54 -0
- package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
- package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +121 -0
- package/dist/runtime/attempt-process-supervisor.js +471 -0
- package/dist/runtime/canonical-source-file.d.ts +3 -0
- package/dist/runtime/canonical-source-file.js +54 -0
- package/dist/runtime/docker-engine-probe.d.ts +95 -0
- package/dist/runtime/docker-engine-probe.js +340 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/generated-output-reset.d.ts +20 -0
- package/dist/runtime/generated-output-reset.js +157 -0
- package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
- package/dist/runtime/host-database-capability-boundary.js +63 -0
- package/dist/runtime/host-diagnostics.d.ts +11 -0
- package/dist/runtime/host-diagnostics.js +192 -0
- package/dist/runtime/host-execution-root.d.ts +4 -0
- package/dist/runtime/host-execution-root.js +39 -0
- package/dist/runtime/host-facts.d.ts +36 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-listener-inspector.d.ts +51 -0
- package/dist/runtime/host-listener-inspector.js +385 -0
- package/dist/runtime/host-load-admission.d.ts +67 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +52 -0
- package/dist/runtime/host-load-governor-config.js +83 -0
- package/dist/runtime/host-load-governor.d.ts +186 -0
- package/dist/runtime/host-load-governor.js +632 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +156 -0
- package/dist/runtime/host-load-sampler.js +298 -0
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-port-broker.d.ts +76 -0
- package/dist/runtime/host-port-broker.js +333 -0
- package/dist/runtime/host-pressure-stall.d.ts +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +74 -0
- package/dist/runtime/host-runtime-contract.js +846 -0
- package/dist/runtime/host-runtime-lease.d.ts +287 -0
- package/dist/runtime/host-runtime-lease.js +2763 -0
- package/dist/runtime/host-runtime-promotion.d.ts +55 -0
- package/dist/runtime/host-runtime-promotion.js +254 -0
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +596 -0
- package/dist/runtime/memory-capacity.d.ts +70 -0
- package/dist/runtime/memory-capacity.js +123 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
- package/dist/runtime/native-test-postgres-fallback.js +143 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +54 -0
- package/dist/runtime/node-host-runtime-adapter.js +286 -0
- package/dist/runtime/pinned-directory-process.d.ts +9 -0
- package/dist/runtime/pinned-directory-process.js +61 -0
- package/dist/runtime/pinned-source-directory.d.ts +17 -0
- package/dist/runtime/pinned-source-directory.js +94 -0
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +39 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +274 -0
- package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
- package/dist/runtime/prepared-runtime-identity.js +218 -0
- package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
- package/dist/runtime/prepared-runtime-readiness.js +285 -0
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
- package/dist/runtime/runtime-isolation-lease.js +161 -0
- package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
- package/dist/runtime/workspace-resource-estimator.js +174 -0
- package/dist/sandbox/command-runner.d.ts +4 -0
- package/dist/sandbox/command-runner.js +47 -0
- package/dist/sandbox/contract.d.ts +5 -0
- package/dist/sandbox/contract.js +276 -0
- package/dist/sandbox/event-budget.d.ts +11 -0
- package/dist/sandbox/event-budget.js +27 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/image-policy.d.ts +35 -0
- package/dist/sandbox/image-policy.js +247 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/lease-watchdog.d.ts +18 -0
- package/dist/sandbox/lease-watchdog.js +67 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +36 -0
- package/dist/sandbox/preflight.d.ts +84 -0
- package/dist/sandbox/preflight.js +521 -0
- package/dist/sandbox/process.d.ts +20 -0
- package/dist/sandbox/process.js +209 -0
- package/dist/sandbox/provider-auth/codex.d.ts +26 -0
- package/dist/sandbox/provider-auth/codex.js +212 -0
- package/dist/sandbox/repository-lock.d.ts +6 -0
- package/dist/sandbox/repository-lock.js +129 -0
- package/dist/sandbox/runtime.d.ts +311 -0
- package/dist/sandbox/runtime.js +2407 -0
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox.types.d.ts +93 -0
- package/dist/sandbox/sandbox.types.js +1 -0
- package/dist/sandbox/smoke.d.ts +76 -0
- package/dist/sandbox/smoke.js +380 -0
- package/dist/sandbox/worker-supervisor.d.ts +13 -0
- package/dist/sandbox/worker-supervisor.js +36 -0
- package/dist/sandbox/worker.d.ts +1 -0
- package/dist/sandbox/worker.js +225 -0
- package/dist/sandbox/workspace.service.d.ts +13 -0
- package/dist/sandbox/workspace.service.js +74 -0
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +48 -0
- package/dist/session/managed-attempt-tools.js +1299 -0
- package/dist/session/managed-build-coordinator.d.ts +5 -0
- package/dist/session/managed-build-coordinator.js +109 -0
- package/dist/session/managed-build-receipt.d.ts +26 -0
- package/dist/session/managed-build-receipt.js +342 -0
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -0
- package/dist/session/managed-verification-timeouts.d.ts +8 -0
- package/dist/session/managed-verification-timeouts.js +17 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +34 -0
- package/dist/session/phase-completion.artifacts.js +903 -0
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +65 -42
- package/dist/session/phase-completion.helpers.d.ts +117 -0
- package/dist/session/phase-completion.helpers.js +708 -0
- package/dist/session/phase-completion.js +130 -3007
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.d.ts +14 -0
- package/dist/session/phase-completion.prompts.js +238 -0
- package/dist/session/phase-completion.runtime.d.ts +43 -0
- package/dist/session/phase-completion.runtime.js +721 -0
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -0
- package/dist/session/phase-completion.schemas.js +836 -0
- package/dist/session/phase-completion.validation.d.ts +37 -0
- package/dist/session/phase-completion.validation.js +874 -0
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +23 -0
- package/dist/session/pre-publication-process.js +109 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +91 -0
- package/dist/session/pre-publication-validation.js +670 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +16 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +96 -0
- package/dist/session/provider-cli/provider-cli.artifacts.js +818 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +407 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +114 -0
- package/dist/session/provider-cli/provider-cli.process.js +757 -0
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +62 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +770 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +30 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +120 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +53 -53
- package/dist/session/provider-cli/provider-cli.service.js +1299 -2523
- package/dist/session/provider-cli/provider-cli.types.d.ts +38 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +40 -0
- package/dist/session/provider-cli/provider-output-state.js +832 -0
- package/dist/session/provider-cli/provider-usage.d.ts +9 -1
- package/dist/session/provider-cli/provider-usage.js +28 -5
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +257 -0
- package/dist/session/session-redaction.d.ts +3 -0
- package/dist/session/session-redaction.js +298 -0
- package/dist/session/session.base.d.ts +14 -1
- package/dist/session/session.service.d.ts +17 -2
- package/dist/session/session.service.js +708 -60
- package/dist/session/session.types.d.ts +327 -3
- package/dist/session/session.types.js +951 -10
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/unreferenced-exports.d.ts +12 -0
- package/dist/session/unreferenced-exports.js +59 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/format/format-bytes.d.ts +1 -0
- package/dist/shared/format/format-bytes.js +9 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/git/git.js +2 -1
- package/dist/shared/path/path.d.ts +1 -0
- package/dist/shared/path/path.js +21 -1
- package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
- package/dist/shared/process/dotnet-toolchain.js +307 -0
- package/dist/shared/process/host-process-recovery.d.ts +23 -0
- package/dist/shared/process/host-process-recovery.js +99 -0
- package/dist/shared/process/host-process-supervisor.d.ts +72 -0
- package/dist/shared/process/host-process-supervisor.js +383 -0
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +70 -0
- package/dist/shared/process/process.js +224 -16
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +26 -0
- package/dist/shared/process/windows-launch.js +109 -0
- package/dist/shared/provider-capabilities.d.ts +4 -0
- package/dist/shared/provider-capabilities.js +95 -0
- package/dist/shared/redaction/redaction.d.ts +1 -0
- package/dist/shared/redaction/redaction.js +47 -4
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.d.ts +3 -2
- package/dist/worktree/artifact-injector.js +82 -10
- package/dist/worktree/dependency-warmer.d.ts +78 -1
- package/dist/worktree/dependency-warmer.js +731 -13
- package/dist/worktree/index.d.ts +2 -1
- package/dist/worktree/index.js +1 -0
- package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
- package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
- package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
- package/dist/worktree/story-qa-reference-hydrator.js +253 -0
- package/dist/worktree/wip-git.d.ts +33 -0
- package/dist/worktree/wip-git.js +122 -0
- package/dist/worktree/wip-refs.d.ts +62 -0
- package/dist/worktree/wip-refs.js +119 -0
- package/dist/worktree/wip-restore.d.ts +38 -0
- package/dist/worktree/wip-restore.js +190 -0
- package/dist/worktree/wip-snapshot.d.ts +50 -0
- package/dist/worktree/wip-snapshot.js +268 -0
- package/dist/worktree/worktree-paths.d.ts +4 -0
- package/dist/worktree/worktree-paths.js +30 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +98 -0
- package/dist/worktree/worktree-wip.d.ts +49 -0
- package/dist/worktree/worktree-wip.js +182 -0
- package/dist/worktree/worktree.base.d.ts +10 -1
- package/dist/worktree/worktree.service.d.ts +30 -4
- package/dist/worktree/worktree.service.js +379 -54
- package/dist/worktree/worktree.types.d.ts +38 -1
- package/package.json +12 -7
- package/runtime/windows-job-supervisor.ps1 +722 -0
- package/runtime/windows-listener-owner.ps1 +33 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { ForgeFailureError } from "../session/session.types.js";
|
|
7
|
+
export function defaultPlaywrightBrowserCacheCandidates(playwrightCoreDirectory, env = process.env, platform = process.platform, homeDirectory = os.homedir()) {
|
|
8
|
+
const browsersPath = env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
9
|
+
return [
|
|
10
|
+
// PLAYWRIGHT_BROWSERS_PATH=0 makes Playwright use the browsers installed beside playwright-core.
|
|
11
|
+
browsersPath === "0"
|
|
12
|
+
? playwrightCoreDirectory ? path.join(playwrightCoreDirectory, ".local-browsers") : null
|
|
13
|
+
: browsersPath || null,
|
|
14
|
+
env.LOCALAPPDATA ? path.join(env.LOCALAPPDATA, "ms-playwright") : null,
|
|
15
|
+
env.XDG_CACHE_HOME ? path.join(env.XDG_CACHE_HOME, "ms-playwright") : null,
|
|
16
|
+
platform === "darwin" ? path.join(homeDirectory, "Library", "Caches", "ms-playwright") : null,
|
|
17
|
+
path.join(homeDirectory, ".cache", "ms-playwright"),
|
|
18
|
+
].filter((candidate) => Boolean(candidate?.trim()));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Finds a host browser cache holding the Chromium and Chromium headless shell
|
|
22
|
+
* builds the project's installed Playwright pins. Only those two builds are
|
|
23
|
+
* checked: they are what the project's Chromium projects launch.
|
|
24
|
+
*/
|
|
25
|
+
export async function findPlaywrightBrowserCache(realWorktree, configDirectory, candidatesFor, hostPlatform) {
|
|
26
|
+
const pinned = await readPinnedChromiumBuilds(realWorktree, configDirectory, hostPlatform);
|
|
27
|
+
const checked = [...new Set(candidatesFor(pinned?.playwrightCoreDirectory ?? null).map(candidate => path.resolve(candidate)))];
|
|
28
|
+
for (const candidate of checked) {
|
|
29
|
+
const ready = pinned
|
|
30
|
+
? await hasPinnedChromiumBuilds(candidate, pinned.builds)
|
|
31
|
+
: await hasChromiumExecutable(candidate);
|
|
32
|
+
if (ready)
|
|
33
|
+
return { cache: candidate, pinned, checked };
|
|
34
|
+
}
|
|
35
|
+
return { cache: null, pinned, checked };
|
|
36
|
+
}
|
|
37
|
+
export function missingPlaywrightBrowsersError(resolution, installCommand) {
|
|
38
|
+
const missing = resolution.pinned.builds.map(build => build.directory).join(" and ");
|
|
39
|
+
const checked = resolution.checked.length > 0 ? resolution.checked.join(", ") : "none";
|
|
40
|
+
return new ForgeFailureError("host_runtime_project_start_failed", `host_runtime_project_start_failed: playwright_browsers_missing: Playwright ${resolution.pinned.version} launches `
|
|
41
|
+
+ `Chromium from ${missing}, and no host browser cache holds them (checked: ${checked}). Only the pinned Chromium `
|
|
42
|
+
+ `and Chromium headless shell builds are checked. The attempt stopped before it started; install them on this `
|
|
43
|
+
+ `host with \`${installCommand}\` and dispatch again.`, "bridge");
|
|
44
|
+
}
|
|
45
|
+
// Executable layouts Playwright launches from, per browser directory (current and legacy builds).
|
|
46
|
+
const chromiumExecutables = {
|
|
47
|
+
win32: [path.join("chrome-win64", "chrome.exe"), path.join("chrome-win", "chrome.exe")],
|
|
48
|
+
darwin: [
|
|
49
|
+
path.join("chrome-mac-arm64", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
50
|
+
path.join("chrome-mac-x64", "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
51
|
+
path.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
|
|
52
|
+
],
|
|
53
|
+
linux: [path.join("chrome-linux64", "chrome"), path.join("chrome-linux", "chrome")],
|
|
54
|
+
};
|
|
55
|
+
const headlessShellExecutables = {
|
|
56
|
+
win32: [path.join("chrome-headless-shell-win64", "chrome-headless-shell.exe"), path.join("chrome-win", "headless_shell.exe")],
|
|
57
|
+
darwin: [
|
|
58
|
+
path.join("chrome-headless-shell-mac-arm64", "chrome-headless-shell"),
|
|
59
|
+
path.join("chrome-headless-shell-mac-x64", "chrome-headless-shell"),
|
|
60
|
+
path.join("chrome-mac", "headless_shell"),
|
|
61
|
+
],
|
|
62
|
+
linux: [path.join("chrome-headless-shell-linux64", "chrome-headless-shell"), path.join("chrome-linux", "headless_shell")],
|
|
63
|
+
};
|
|
64
|
+
function platformExecutables(table) {
|
|
65
|
+
return table[process.platform] ?? table.linux;
|
|
66
|
+
}
|
|
67
|
+
async function readPinnedChromiumBuilds(realWorktree, configDirectory, hostPlatform) {
|
|
68
|
+
const manifestPath = await resolvePlaywrightCoreManifest(realWorktree, configDirectory);
|
|
69
|
+
if (!manifestPath)
|
|
70
|
+
return null;
|
|
71
|
+
let version;
|
|
72
|
+
let browsers;
|
|
73
|
+
try {
|
|
74
|
+
version = String(JSON.parse(await fs.readFile(manifestPath, "utf8")).version ?? "unknown");
|
|
75
|
+
const parsed = JSON.parse(await fs.readFile(path.join(path.dirname(manifestPath), "browsers.json"), "utf8"));
|
|
76
|
+
browsers = Array.isArray(parsed.browsers) ? parsed.browsers : [];
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const builds = [];
|
|
82
|
+
for (const [name, executables] of [
|
|
83
|
+
["chromium", platformExecutables(chromiumExecutables)],
|
|
84
|
+
["chromium-headless-shell", platformExecutables(headlessShellExecutables)],
|
|
85
|
+
]) {
|
|
86
|
+
const entry = browsers.find(browser => browser.name === name);
|
|
87
|
+
if (!entry || typeof entry.revision !== "string")
|
|
88
|
+
continue;
|
|
89
|
+
// Playwright replaces the revision only for the host platform it runs on.
|
|
90
|
+
const override = entry.revisionOverrides && typeof entry.revisionOverrides === "object"
|
|
91
|
+
? entry.revisionOverrides[hostPlatform]
|
|
92
|
+
: undefined;
|
|
93
|
+
const revision = typeof override === "string" ? override : entry.revision;
|
|
94
|
+
builds.push({ directory: `${name.replaceAll("-", "_")}-${revision}`, executables });
|
|
95
|
+
}
|
|
96
|
+
return builds.length > 0 ? { version, playwrightCoreDirectory: path.dirname(manifestPath), builds } : null;
|
|
97
|
+
}
|
|
98
|
+
async function resolvePlaywrightCoreManifest(realWorktree, configDirectory) {
|
|
99
|
+
// Follow the chain the project's test runner resolves first: pnpm does not
|
|
100
|
+
// hoist playwright-core next to @playwright/test, and a hoisted bare
|
|
101
|
+
// playwright-core may be a different version than the runner's own.
|
|
102
|
+
for (const chain of [
|
|
103
|
+
["@playwright/test", "playwright", "playwright-core"],
|
|
104
|
+
["playwright", "playwright-core"],
|
|
105
|
+
["playwright-core"],
|
|
106
|
+
]) {
|
|
107
|
+
let from = path.join(configDirectory, "package.json");
|
|
108
|
+
try {
|
|
109
|
+
for (const packageName of chain)
|
|
110
|
+
from = createRequire(from).resolve(`${packageName}/package.json`);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
// A Playwright found above the worktree is not the project's own pin.
|
|
116
|
+
const realManifest = await fs.realpath(from).catch(() => null);
|
|
117
|
+
if (realManifest && isContained(realWorktree, realManifest))
|
|
118
|
+
return realManifest;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
async function hasPinnedChromiumBuilds(cachePath, builds) {
|
|
123
|
+
for (const build of builds) {
|
|
124
|
+
if (!await anyFile(build.executables.map(executable => path.join(cachePath, build.directory, executable))))
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
async function hasChromiumExecutable(cachePath) {
|
|
130
|
+
let entries;
|
|
131
|
+
try {
|
|
132
|
+
entries = await fs.readdir(cachePath, { withFileTypes: true });
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const executableSuffixes = platformExecutables(chromiumExecutables);
|
|
138
|
+
for (const entry of entries) {
|
|
139
|
+
if (!entry.isDirectory() || !entry.name.startsWith("chromium-"))
|
|
140
|
+
continue;
|
|
141
|
+
if (await anyFile(executableSuffixes.map(suffix => path.join(cachePath, entry.name, suffix))))
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
async function anyFile(candidates) {
|
|
147
|
+
for (const candidate of candidates) {
|
|
148
|
+
try {
|
|
149
|
+
if ((await fs.stat(candidate)).isFile())
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Continue through known Playwright layouts.
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
function isContained(parent, child) {
|
|
159
|
+
const relative = path.relative(parent, child);
|
|
160
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
161
|
+
}
|
|
162
|
+
const defaultHostProbe = {
|
|
163
|
+
env: process.env,
|
|
164
|
+
platform: process.platform,
|
|
165
|
+
release: os.release(),
|
|
166
|
+
arch: os.arch(),
|
|
167
|
+
appleCpu: os.cpus().some(cpu => cpu.model.includes("Apple")),
|
|
168
|
+
osRelease: () => {
|
|
169
|
+
try {
|
|
170
|
+
return readFileSync("/etc/os-release", "utf8");
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
/** Mirrors Playwright's own host platform key, which selects `revisionOverrides` entries. */
|
|
178
|
+
export function playwrightHostPlatform(probe = defaultHostProbe) {
|
|
179
|
+
if (probe.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE)
|
|
180
|
+
return probe.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE;
|
|
181
|
+
if (probe.platform === "win32")
|
|
182
|
+
return "win64";
|
|
183
|
+
if (probe.platform === "darwin") {
|
|
184
|
+
const major = Number.parseInt(probe.release.split(".")[0] ?? "", 10);
|
|
185
|
+
if (major < 18)
|
|
186
|
+
return "mac10.13";
|
|
187
|
+
if (major === 18)
|
|
188
|
+
return "mac10.14";
|
|
189
|
+
if (major === 19)
|
|
190
|
+
return "mac10.15";
|
|
191
|
+
const macVersion = major < 25 ? major - 9 : Math.min(major + 1, 26);
|
|
192
|
+
return `mac${macVersion}${probe.appleCpu ? "-arm64" : ""}`;
|
|
193
|
+
}
|
|
194
|
+
if (probe.platform !== "linux" || !["x64", "arm64"].includes(probe.arch))
|
|
195
|
+
return "<unknown>";
|
|
196
|
+
const suffix = `-${probe.arch}`;
|
|
197
|
+
const fields = new Map((probe.osRelease() ?? "").split("\n").map(line => {
|
|
198
|
+
const [name = "", ...rest] = line.split("=");
|
|
199
|
+
return [name.toLowerCase(), rest.join("=").trim().replace(/^"(.*)"$/u, "$1")];
|
|
200
|
+
}));
|
|
201
|
+
const id = fields.get("id") ?? "";
|
|
202
|
+
const version = fields.get("version_id") ?? "";
|
|
203
|
+
const major = Number.parseInt(version, 10);
|
|
204
|
+
if (["ubuntu", "pop", "neon", "tuxedo"].includes(id)) {
|
|
205
|
+
if (major < 20)
|
|
206
|
+
return `ubuntu18.04${suffix}`;
|
|
207
|
+
if (major < 22)
|
|
208
|
+
return `ubuntu20.04${suffix}`;
|
|
209
|
+
if (major < 24)
|
|
210
|
+
return `ubuntu22.04${suffix}`;
|
|
211
|
+
if (major < 26)
|
|
212
|
+
return `ubuntu24.04${suffix}`;
|
|
213
|
+
return `ubuntu${version}${suffix}`;
|
|
214
|
+
}
|
|
215
|
+
if (id === "linuxmint") {
|
|
216
|
+
if (major <= 20)
|
|
217
|
+
return `ubuntu20.04${suffix}`;
|
|
218
|
+
return major === 21 ? `ubuntu22.04${suffix}` : `ubuntu24.04${suffix}`;
|
|
219
|
+
}
|
|
220
|
+
if (id === "debian" || id === "raspbian") {
|
|
221
|
+
if (["11", "12", "13"].includes(version))
|
|
222
|
+
return `debian${version}${suffix}`;
|
|
223
|
+
if (version === "")
|
|
224
|
+
return `debian13${suffix}`;
|
|
225
|
+
}
|
|
226
|
+
return `ubuntu24.04${suffix}`;
|
|
227
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HostRuntimePlaywrightConfig } from "./host-runtime-contract.js";
|
|
2
|
+
import { type PlaywrightBrowserCacheCandidates } from "./playwright-browser-cache.js";
|
|
3
|
+
export interface PlaywrightHostRuntimeContext {
|
|
4
|
+
readonly worktreePath: string;
|
|
5
|
+
readonly temporaryDirectory: string;
|
|
6
|
+
readonly testOutputDirectory: string;
|
|
7
|
+
readonly browserProfileDirectory: string;
|
|
8
|
+
readonly baseUrl: string;
|
|
9
|
+
readonly ownershipToken: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PreparedPlaywrightHostRuntime {
|
|
12
|
+
readonly configPath: string;
|
|
13
|
+
readonly environment: Readonly<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Prepares a finite Playwright test boundary for a managed-host attempt.
|
|
17
|
+
* The generated overlay points tests at Forge's verified listener, disables
|
|
18
|
+
* Playwright-managed web servers, and keeps writable artifacts attempt-local.
|
|
19
|
+
*/
|
|
20
|
+
export declare class PlaywrightHostRuntimeAdapter {
|
|
21
|
+
private readonly browserCacheCandidates;
|
|
22
|
+
private readonly hostPlatform;
|
|
23
|
+
constructor(browserCacheCandidates?: PlaywrightBrowserCacheCandidates, hostPlatform?: () => string);
|
|
24
|
+
/**
|
|
25
|
+
* Fails a host that lacks the project's pinned Chromium builds before any
|
|
26
|
+
* database, build, launch, or promotion work, so the attempt never runs
|
|
27
|
+
* toward a Playwright gate whose every spec would fail at browser launch.
|
|
28
|
+
*/
|
|
29
|
+
assertBrowserCacheReady(config: HostRuntimePlaywrightConfig, worktreePath: string): Promise<void>;
|
|
30
|
+
private readyBrowserCache;
|
|
31
|
+
/**
|
|
32
|
+
* Removes the generated config, which names the base URL of the stack it was prepared for. A
|
|
33
|
+
* stopped stack's config must not survive: its port may be reassigned to another attempt, and a
|
|
34
|
+
* provider that remembers the config's path would otherwise run Playwright against that port.
|
|
35
|
+
* The next `prepare` writes a fresh one.
|
|
36
|
+
*/
|
|
37
|
+
discardOverlay(temporaryDirectory: string): Promise<void>;
|
|
38
|
+
prepare(config: HostRuntimePlaywrightConfig, context: PlaywrightHostRuntimeContext): Promise<PreparedPlaywrightHostRuntime>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { assertCanonicalDirectory, createPrivateCanonicalDirectory } from "./attempt-private-directory.js";
|
|
5
|
+
import { readCanonicalSourceFile } from "./canonical-source-file.js";
|
|
6
|
+
import { runAttemptPathOperation } from "./attempt-path-operation.js";
|
|
7
|
+
import { defaultPlaywrightBrowserCacheCandidates, findPlaywrightBrowserCache, missingPlaywrightBrowsersError, playwrightHostPlatform, } from "./playwright-browser-cache.js";
|
|
8
|
+
const maximumConfigBytes = 1024 * 1024;
|
|
9
|
+
/**
|
|
10
|
+
* Prepares a finite Playwright test boundary for a managed-host attempt.
|
|
11
|
+
* The generated overlay points tests at Forge's verified listener, disables
|
|
12
|
+
* Playwright-managed web servers, and keeps writable artifacts attempt-local.
|
|
13
|
+
*/
|
|
14
|
+
export class PlaywrightHostRuntimeAdapter {
|
|
15
|
+
browserCacheCandidates;
|
|
16
|
+
hostPlatform;
|
|
17
|
+
constructor(browserCacheCandidates = defaultPlaywrightBrowserCacheCandidates, hostPlatform = playwrightHostPlatform) {
|
|
18
|
+
this.browserCacheCandidates = browserCacheCandidates;
|
|
19
|
+
this.hostPlatform = hostPlatform;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fails a host that lacks the project's pinned Chromium builds before any
|
|
23
|
+
* database, build, launch, or promotion work, so the attempt never runs
|
|
24
|
+
* toward a Playwright gate whose every spec would fail at browser launch.
|
|
25
|
+
*/
|
|
26
|
+
async assertBrowserCacheReady(config, worktreePath) {
|
|
27
|
+
const { realWorktree, realSource } = await projectConfigLocation(config, worktreePath);
|
|
28
|
+
await this.readyBrowserCache(worktreePath, realWorktree, path.dirname(realSource));
|
|
29
|
+
}
|
|
30
|
+
async readyBrowserCache(worktreePath, realWorktree, configDirectory) {
|
|
31
|
+
const installCommand = await resolvePlaywrightBrowserInstallCommand(worktreePath, configDirectory);
|
|
32
|
+
const resolution = await findPlaywrightBrowserCache(realWorktree, configDirectory, this.browserCacheCandidates, this.hostPlatform());
|
|
33
|
+
if (resolution.pinned && !resolution.cache) {
|
|
34
|
+
throw missingPlaywrightBrowsersError({ ...resolution, pinned: resolution.pinned }, installCommand);
|
|
35
|
+
}
|
|
36
|
+
return { cache: resolution.cache, installCommand };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Removes the generated config, which names the base URL of the stack it was prepared for. A
|
|
40
|
+
* stopped stack's config must not survive: its port may be reassigned to another attempt, and a
|
|
41
|
+
* provider that remembers the config's path would otherwise run Playwright against that port.
|
|
42
|
+
* The next `prepare` writes a fresh one.
|
|
43
|
+
*/
|
|
44
|
+
async discardOverlay(temporaryDirectory) {
|
|
45
|
+
if (!await assertCanonicalDirectory(temporaryDirectory, true))
|
|
46
|
+
return;
|
|
47
|
+
await fs.rm(path.join(path.resolve(temporaryDirectory), playwrightOverlayFileName), { force: true });
|
|
48
|
+
}
|
|
49
|
+
async prepare(config, context) {
|
|
50
|
+
const { realWorktree, realSource } = await projectConfigLocation(config, context.worktreePath);
|
|
51
|
+
const sourceConfig = path.resolve(path.resolve(context.worktreePath), config.config);
|
|
52
|
+
const sourceBytes = await readCanonicalSourceFile(sourceConfig, maximumConfigBytes);
|
|
53
|
+
if (sourceBytes.length < 1) {
|
|
54
|
+
throw new Error(`playwright_runtime_adapter_invalid: project config must be a regular 1-${maximumConfigBytes} byte file.`);
|
|
55
|
+
}
|
|
56
|
+
const sourceConfigText = sourceBytes.toString("utf8");
|
|
57
|
+
const projectNames = [...sourceConfigText.matchAll(/\bname\s*:\s*["']([^"']+)["']/gu)]
|
|
58
|
+
.map(match => match[1])
|
|
59
|
+
.filter((name, index, names) => names.indexOf(name) === index);
|
|
60
|
+
await ensureAttemptWritableDirectories([
|
|
61
|
+
context.temporaryDirectory,
|
|
62
|
+
context.testOutputDirectory,
|
|
63
|
+
context.browserProfileDirectory,
|
|
64
|
+
], realWorktree);
|
|
65
|
+
const temporaryDirectory = await realContainedDirectory(context.temporaryDirectory, realWorktree, "temporary directory");
|
|
66
|
+
const testOutputDirectory = await realContainedDirectory(context.testOutputDirectory, realWorktree, "test output directory");
|
|
67
|
+
const browserProfileDirectory = await realContainedDirectory(context.browserProfileDirectory, realWorktree, "browser profile directory");
|
|
68
|
+
const attemptRoot = path.dirname(temporaryDirectory);
|
|
69
|
+
if (path.dirname(testOutputDirectory) !== attemptRoot || path.dirname(browserProfileDirectory) !== attemptRoot) {
|
|
70
|
+
throw new Error("playwright_runtime_adapter_invalid: writable directories must belong to the same attempt root.");
|
|
71
|
+
}
|
|
72
|
+
const baseUrl = loopbackHttpUrl(context.baseUrl);
|
|
73
|
+
if (!/^[0-9a-f]{32}$/u.test(context.ownershipToken)) {
|
|
74
|
+
throw new Error("playwright_runtime_adapter_invalid: ownership token must be a normalized dispatch attempt UUID.");
|
|
75
|
+
}
|
|
76
|
+
const overlayPath = path.join(temporaryDirectory, playwrightOverlayFileName);
|
|
77
|
+
const { cache: readyCache, installCommand: browserInstallCommand } = await this.readyBrowserCache(context.worktreePath, realWorktree, path.dirname(realSource));
|
|
78
|
+
const browserCache = readyCache
|
|
79
|
+
? { path: readyCache, ready: true }
|
|
80
|
+
: { path: await attemptBrowserCache(attemptRoot), ready: false };
|
|
81
|
+
await writeAttemptOverlay(overlayPath, renderOverlay({
|
|
82
|
+
projectConfigUrl: pathToFileURL(realSource).href,
|
|
83
|
+
projectConfigDirectory: path.dirname(realSource),
|
|
84
|
+
testOutputDirectory,
|
|
85
|
+
baseUrl,
|
|
86
|
+
workers: config.workers,
|
|
87
|
+
projectNames,
|
|
88
|
+
}));
|
|
89
|
+
return {
|
|
90
|
+
configPath: overlayPath,
|
|
91
|
+
environment: {
|
|
92
|
+
FORGE_PLAYWRIGHT_CONFIG: overlayPath,
|
|
93
|
+
FORGE_PLAYWRIGHT_BASE_URL: baseUrl,
|
|
94
|
+
FORGE_E2E_WEB_URL: baseUrl,
|
|
95
|
+
FORGE_E2E_OWNERSHIP_MODE: "attempt",
|
|
96
|
+
FORGE_E2E_OWNERSHIP_TOKEN: context.ownershipToken,
|
|
97
|
+
FORGE_PLAYWRIGHT_BROWSER_READY: browserCache.ready ? "true" : "false",
|
|
98
|
+
FORGE_PLAYWRIGHT_BROWSER_INSTALL_COMMAND: browserInstallCommand,
|
|
99
|
+
PLAYWRIGHT_BROWSERS_PATH: browserCache.path,
|
|
100
|
+
PLAYWRIGHT_HTML_OUTPUT_DIR: path.join(testOutputDirectory, "html-report"),
|
|
101
|
+
PLAYWRIGHT_BLOB_OUTPUT_DIR: path.join(testOutputDirectory, "blob-report"),
|
|
102
|
+
PLAYWRIGHT_JUNIT_OUTPUT_NAME: path.join(testOutputDirectory, "results.xml"),
|
|
103
|
+
PLAYWRIGHT_JSON_OUTPUT_NAME: path.join(testOutputDirectory, "results.json"),
|
|
104
|
+
FORGE_BROWSER_PROFILE_DIR: browserProfileDirectory,
|
|
105
|
+
FORGE_TEST_OUTPUT_DIR: testOutputDirectory,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function projectConfigLocation(config, worktreePath) {
|
|
111
|
+
const resolvedWorktree = path.resolve(worktreePath);
|
|
112
|
+
const [realWorktree, realSource] = await Promise.all([
|
|
113
|
+
fs.realpath(resolvedWorktree),
|
|
114
|
+
fs.realpath(path.resolve(resolvedWorktree, config.config)),
|
|
115
|
+
]);
|
|
116
|
+
assertContained(realWorktree, realSource, "project Playwright config");
|
|
117
|
+
return { realWorktree, realSource };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Without an installed Playwright the pinned build is unknown; the attempt
|
|
121
|
+
* gets its own empty cache and the readiness manifest names the install command.
|
|
122
|
+
*/
|
|
123
|
+
async function attemptBrowserCache(attemptRoot) {
|
|
124
|
+
const attemptCache = path.join(attemptRoot, "cache", "ms-playwright");
|
|
125
|
+
await createPrivateCanonicalDirectory(attemptCache);
|
|
126
|
+
return attemptCache;
|
|
127
|
+
}
|
|
128
|
+
async function ensureAttemptWritableDirectories(targets, realWorktree) {
|
|
129
|
+
const resolvedTargets = targets.map(target => path.resolve(target));
|
|
130
|
+
const attemptRoots = new Set(resolvedTargets.map(target => path.dirname(target)));
|
|
131
|
+
if (attemptRoots.size !== 1) {
|
|
132
|
+
throw new Error("playwright_runtime_adapter_invalid: writable directories must belong to the same attempt root.");
|
|
133
|
+
}
|
|
134
|
+
const attemptRoot = [...attemptRoots][0];
|
|
135
|
+
if (!attemptRoot || attemptRoot === realWorktree || isContained(realWorktree, attemptRoot)) {
|
|
136
|
+
throw new Error("playwright_runtime_adapter_invalid: writable directories must be attempt-private and outside the worktree.");
|
|
137
|
+
}
|
|
138
|
+
await assertCanonicalDirectory(attemptRoot, true);
|
|
139
|
+
for (const target of resolvedTargets) {
|
|
140
|
+
if (target === realWorktree || isContained(realWorktree, target)) {
|
|
141
|
+
throw new Error("playwright_runtime_adapter_invalid: writable directories must be attempt-private and outside the worktree.");
|
|
142
|
+
}
|
|
143
|
+
await assertCanonicalDirectory(target, true);
|
|
144
|
+
}
|
|
145
|
+
await createPrivateCanonicalDirectory(attemptRoot);
|
|
146
|
+
for (const target of resolvedTargets)
|
|
147
|
+
await createPrivateCanonicalDirectory(target);
|
|
148
|
+
}
|
|
149
|
+
const playwrightOverlayFileName = "forge.playwright.config.mjs";
|
|
150
|
+
async function writeAttemptOverlay(target, content) {
|
|
151
|
+
const parent = path.dirname(target);
|
|
152
|
+
const identity = await assertCanonicalDirectory(parent);
|
|
153
|
+
if (!identity)
|
|
154
|
+
throw new Error("playwright_runtime_adapter_invalid: overlay parent is missing.");
|
|
155
|
+
await runAttemptPathOperation(parent, identity, { kind: "overlay", name: path.basename(target), content });
|
|
156
|
+
}
|
|
157
|
+
async function resolvePlaywrightBrowserInstallCommand(worktreePath, configDirectory) {
|
|
158
|
+
const relativeDirectory = path.relative(worktreePath, configDirectory).replaceAll(path.sep, "/") || ".";
|
|
159
|
+
if (await isFile(path.join(configDirectory, "pnpm-lock.yaml"))) {
|
|
160
|
+
return `pnpm --dir ${quoteCommandArgument(relativeDirectory)} exec playwright install chromium`;
|
|
161
|
+
}
|
|
162
|
+
if (await isFile(path.join(configDirectory, "yarn.lock"))) {
|
|
163
|
+
return `yarn --cwd ${quoteCommandArgument(relativeDirectory)} playwright install chromium`;
|
|
164
|
+
}
|
|
165
|
+
return `npm --prefix ${quoteCommandArgument(relativeDirectory)} exec playwright install chromium`;
|
|
166
|
+
}
|
|
167
|
+
async function isFile(candidate) {
|
|
168
|
+
try {
|
|
169
|
+
return (await fs.stat(candidate)).isFile();
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function quoteCommandArgument(value) {
|
|
176
|
+
return /[\s"']/u.test(value) ? JSON.stringify(value) : value;
|
|
177
|
+
}
|
|
178
|
+
function renderOverlay(values) {
|
|
179
|
+
return [
|
|
180
|
+
"// Generated by forge-bridge for one fenced host attempt.",
|
|
181
|
+
`// forge-playwright-projects: ${JSON.stringify(values.projectNames)}`,
|
|
182
|
+
"import path from \"node:path\";",
|
|
183
|
+
`import projectConfig from ${JSON.stringify(values.projectConfigUrl)};`,
|
|
184
|
+
`const projectConfigDirectory = ${JSON.stringify(values.projectConfigDirectory)};`,
|
|
185
|
+
"const resolveConfigPath = value => typeof value === \"string\" && !path.isAbsolute(value)",
|
|
186
|
+
" ? path.resolve(projectConfigDirectory, value)",
|
|
187
|
+
" : value;",
|
|
188
|
+
"const resolveModulePath = value => typeof value === \"string\" && value.startsWith(\".\")",
|
|
189
|
+
" ? path.resolve(projectConfigDirectory, value)",
|
|
190
|
+
" : value;",
|
|
191
|
+
"const resolveUse = use => ({",
|
|
192
|
+
" ...(use ?? {}),",
|
|
193
|
+
" storageState: typeof use?.storageState === \"string\" ? resolveConfigPath(use.storageState) : use?.storageState,",
|
|
194
|
+
" baseURL: " + JSON.stringify(values.baseUrl) + ",",
|
|
195
|
+
"});",
|
|
196
|
+
"const forgeUse = resolveUse(projectConfig.use);",
|
|
197
|
+
"const forgeProjects = Array.isArray(projectConfig.projects)",
|
|
198
|
+
" ? projectConfig.projects.map(project => ({",
|
|
199
|
+
" ...project,",
|
|
200
|
+
" testDir: resolveConfigPath(project.testDir),",
|
|
201
|
+
" snapshotDir: resolveConfigPath(project.snapshotDir),",
|
|
202
|
+
" use: resolveUse(project.use),",
|
|
203
|
+
" }))",
|
|
204
|
+
" : projectConfig.projects;",
|
|
205
|
+
"const forgeReporter = Array.isArray(projectConfig.reporter)",
|
|
206
|
+
" ? projectConfig.reporter.map(reporter => Array.isArray(reporter)",
|
|
207
|
+
" ? [resolveModulePath(reporter[0]), ...reporter.slice(1)]",
|
|
208
|
+
" : resolveModulePath(reporter))",
|
|
209
|
+
" : resolveModulePath(projectConfig.reporter);",
|
|
210
|
+
"const forgeProviderOnlySpecs = (() => {",
|
|
211
|
+
" try {",
|
|
212
|
+
" const parsed = JSON.parse(process.env.FORGE_CI_REPAIR_PROVIDER_ONLY_SPECS ?? '[]');",
|
|
213
|
+
" return Array.isArray(parsed) ? parsed.filter(value => typeof value === 'string' && value.length > 0) : [];",
|
|
214
|
+
" } catch {",
|
|
215
|
+
" return [];",
|
|
216
|
+
" }",
|
|
217
|
+
"})();",
|
|
218
|
+
"const forgeTestIgnore = forgeProviderOnlySpecs.length === 0",
|
|
219
|
+
" ? projectConfig.testIgnore",
|
|
220
|
+
" : [...(Array.isArray(projectConfig.testIgnore) ? projectConfig.testIgnore : projectConfig.testIgnore ? [projectConfig.testIgnore] : []), ...forgeProviderOnlySpecs];",
|
|
221
|
+
"export default {",
|
|
222
|
+
" ...projectConfig,",
|
|
223
|
+
" testDir: resolveConfigPath(projectConfig.testDir),",
|
|
224
|
+
" snapshotDir: resolveConfigPath(projectConfig.snapshotDir),",
|
|
225
|
+
" globalSetup: resolveModulePath(projectConfig.globalSetup),",
|
|
226
|
+
" globalTeardown: resolveModulePath(projectConfig.globalTeardown),",
|
|
227
|
+
" reporter: forgeReporter,",
|
|
228
|
+
" testIgnore: forgeTestIgnore,",
|
|
229
|
+
` outputDir: ${JSON.stringify(values.testOutputDirectory)},`,
|
|
230
|
+
` workers: ${values.workers},`,
|
|
231
|
+
" webServer: undefined,",
|
|
232
|
+
" use: forgeUse,",
|
|
233
|
+
" projects: forgeProjects,",
|
|
234
|
+
"};",
|
|
235
|
+
"",
|
|
236
|
+
].join("\n");
|
|
237
|
+
}
|
|
238
|
+
async function realContainedDirectory(target, realWorktree, label) {
|
|
239
|
+
await assertCanonicalDirectory(target);
|
|
240
|
+
const realTarget = await fs.realpath(path.resolve(target));
|
|
241
|
+
if (realTarget === realWorktree || isContained(realWorktree, realTarget)) {
|
|
242
|
+
throw new Error(`playwright_runtime_adapter_invalid: ${label} must be attempt-private and outside the worktree.`);
|
|
243
|
+
}
|
|
244
|
+
const stat = await fs.stat(realTarget);
|
|
245
|
+
if (!stat.isDirectory())
|
|
246
|
+
throw new Error(`playwright_runtime_adapter_invalid: ${label} must be a directory.`);
|
|
247
|
+
return realTarget;
|
|
248
|
+
}
|
|
249
|
+
function assertContained(parent, child, label) {
|
|
250
|
+
if (!isContained(parent, child)) {
|
|
251
|
+
throw new Error(`playwright_runtime_adapter_invalid: ${label} must stay inside the prepared worktree.`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function isContained(parent, child) {
|
|
255
|
+
const relative = path.relative(parent, child);
|
|
256
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
257
|
+
}
|
|
258
|
+
function loopbackHttpUrl(value) {
|
|
259
|
+
let url;
|
|
260
|
+
try {
|
|
261
|
+
url = new URL(value);
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
throw new Error("playwright_runtime_adapter_invalid: base URL must be an HTTP loopback URL.");
|
|
265
|
+
}
|
|
266
|
+
if ((url.protocol !== "http:" && url.protocol !== "https:")
|
|
267
|
+
|| url.hostname !== "127.0.0.1"
|
|
268
|
+
|| !url.port
|
|
269
|
+
|| url.username
|
|
270
|
+
|| url.password) {
|
|
271
|
+
throw new Error("playwright_runtime_adapter_invalid: base URL must be an HTTP loopback URL.");
|
|
272
|
+
}
|
|
273
|
+
return url.href.replace(/\/$/u, "");
|
|
274
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HostParallelProofIdentity } from "./host-runtime-promotion.js";
|
|
2
|
+
export interface PreparedRuntimeIdentityDiagnostics {
|
|
3
|
+
readonly entries: Map<string, string>;
|
|
4
|
+
}
|
|
5
|
+
/** Bind evidence to the prepared source, including unstaged replacements, not just HEAD. */
|
|
6
|
+
export declare function preparedRuntimeIdentity(worktreePath: string, signal?: AbortSignal, diagnostics?: PreparedRuntimeIdentityDiagnostics): Promise<HostParallelProofIdentity>;
|