Commit f79daa2
feat(template-agent-builder): make WorkOS auth and EE license optional in dev (#18171)
## Summary
The Agent Builder template could not start unless WorkOS auth
credentials and a `MASTRA_EE_LICENSE` were both set, which made it hard
to try the template locally. This change makes both optional for local
development so the template boots out of the box.
- **Auth is now optional.** WorkOS AuthKit + RBAC follow the same
env-gated pattern already used for the Composio, Slack, and Browserbase
integrations: they are only enabled when the WorkOS variables are
present. With them unset, the template runs without authentication.
- **The redundant startup license check is removed.** The license is
still enforced by `@mastra/editor` for production use (with a
development bypass), so the template's own fail-fast guard was redundant
and blocked local dev. Development no longer requires a license.
## Changes
- `src/mastra/auth.ts`: `initWorkOS` returns `null` when the WorkOS env
vars are not all set, instead of throwing.
- `src/mastra/index.ts`: `auth`/`rbac` are spread into the server config
only when WorkOS is configured; removed the `requireEnterpriseLicense()`
startup call.
- `src/mastra/env.ts`: removed the now-unused `requireEnterpriseLicense`
and `requiredEnv` helpers.
- `.env.example`: WorkOS moved to an optional section; license
documented as required for production only.
- `README.md`: WorkOS listed under optional integrations; license framed
as production-only with a dev note.
## Test plan
- Copy the template out of the monorepo, `pnpm install`, set only
`OPENAI_API_KEY`, run `mastra dev` — it boots with no auth and no
license.
- Add `WORKOS_API_KEY`, `WORKOS_CLIENT_ID`, `WORKOS_COOKIE_PASSWORD` and
restart — auth + RBAC are enabled.
## Note
This PR is based on the playground request-context fix branch so its
diff is scoped to the template only. Rebase onto `main` once that PR
merges.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5 (Explain Like I'm 5)
This PR makes it possible to run the Agent Builder template on your
computer without needing to set up special authentication or buy an
enterprise license first. Instead of requiring all the setup details
before you can even start the app, it now checks if you have them and
skips authentication if you don't, letting you test and develop locally
with just the OpenAI API key.
## Changes Summary
### Core Functionality Changes
**Authentication made optional for local development:**
- `src/mastra/auth.ts`: The `initWorkOS` function now returns `null`
when WorkOS environment variables (`WORKOS_API_KEY`, `WORKOS_CLIENT_ID`,
`WORKOS_COOKIE_PASSWORD`) are missing, instead of throwing an error.
When variables are present, it initializes WorkOS auth and RBAC as
before.
- `src/mastra/index.ts`: The Mastra server configuration now
conditionally includes `auth` and `rbac` only when WorkOS is properly
configured. Removed the unconditional `requireEnterpriseLicense()`
startup-time check.
- `src/mastra/env.ts`: Removed the `requiredEnv` and
`requireEnterpriseLicense` helper functions that are no longer needed
with the optional authentication pattern.
### Configuration & Documentation Updates
**Updated environment variable documentation:**
- `.env.example`: Clarified that `OPENAI_API_KEY` powers builder-created
agents and that `MASTRA_EE_LICENSE` is required only for production
(development runs without it). Expanded WorkOS section to explain that
AuthKit + RBAC are only enabled when all required WorkOS variables are
set.
- `README.md`: Updated to reflect that WorkOS AuthKit
authentication/RBAC is optional, adjusted license prerequisites for
production vs. development, and documented that the template runs
without authentication when WorkOS values are unset.
### Model & Dependency Updates
**Model configuration:**
- `src/mastra/index.ts`: Updated the builder model allowlist to use the
`gpt-5.4-*` family with `gpt-5.4-nano` as the default model. Removed
redundant builder features configuration block.
**New dependencies:**
- `package.json`: Added `@mastra/stagehand: "latest"` and `zod:
"^4.3.6"` as direct dependencies (zod was previously relied upon as a
peer of `@mastra/core`).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: YJ <yj@example.com>
Co-authored-by: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>1 parent b04369d commit f79daa2
6 files changed
Lines changed: 33 additions & 54 deletions
File tree
- templates/template-agent-builder
- src/mastra
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | | - | |
34 | | - | |
| 32 | + | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 52 | | |
66 | 53 | | |
67 | 54 | | |
| |||
72 | 59 | | |
73 | 60 | | |
74 | 61 | | |
75 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
76 | 68 | | |
77 | 69 | | |
78 | | - | |
| 70 | + | |
79 | 71 | | |
80 | 72 | | |
81 | 73 | | |
| |||
103 | 95 | | |
104 | 96 | | |
105 | 97 | | |
106 | | - | |
107 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
108 | 104 | | |
109 | 105 | | |
110 | 106 | | |
| |||
0 commit comments