0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/examples/sandbox-deployer
Dane - AI (Mastra) a1c11c5b11
chore(deps): update better-auth monorepo to v1.7.22 (#30464)
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
|
[@better-auth/drizzle-adapter@<1.7.7](https://www.better-auth.com/docs/adapters/drizzle)
([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/drizzle-adapter))
| pnpm-workspace.overrides | patch | [`1.7.18` →
`1.7.22`](https://renovatebot.com/diffs/npm/@better-auth%2fdrizzle-adapter/1.7.18/1.7.22)
| `1.7.25` (+2) |
| [better-auth](https://better-auth.com)
([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/better-auth))
| pnpm-workspace.overrides | patch | [`^1.7.18` →
`^1.7.22`](https://renovatebot.com/diffs/npm/better-auth/1.7.18/1.7.22)
| `1.7.25` (+2) |
| [better-auth](https://better-auth.com)
([source](https://redirect.github.com/better-auth/better-auth/tree/HEAD/packages/better-auth))
| dependencies | patch | [`^1.7.18` →
`^1.7.22`](https://renovatebot.com/diffs/npm/better-auth/1.7.18/1.7.22)
| `1.7.25` (+2) |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/9505) for more information.

---

### Release Notes

<details>
<summary>better-auth/better-auth
(@&#8203;better-auth/drizzle-adapter@<1.7.7)</summary>

###
[`v1.7.22`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1722)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.21...v1.7.22)

##### Patch Changes

-
[#&#8203;12333](https://redirect.github.com/better-auth/better-auth/pull/12333)
[`6536174`](6536174213)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fix
`getSession` failing with "Failed to get session" when a
`user.additionalFields` entry references a table outside the Better Auth
schema, including with database joins enabled on Drizzle and Prisma.
Join resolution now matches `references.model` against schema keys only.

###
[`v1.7.21`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1721)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.20...v1.7.21)

###
[`v1.7.20`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1720)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.19...v1.7.20)

###
[`v1.7.19`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/drizzle-adapter/CHANGELOG.md#1719)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.18...v1.7.19)

</details>

<details>
<summary>better-auth/better-auth (better-auth)</summary>

###
[`v1.7.22`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1722)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.21...v1.7.22)

##### Patch Changes

-
[#&#8203;12324](https://redirect.github.com/better-auth/better-auth/pull/12324)
[`80c407b`](80c407b7ca)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
`ReferenceError: window is not defined` when a client session
subscription is cleaned up after a test environment such as happy-dom
tears down its globals.

-
[#&#8203;12462](https://redirect.github.com/better-auth/better-auth/pull/12462)
[`d32a30a`](d32a30af37)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
session polling never firing when the runtime's `navigator` does not
report connectivity.

-
[#&#8203;12324](https://redirect.github.com/better-auth/better-auth/pull/12324)
[`80c407b`](80c407b7ca)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
client session refresh listeners piling up on the server during SSR.

-
[#&#8203;12321](https://redirect.github.com/better-auth/better-auth/pull/12321)
[`946177e`](946177e509)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! -
Revoking your current session with `revokeSession` or `revokeSessions`,
and deleting your account with `deleteUser({ token })`, now expire the
session cookies, so a cached session is no longer returned afterwards.

-
[#&#8203;12459](https://redirect.github.com/better-auth/better-auth/pull/12459)
[`d210421`](d210421a26)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! -
`getSession` no longer leaves an expired session in the request context
after returning `null`.

-
[#&#8203;12331](https://redirect.github.com/better-auth/better-auth/pull/12331)
[`485567e`](485567e2c9)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - OAuth
sign-up rejected by a `user.create.before` hook returning `false` no
longer logs a `TypeError`. It still fails with `unable_to_create_user`.

-
[#&#8203;12334](https://redirect.github.com/better-auth/better-auth/pull/12334)
[`ec3047d`](ec3047da81)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
`deleteOrganization` clearing the session's active organization when a
`beforeDeleteOrganization` hook rejected the delete. The active
organization is now cleared only after the organization is actually
deleted.

-
[#&#8203;12330](https://redirect.github.com/better-auth/better-auth/pull/12330)
[`d521343`](d521343fc3)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fix
`deferSessionRefresh` refresh requests failing with 415 in Next.js and
Nuxt, where the bodyless `POST /get-session` reached the handler as an
empty stream without a `Content-Type`.

-
[#&#8203;12451](https://redirect.github.com/better-auth/better-auth/pull/12451)
[`71052af`](71052af880)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - On
Cloudflare Workers, consuming a verification value no longer hangs when
an earlier request for the same identifier ended mid-query. A superseded
code can also no longer be consumed while a newer one is being verified
on a database without transactions.

-
[#&#8203;12448](https://redirect.github.com/better-auth/better-auth/pull/12448)
[`79219b4`](79219b4f8e)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Schema
validation now runs when the auth instance is first used instead of when
it is created, so a module-scope instance on Cloudflare Workers no
longer logs a validation error on every cold start. On every runtime, a
mismatch is no longer logged at startup and is reported by the requests
that fail.

- Updated dependencies
\[[`6536174`](6536174213),
[`262adc0`](262adc0e76),
[`e9d8e59`](e9d8e5977c),
[`79219b4`](79219b4f8e)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.22
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.22
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.22
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.22
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.22
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.22
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.22

###
[`v1.7.21`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1721)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.20...v1.7.21)

##### Patch Changes

-
[#&#8203;12126](https://redirect.github.com/better-auth/better-auth/pull/12126)
[`4739122`](4739122fa6)
Thanks
[@&#8203;hardikguptaofficialgit](https://redirect.github.com/hardikguptaofficialgit)!
- On Prisma with MongoDB, when your id columns use `@db.ObjectId`, magic
link and email OTP sign-in for users with an unverified email no longer
fail with a 500 (`Malformed ObjectID`). SAML sign-in, DPoP-bound OAuth
requests, and `private_key_jwt` client authentication are fixed the same
way, and Sign-In with Ethereum now keeps the email the user supplied
instead of a placeholder. Setups with plain `String` id columns and
other databases are unaffected.

-
[#&#8203;12392](https://redirect.github.com/better-auth/better-auth/pull/12392)
[`a277020`](a277020fa3)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Fixed the device approval page showing a valid code as invalid when
the same signed-in user looked it up twice at once, such as under React
Strict Mode in development.

-
[#&#8203;12052](https://redirect.github.com/better-auth/better-auth/pull/12052)
[`1c3410a`](1c3410a5c3)
Thanks
[@&#8203;lakshya-dhariwal](https://redirect.github.com/lakshya-dhariwal)!
- If you set `advanced.backgroundTasks.handler` and your database
adapter runs transactions (the built-in Kysely connection, MongoDB with
`client`, or Prisma or Drizzle with `transaction: true`), email sign-up
now keeps the database writes made while sending the verification email
or running `onExistingUserSignUp`. Before, those writes failed because
the sign-up had already been saved. With `emailOTP({
overrideDefaultEmailVerification: true })`, the code was never stored,
so new users could not verify their email.

Whatever adapter or background handler you use, a sign-up verification
email now goes out after the new user is saved, and
`onExistingUserSignUp`, when a duplicate sign-up triggers it, runs after
the request's database work completes. If `sendVerificationEmail`
throws, the sign-up succeeds and the error is logged; before, the
sign-up failed. To reject a sign-up, use a
`databaseHooks.user.create.before` hook. If `onExistingUserSignUp`
throws, the error is logged and the request still returns the generic
response.

-
[#&#8203;12179](https://redirect.github.com/better-auth/better-auth/pull/12179)
[`9105261`](91052614cb)
Thanks [@&#8203;ghazy2001](https://redirect.github.com/ghazy2001)! -
Generic OAuth providers configured with `discoveryHeaders` now send
those headers when fetching the provider's signing keys from a
`jwks_uri` on the same origin as `discoveryUrl`. Before, the keys
request went out without them. Providers whose key endpoint requires the
headers rejected it, so every ID token failed verification and sign-in
failed. A `jwks_uri` on another origin still gets no headers.

With `discoveryHeaders` set, the discovery request now follows redirects
only within the origin of `discoveryUrl`, so the headers no longer reach
another host. If your `discoveryUrl` redirects to another origin,
discovery now fails and Better Auth logs an error. Set `discoveryUrl` to
the final URL. Providers without `discoveryHeaders` are unaffected.

-
[#&#8203;12401](https://redirect.github.com/better-auth/better-auth/pull/12401)
[`c3a94c5`](c3a94c546a)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- Generic OAuth providers configured with `authorizationHeaders` now
send those headers when refreshing an access token, not only when
exchanging the authorization code. Before, a provider whose token
endpoint requires one of those headers accepted the sign-in but rejected
every refresh. Providers without `authorizationHeaders` are unaffected.

`refreshAccessToken` and `refreshAccessTokenRequest` from
`@better-auth/core/oauth2` accept an optional `headers` input for
providers that need extra headers on refresh. Client authentication
headers still take precedence over it.

Extra headers whose names differ only in case from a client
authentication header, such as `Authorization` with `authentication:
"basic"`, no longer produce a combined, invalid header on the code
exchange or refresh. Client authentication replaces them, including
headers a custom `tokenEndpointAuth` hook sets in any casing.

-
[#&#8203;12404](https://redirect.github.com/better-auth/better-auth/pull/12404)
[`9b40ac6`](9b40ac62af)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Plugin
packages no longer import from the `better-auth` root, so bundlers that
split code stop emitting unused Kysely chunks when used with
`better-auth/minimal`.

-
[#&#8203;12395](https://redirect.github.com/better-auth/better-auth/pull/12395)
[`b0ced9d`](b0ced9d257)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- On Cloudflare Workers, sign-ins with a `genericOAuth` provider that
uses `discoveryUrl`, and OAuth provider requests that use a configured
resource (`resources`), no longer hang. An auth instance created at
module scope retries discovery and resource seeding on later requests.
Previously, if the request running that retry ended first, every later
request that needed it waited forever. Each request now retries on its
own until one succeeds.

On other runtimes, concurrent requests may send a few more discovery
requests or resource lookups while the identity provider or database is
unreachable.

-
[#&#8203;11912](https://redirect.github.com/better-auth/better-auth/pull/11912)
[`5c12074`](5c120747e4)
Thanks
[@&#8203;gustavovalverde](https://redirect.github.com/gustavovalverde)!
- If you use PostgreSQL and other schemas in the same database are
dropped while Better Auth reads the database, for example one schema per
tenant or parallel test runs, the startup schema check and `npx
auth@latest migrate` no longer fail intermittently with `schema "…" does
not exist` or `relation "…" does not exist`. The startup schema check
now reads only the schemas on the connection's `search_path`, plus any
schema set with `schemaName` or a schema plugin, and `migrate` reads
only the schema it migrates. Before, both read every schema in the
database. If no other schemas change while Better Auth reads the
database, nothing changes for you.

-
[#&#8203;12403](https://redirect.github.com/better-auth/better-auth/pull/12403)
[`e64f624`](e64f624273)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - SIWE
verification no longer includes the internal error message (for example
a database error) in its 401 response. The original error is now logged
on the server instead.

- Updated dependencies
\[[`4739122`](4739122fa6),
[`c3a94c5`](c3a94c546a),
[`4080630`](40806302bf),
[`5c12074`](5c120747e4),
[`b241ffc`](b241ffc940),
[`57fa843`](57fa8432d8),
[`1a79da5`](1a79da5067),
[`2d10ae7`](2d10ae733e),
[`ef4d4f7`](ef4d4f7dc4)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.21
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.21
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.21
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.21
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.21
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.21
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.21

###
[`v1.7.20`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1720)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.19...v1.7.20)

##### Patch Changes

- Updated dependencies
\[[`a3f50d0`](a3f50d064d),
[`e9b43d7`](e9b43d7149),
[`265629c`](265629cb95),
[`e9b43d7`](e9b43d7149)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.20
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.20
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.20
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.20
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.20
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.20
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.20

###
[`v1.7.19`](https://redirect.github.com/better-auth/better-auth/blob/HEAD/packages/better-auth/CHANGELOG.md#1719)

[Compare
Source](https://redirect.github.com/better-auth/better-auth/compare/v1.7.18...v1.7.19)

##### Patch Changes

-
[#&#8203;12323](https://redirect.github.com/better-auth/better-auth/pull/12323)
[`a10121d`](a10121d33c)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
the `active-sessions` list in secondary storage being stored without an
expiry when the last remaining session had less than a second left.

-
[#&#8203;12335](https://redirect.github.com/better-auth/better-auth/pull/12335)
[`c41f8ff`](c41f8ff087)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
`/admin/create-user` leaving a user without a credential account when
the password was rejected (for example by the Have I Been Pwned plugin),
which made retrying with the same email fail with
`USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL`.

-
[#&#8203;12338](https://redirect.github.com/better-auth/better-auth/pull/12338)
[`e786566`](e786566dc5)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
`/admin/create-user` leaving a user without a credential account when
creating that account failed, which made retrying with the same email
fail with `USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL`.

-
[#&#8203;12336](https://redirect.github.com/better-auth/better-auth/pull/12336)
[`ac778b7`](ac778b70e9)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Client
actions now send the HTTP method passed in the second-argument fetch
options, the same as when it is nested under `fetchOptions`. Passing a
lowercase `get` or `HEAD` method no longer fails because a request body
was attached.

-
[#&#8203;12246](https://redirect.github.com/better-auth/better-auth/pull/12246)
[`5eb69d8`](5eb69d8371)
Thanks
[@&#8203;AryaKesharwani](https://redirect.github.com/AryaKesharwani)! -
`/device/token` now returns `invalid_client` instead of `invalid_grant`
when `validateClient` rejects the `client_id`, matching `/device/code`
and RFC 6749 section 5.2.

-
[#&#8203;12319](https://redirect.github.com/better-auth/better-auth/pull/12319)
[`4b0327b`](4b0327bfa3)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Plugin
schema overrides (`modelName` and field names) no longer leak into other
instances of the same plugin in one process.

-
[#&#8203;12320](https://redirect.github.com/better-auth/better-auth/pull/12320)
[`2d5ef64`](2d5ef64dae)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fix
OAuth sign-in failing with `state_mismatch` during the daylight saving
time fall-back hour on servers that do not run in UTC. The stored OAuth
state is no longer created already expired.

-
[#&#8203;12337](https://redirect.github.com/better-auth/better-auth/pull/12337)
[`5f0a0fc`](5f0a0fcef3)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - The
OpenAPI schema now documents query parameters for endpoints whose query
schema is wrapped in `z.optional()`, such as `/get-session` and Stripe's
`/subscription/list`.

-
[#&#8203;12332](https://redirect.github.com/better-auth/better-auth/pull/12332)
[`89e74b8`](89e74b81e5)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
`organization.getInvitation` returning a missing, expired, or
non-pending invitation error without a `code`. It now returns
`INVITATION_NOT_FOUND` like the other invitation endpoints.

-
[#&#8203;12318](https://redirect.github.com/better-auth/better-auth/pull/12318)
[`525bd7a`](525bd7a7d8)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fix
`listMembers` failing with a syntax error on PostgreSQL and MSSQL when
the filter or offset matches no members.

-
[#&#8203;12366](https://redirect.github.com/better-auth/better-auth/pull/12366)
[`23a60a3`](23a60a31f4)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
SIWE sign-in leaving a user behind when creating its wallet address or
account failed, which blocked that wallet from signing in again.

-
[#&#8203;12340](https://redirect.github.com/better-auth/better-auth/pull/12340)
[`29e45f8`](29e45f84d5)
Thanks [@&#8203;bytaesu](https://redirect.github.com/bytaesu)! - Fixed
social sign-up hanging on single-connection databases when the username
plugin is enabled and the provider profile maps a username.

- Updated dependencies
\[[`8412a5f`](8412a5f43b),
[`34ee100`](34ee1008d8)]:
-
[@&#8203;better-auth/core](https://redirect.github.com/better-auth/core)@1.7.19
-
[@&#8203;better-auth/drizzle-adapter](https://redirect.github.com/better-auth/drizzle-adapter)@1.7.19
-
[@&#8203;better-auth/kysely-adapter](https://redirect.github.com/better-auth/kysely-adapter)@1.7.19
-
[@&#8203;better-auth/memory-adapter](https://redirect.github.com/better-auth/memory-adapter)@1.7.19
-
[@&#8203;better-auth/mongo-adapter](https://redirect.github.com/better-auth/mongo-adapter)@1.7.19
-
[@&#8203;better-auth/prisma-adapter](https://redirect.github.com/better-auth/prisma-adapter)@1.7.19
-
[@&#8203;better-auth/telemetry](https://redirect.github.com/better-auth/telemetry)@1.7.19

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 6am every weekday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend Renovate
CLI](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yMzkuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjIzOS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWF0aW9uIl19-->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
History 2026-11-15 17:48:36 -08:00
..
scripts feat(deployer-sandbox): deploy Mastra servers to workspace sandboxes (Vercel, E2B, Daytona) (#19577) 2026-07-17 12:58:48 +02:00
src/mastra feat(deployer-sandbox): deploy Mastra servers to workspace sandboxes (Vercel, E2B, Daytona) (#19577) 2026-07-17 12:58:48 +02:00
.env.example feat(deployer-sandbox): deploy Mastra servers to workspace sandboxes (Vercel, E2B, Daytona) (#19577) 2026-07-17 12:58:48 +02:00
.gitignore feat(deployer-sandbox): deploy Mastra servers to workspace sandboxes (Vercel, E2B, Daytona) (#19577) 2026-07-17 12:58:48 +02:00
package.json chore(daytona): switch to the renamed @daytona/sdk package (#28995) 2026-11-13 17:13:01 +01:00
pnpm-lock.yaml chore(daytona): switch to the renamed @daytona/sdk package (#28995) 2026-11-13 17:13:01 +01:00
pnpm-workspace.yaml chore(deps): update better-auth monorepo to v1.7.22 (#30464) 2026-11-15 17:48:36 -08:00
README.md feat(deployer-sandbox): deploy Mastra servers to workspace sandboxes (Vercel, E2B, Daytona) (#19577) 2026-07-17 12:58:48 +02:00
tsconfig.json feat(deployer-sandbox): deploy Mastra servers to workspace sandboxes (Vercel, E2B, Daytona) (#19577) 2026-07-17 12:58:48 +02:00

Sandbox Deployer Example

Deploys a minimal Mastra server (one agent, one tool, plus Studio) into a sandbox microVM using @mastra/deployer-sandbox, and prints a live public URL. Supports three providers — Vercel Sandbox (default), E2B, and Daytona — selected with the SANDBOX_PROVIDER env var.

Sandboxes are ephemeral compute — use this for instant previews, CI smoke deploys, and verifying agent-built apps, not production hosting.

Setup

Install dependencies (this example is a standalone pnpm workspace linked to the repo's packages):

corepack pnpm@10.29.3 --dir examples/sandbox-deployer install --ignore-workspace

Authenticate with Vercel using the Vercel CLI (matches the Vercel Sandbox quickstart):

cd examples/sandbox-deployer
vercel link          # link (or create) a Vercel project
vercel env pull      # writes VERCEL_OIDC_TOKEN to .env.local

Alternatively, copy .env.example to .env and set VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID.

Add a model provider key to .env so the agent can generate:

echo "OPENAI_API_KEY=sk-..." >> .env

Deploy

pnpm build

This builds the linked workspace packages and runs mastra build, which bundles the project and deploys it into the sandbox in one step. The deploy prints the API and Studio URLs and writes .mastra/output/sandbox-deployment.json.

Note: the OIDC token from vercel env pull expires after 12 hours — re-run vercel env pull if auth starts failing.

Deploy to E2B instead

The provider is picked in src/mastra/sandbox.ts — set SANDBOX_PROVIDER=e2b (and E2B_API_KEY) to deploy the same app to an E2B sandbox:

SANDBOX_PROVIDER=e2b E2B_API_KEY=e2b_... pnpm build

E2B pauses the sandbox on timeout instead of killing it, and resumes running processes on wake — so a woken deployment answers immediately without a server relaunch.

Deploy to Daytona instead

Set SANDBOX_PROVIDER=daytona (and DAYTONA_API_KEY) to deploy the same app to a Daytona sandbox:

SANDBOX_PROVIDER=daytona DAYTONA_API_KEY=dtn_... pnpm build

The sandbox is created with public: true so the preview URL works without a token. Stopping persists the filesystem but not processes, so waking relaunches the server (like Vercel).

Lifecycle

Manage the deployment with getDeployment() from @mastra/deployer-sandbox/client (stop(), destroy(), logs(), wake-on-demand). The sandbox name is the identity, so the scripts — or any other codebase — just construct the provider with the same name:

pnpm stop      # snapshot-stop (resumes on next deploy) — see scripts/stop.ts
pnpm destroy   # permanently delete the sandbox — see scripts/destroy.ts

Set SANDBOX_PROVIDER=e2b (or daytona) on these too when managing a deployment on another provider.

Both work from a fresh process: the provider attaches to the named sandbox without resuming it, so stopping or destroying never wakes (or bills) a stopped sandbox first. The Vercel CLI works too (vercel sandbox ls|stop|rm).

Redeploys (pnpm build again) reuse the named sandbox and skip npm install when the install inputs (package.json, bundled lockfiles, and the install command) are unchanged.

See the sandbox deployment docs for routing tiers, security notes, and CI recipes.