Recover server-v4 drizzle stack onto main
Merged
MO
8mo ago+3736+3736+0123456789012345678901234567890123456789-692-692-012345678901234567890123456789
Why
The original server-v4 stacked PRs merged into each other after STG-1614 had already merged into main, so the env/test-harness work, Drizzle foundation, and Drizzle schema/controller flow never actually reached main.
This PR recovers that full stack onto current main in one branch.
What Changed
- cherry-picked the three stacked squash-merge commits from
#1896,#1897, and#1898onto freshmain - preserved the full
server-v4env/test harness cleanup, Drizzle foundation, DB smoke tests, schema/migration work, and/v4/llmscontroller/service/repo flow - added one small follow-up commit to normalize
pnpm-lock.yamlagainst currentmainafter applying the recovered stack
Test Plan
pnpm installpnpm --filter @browserbasehq/stagehand-server-v4 run lintpnpm --filter @browserbasehq/stagehand-server-v4 run test:unitpnpm --filter @browserbasehq/stagehand-server-v4 run buildpnpm --filter @browserbasehq/stagehand-server-v4 run gen:openapi
Summary by cubic
Recovers the server‑v4 Drizzle stack onto main, restoring DB‑backed /v4/llms and switching the public LLMId to UUID. Adds a typed env, clean app bootstrap, and a local pglite/Postgres runtime with migrations, tests, and a simpler source‑based test harness.
-
New Features
- Drizzle foundation with
pglitedefault and Postgres option; newdb:*scripts viadrizzle-kit. - Fastify
databasePluginand unified DB client;app.tsbootstrap with health/readiness and Swagger/OpenAPI; env via@t3-oss/env-core. - Tables/relations for LLMs and Stagehand; DB‑derived Zod schemas; first migration; OpenAPI updated for UUID
LLMIdwith strict format and pattern. - LLM module (repo/service/controller) backing
/v4/llms; routes now delegate to the controller; browser session create uses the service and auto‑creates a system default LLM whenllmIdis missing. - Tests run from source via
tsx; test server script simplified;turbotasks cleaned up; schema cleanup (z.url()).
- Drizzle foundation with
-
Migration
- Run:
pnpm --filter @browserbasehq/stagehand-server-v4 db:migrate. - Local dev uses
pgliteat~/.stagehand/db/stagehand-v4. For Postgres setSTAGEHAND_DB_MODE=postgresandDATABASE_URL. - Update clients to treat
LLMIdas a UUID and regenerate fromopenapi.v4.yamlif needed.
- Run: