Files
wehub-resource-sync cb15c5e0d8
CI / Rust (windows-latest - x86_64-pc-windows-msvc) (push) Waiting to run
CI / Native E2E Tests (push) Blocked by required conditions
CI / Windows Integration Test (push) Blocked by required conditions
CI / Version Sync Check (push) Waiting to run
CI / Rust (push) Waiting to run
CI / Dashboard (push) Waiting to run
CI / Sandbox Package (push) Waiting to run
CI / Rust (macos-latest - aarch64-apple-darwin) (push) Waiting to run
CI / Rust (macos-latest - x86_64-apple-darwin) (push) Waiting to run
CI / Global Install (macos-latest) (push) Blocked by required conditions
CI / Global Install (ubuntu-latest) (push) Blocked by required conditions
CI / Global Install (windows-latest) (push) Blocked by required conditions
Release / Check for new version (push) Has been cancelled
Release / Build macOS ARM64 (push) Has been cancelled
Release / Build macOS x64 (push) Has been cancelled
Release / Build Linux ARM64 (push) Has been cancelled
Release / Build Linux musl ARM64 (push) Has been cancelled
Release / Build Linux musl x64 (push) Has been cancelled
Release / Build Linux x64 (push) Has been cancelled
Release / Build Windows x64 (push) Has been cancelled
Release / Publish to npm (push) Has been cancelled
Release / Publish sandbox package to npm (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:58 +08:00

55 lines
1.6 KiB
TypeScript

/**
* Create a Vercel Sandbox snapshot with agent-browser + Chromium pre-installed.
*
* Run once: npx tsx scripts/create-snapshot.ts
* Then set: AGENT_BROWSER_SNAPSHOT_ID=<output id>
*
* Authentication (one of):
* - VERCEL_TOKEN + VERCEL_TEAM_ID + VERCEL_PROJECT_ID
* - VERCEL_OIDC_TOKEN (automatically available on Vercel deployments)
*
* This makes sandbox creation sub-second instead of ~30s.
*/
import "dotenv/config";
import { createSnapshot, getSandboxCredentials } from "../lib/agent-browser-sandbox";
const hasExplicitCreds = !!(
process.env.VERCEL_TOKEN &&
process.env.VERCEL_TEAM_ID &&
process.env.VERCEL_PROJECT_ID
);
const hasOidc = !!process.env.VERCEL_OIDC_TOKEN;
if (!hasExplicitCreds && !hasOidc) {
console.error(
"Missing sandbox credentials. Provide either:\n" +
" 1. VERCEL_TOKEN + VERCEL_TEAM_ID + VERCEL_PROJECT_ID\n" +
" 2. VERCEL_OIDC_TOKEN",
);
process.exit(1);
}
const creds = getSandboxCredentials();
console.log(
creds.token
? `Authenticating with explicit credentials (team: ${creds.teamId})`
: "Authenticating via VERCEL_OIDC_TOKEN",
);
async function main() {
console.log("Creating Vercel Sandbox with agent-browser + Chromium...");
console.log("This takes ~30-60 seconds on first run.\n");
const snapshotId = await createSnapshot();
console.log("\nSnapshot created successfully!");
console.log(`\n AGENT_BROWSER_SNAPSHOT_ID=${snapshotId}\n`);
console.log("Add this to your .env.local or Vercel environment variables.");
}
main().catch((err) => {
console.error("Failed to create snapshot:", err.message || err);
process.exit(1);
});