Skip to content

Commit 5981f91

Browse files
authored
Rename server package to server-v3 (browserbase#1839)
# why Nick's PR had both some server-v3 changes and server-v4 changes. I split it into two prs - just the v3 changes here, and just the v4 changes [here](browserbase#1840) (WIP). Then, once I rebased this PR, it's really just one small change to the node SEA binary stuff. # test plan Verified the split with exact file manifests before creating the branch and ran `pnpm install --lockfile-only --ignore-scripts`. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Renamed the Stagehand server to `packages/server-v3` and `@browserbasehq/stagehand-server-v3`. Updated CI, release, tests, and SEA build logic; no API or runtime changes. - **Refactors** - Moved `packages/server` to `packages/server-v3` and renamed the package to `@browserbasehq/stagehand-server-v3`. - Updated GitHub workflows (CI, SEA build, release) and artifacts to `stagehand-server-v3-*`. - Switched OpenAPI/Stainless references to `packages/server-v3/openapi.v3.yaml`. - Updated test discovery/commands and Turbo tasks to target `@browserbasehq/stagehand-server-v3`; adjusted ESLint, workspace, and scripts accordingly. - Hardened SEA build: verify Node binary includes the required fuse, fall back to the official Node distro when needed, enforce fuse presence, use `stagehand-server-v3-sea` temp paths, centralize the fuse value, and add a clear cache recovery hint when the cached Node binary lacks the fuse. - **Migration** - Use `@browserbasehq/stagehand-server-v3` in `pnpm`/Turbo filters and scripts. - Run local tasks from `packages/server-v3`. - For SEA builds/tests, use binaries named `stagehand-server-v3-<platform>-<arch>` and set `SEA_BINARY_NAME` if needed. <sup>Written for commit 645a2e6. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1839">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. -->
1 parent 424efa1 commit 5981f91

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

packages/server-v3/scripts/build-sea.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import esbuild from "esbuild";
2323
import { getRepoRootDir } from "./runtimePaths.js";
2424

2525
const repoDir = getRepoRootDir();
26+
const seaFuse = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
2627

2728
const argValue = (name: string) => {
2829
const prefix = `--${name}=`;
@@ -119,6 +120,14 @@ const runOptional = (
119120
spawnSync(cmd, args, { stdio: "ignore", ...opts });
120121
};
121122

123+
const hasSeaFuse = (binaryPath: string): boolean => {
124+
try {
125+
return fs.readFileSync(binaryPath).includes(Buffer.from(seaFuse));
126+
} catch {
127+
return false;
128+
}
129+
};
130+
122131
const download = (url: string, dest: string): Promise<void> =>
123132
new Promise((resolve, reject) => {
124133
https
@@ -167,15 +176,20 @@ const resolveNodeBinary = async (): Promise<string> => {
167176
`Cross-platform builds are not supported. Host=${process.platform}, target=${targetPlatform}`,
168177
);
169178
}
170-
if (targetArch === process.arch) {
179+
if (targetArch === process.arch && hasSeaFuse(process.execPath)) {
171180
return process.execPath;
172181
}
182+
if (targetArch === process.arch) {
183+
console.warn(
184+
`Current Node binary at ${process.execPath} does not include ${seaFuse}; falling back to the official ${process.version} distribution for SEA injection.`,
185+
);
186+
}
173187

174188
const version = process.version;
175189
const distPlatform = targetPlatform === "win32" ? "win" : targetPlatform;
176190
const archiveBase = `node-${version}-${distPlatform}-${targetArch}`;
177191
const archiveExt = distPlatform === "win" ? "zip" : "tar.xz";
178-
const tmpRoot = `${os.tmpdir()}/stagehand-sea/${archiveBase}`;
192+
const tmpRoot = `${os.tmpdir()}/stagehand-server-v3-sea/${archiveBase}`;
179193
const archivePath = `${tmpRoot}/${archiveBase}.${archiveExt}`;
180194
const extractRoot = `${tmpRoot}/${archiveBase}`;
181195
const binaryPath =
@@ -184,6 +198,11 @@ const resolveNodeBinary = async (): Promise<string> => {
184198
: `${extractRoot}/bin/node`;
185199

186200
if (fs.existsSync(binaryPath)) {
201+
if (!hasSeaFuse(binaryPath)) {
202+
throw new Error(
203+
`Node binary at ${binaryPath} does not include ${seaFuse}; unable to build SEA binary. Delete ${tmpRoot} and retry.`,
204+
);
205+
}
187206
return binaryPath;
188207
}
189208

@@ -208,6 +227,11 @@ const resolveNodeBinary = async (): Promise<string> => {
208227
if (!fs.existsSync(binaryPath)) {
209228
throw new Error(`Missing Node binary at ${binaryPath}`);
210229
}
230+
if (!hasSeaFuse(binaryPath)) {
231+
throw new Error(
232+
`Node binary at ${binaryPath} does not include ${seaFuse}; unable to build SEA binary. Delete ${tmpRoot} and retry.`,
233+
);
234+
}
211235
return binaryPath;
212236
};
213237

@@ -477,7 +501,7 @@ const main = async () => {
477501
"NODE_SEA_BLOB",
478502
`${repoDir}/packages/server-v3/dist/sea/sea-prep.blob`,
479503
"--sentinel-fuse",
480-
"NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2",
504+
seaFuse,
481505
];
482506
if (targetPlatform === "darwin") {
483507
postjectArgs.push("--macho-segment-name", "NODE_SEA");

0 commit comments

Comments
 (0)