mastra 1.19.0-alpha.8 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +166 -0
  2. package/dist/analytics/index.js +4 -4
  3. package/dist/api-FT5GISRU.js +4 -0
  4. package/dist/api-FT5GISRU.js.map +1 -0
  5. package/dist/{chunk-L2SGSIJI.js → chunk-DBERXPFF.js} +16 -6
  6. package/dist/chunk-DBERXPFF.js.map +1 -0
  7. package/dist/{chunk-4Z57PBTZ.js → chunk-EGDDF6K2.js} +3 -3
  8. package/dist/{chunk-4Z57PBTZ.js.map → chunk-EGDDF6K2.js.map} +1 -1
  9. package/dist/{chunk-XCHUVWWD.js → chunk-I3ZAXMFJ.js} +8 -5
  10. package/dist/chunk-I3ZAXMFJ.js.map +1 -0
  11. package/dist/{chunk-YZP443XD.js → chunk-P6DWHJ3B.js} +8 -8
  12. package/dist/chunk-P6DWHJ3B.js.map +1 -0
  13. package/dist/{chunk-EXG3XKBK.js → chunk-YWEV457P.js} +4 -4
  14. package/dist/{chunk-EXG3XKBK.js.map → chunk-YWEV457P.js.map} +1 -1
  15. package/dist/commands/api/route-metadata.generated.d.ts +1 -1
  16. package/dist/commands/api/route-metadata.generated.d.ts.map +1 -1
  17. package/dist/commands/auth/client.d.ts.map +1 -1
  18. package/dist/commands/create/create.js +5 -5
  19. package/dist/commands/db/platform-api.d.ts +1 -1
  20. package/dist/commands/db/platform-api.d.ts.map +1 -1
  21. package/dist/commands/deploy/index.d.ts.map +1 -1
  22. package/dist/commands/deploy/validate-dir.d.ts +12 -0
  23. package/dist/commands/deploy/validate-dir.d.ts.map +1 -0
  24. package/dist/commands/deploy-preflight.d.ts +13 -0
  25. package/dist/commands/deploy-preflight.d.ts.map +1 -1
  26. package/dist/commands/env/env-file.d.ts +16 -0
  27. package/dist/commands/env/env-file.d.ts.map +1 -0
  28. package/dist/commands/env/env.d.ts.map +1 -1
  29. package/dist/commands/env/vars.d.ts +18 -0
  30. package/dist/commands/env/vars.d.ts.map +1 -0
  31. package/dist/commands/init/utils.d.ts.map +1 -1
  32. package/dist/commands/server/env.d.ts.map +1 -1
  33. package/dist/credentials-N4SAI3J3.js +4 -0
  34. package/dist/{credentials-EGXLGJFI.js.map → credentials-N4SAI3J3.js.map} +1 -1
  35. package/dist/docs/SKILL.md +1 -1
  36. package/dist/docs/assets/SOURCE_MAP.json +4 -4
  37. package/dist/docs/references/reference-cli-mastra.md +19 -4
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +294 -196
  40. package/dist/index.js.map +1 -1
  41. package/dist/studio/assets/{core-g551FJEo.js → core-rJnGu7dN.js} +1 -1
  42. package/dist/studio/assets/{index-InEURcK6.js → index-B9ZrQ3WU.js} +2 -2
  43. package/dist/studio/assets/{main-CPtdepE2.js → main-BMJMT8I-.js} +195 -195
  44. package/dist/studio/assets/{style-0PPJ5riO.css → style-BOO55eNy.css} +1 -1
  45. package/dist/studio/index.html +2 -2
  46. package/package.json +8 -8
  47. package/dist/api-C4LNCE5C.js +0 -4
  48. package/dist/api-C4LNCE5C.js.map +0 -1
  49. package/dist/chunk-L2SGSIJI.js.map +0 -1
  50. package/dist/chunk-XCHUVWWD.js.map +0 -1
  51. package/dist/chunk-YZP443XD.js.map +0 -1
  52. package/dist/credentials-EGXLGJFI.js +0 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,171 @@
1
1
  # mastra
2
2
 
3
+ ## 1.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added CLI commands to manage platform databases, environments, and deploys without leaving the terminal. ([#19199](https://github.com/mastra-ai/mastra/pull/19199))
8
+
9
+ The project is resolved automatically from `MASTRA_PROJECT_ID`, the `--project <name|slug|id>` flag, or the `.mastra-project.json` written by `mastra deploy` — run the commands from your project directory and you never need to name the project.
10
+
11
+ **Databases**
12
+
13
+ ```bash
14
+ mastra env db list # kind, status, scope, injected env var names
15
+ mastra env db list staging # only databases feeding one environment
16
+ mastra env db create --kind turso # shared by all environments, polls until ready
17
+ mastra env db create staging --kind turso # scoped to one environment
18
+ mastra env db show <database> # detail + connection env vars (secrets masked)
19
+ mastra env db detach <database> # confirm prompt, admin only
20
+ ```
21
+
22
+ `env db list` shows the attachment mapping: shared (project-scoped) databases feed all environments, environment-scoped databases feed only their environment. Provisioning failures are surfaced with the provider error instead of being swallowed.
23
+
24
+ **Environments and deploys**
25
+
26
+ ```bash
27
+ mastra env list # now shows latest deploy status + managed env var names
28
+ mastra env create staging # explicit environment creation
29
+ mastra env restart <env> # push saved env vars and restart the running service
30
+ mastra env deploys # all deploys across environments, active marker
31
+ mastra env deploys staging # only one environment's deploys
32
+ ```
33
+
34
+ Breaking change to the existing `mastra env` commands: the `<project>` positional argument is replaced by the resolution above (`mastra env list <project>` → `mastra env list --project <project>`), and `mastra env create <project> -n <name>` is now `mastra env create <name>`.
35
+
36
+ - Added `mastra env vars pull [environment]` to download the full set of env vars an environment actually deploys with — vars stored on the environment (for example, added in the dashboard's environment editor) merged with project-level vars. Managed vars from attached databases are listed as comments (names only) since their values are platform-managed secrets. ([#19400](https://github.com/mastra-ai/mastra/pull/19400))
37
+
38
+ ```bash
39
+ mastra env vars pull staging --output .env.staging
40
+ ```
41
+
42
+ Previously the only pull command, `mastra server env pull`, silently read project-level vars only, so vars added through the dashboard were missing from the pulled file. That command now prints a note about its scope and points to `mastra env vars pull`.
43
+
44
+ ### Patch Changes
45
+
46
+ - Added an optional session scope to the agent controller API so clients can address independent sessions that share one resource (for example one session per git worktree). ([#19357](https://github.com/mastra-ai/mastra/pull/19357))
47
+
48
+ Session routes now accept a `sessionScope` query parameter, and `AgentController.session()` in the client accepts a scope that travels on every request:
49
+
50
+ ```ts
51
+ const controller = client.getAgentController('code');
52
+
53
+ // Address the worktree's own session instead of the shared one:
54
+ const session = controller.session('repo-123', '/worktrees/feature-a');
55
+ await session.create({ tags: { projectPath: '/worktrees/feature-a' } });
56
+ await session.sendMessage('hello');
57
+ ```
58
+
59
+ Requests without a scope behave exactly as before.
60
+
61
+ - Added image attachment support to agent controller chat. You can now send images (and other files) with a message, and the Mastra Code web chat lets you attach, paste, or drag-and-drop images which render inline in the transcript. ([#19368](https://github.com/mastra-ai/mastra/pull/19368))
62
+
63
+ ```ts
64
+ await session.sendMessage({
65
+ content: 'What is in this screenshot?',
66
+ files: [{ data: base64Png, mediaType: 'image/png', filename: 'screenshot.png' }],
67
+ });
68
+ ```
69
+
70
+ - Rename `mastra env db detach` to `mastra env db delete` and make the confirmation prompt state that the database and all of its data are permanently deleted with the provider. The old name described a non-destructive unlink, but the operation deprovisions the Turso/Neon database — data included. The `detach` name is reserved for a future true non-destructive detach. ([#19402](https://github.com/mastra-ai/mastra/pull/19402))
71
+
72
+ - Fixed .env file changes not triggering dev server reload by resolving env file paths to absolute paths before passing them to Rollup's file watcher ([#19051](https://github.com/mastra-ai/mastra/pull/19051))
73
+
74
+ - Fix file-based agent `instructions.md` hot reload in dev. ([#19359](https://github.com/mastra-ai/mastra/pull/19359))
75
+
76
+ - Fixed the default project scaffold failing the deploy preflight check. New projects now read the database URL from TURSO_DATABASE_URL when it is set (for example from a hosted database created with `mastra env db create`) and fall back to a local file during development, so the first `mastra deploy` is no longer blocked by a local storage path error. ([#19395](https://github.com/mastra-ai/mastra/pull/19395))
77
+
78
+ - Fixed `mastra deploy` preflight blocking deploys that are actually fine: ([#19071](https://github.com/mastra-ai/mastra/pull/19071))
79
+
80
+ **Env-guarded storage fallbacks** — code like `process.env.TURSO_DATABASE_URL || "file:./.mastra-demo.db"` no longer hard-errors when the environment variable is provided for the deploy. If the variable is missing from your env file you still get an error, and if no env file is available you get a warning instead.
81
+
82
+ **Library env-var false positives** — the missing environment variable check now only looks at variables your own code references, so variables read by bundled Mastra packages (like `AUTO_BLOCK_EXTERNAL_PROVIDERS`) no longer show up as warnings. They are listed as info instead.
83
+
84
+ **Platform-stored env vars** — `mastra deploy` and `mastra server deploy` preflight now merge the env vars already stored on the target environment / server project under your local env file (local wins, mirroring the platform's deploy-time merge). Vars stored only on the platform no longer trigger `MISSING_ENV_VAR` or `LOCAL_STORAGE_PATH` alarms.
85
+
86
+ **Platform-injected guards** — storage fallbacks guarded by variables the platform sets automatically (like `MASTRA_STORAGE_URL` on Mastra Cloud) are trusted and never flagged.
87
+
88
+ These deploys previously required `--skip-preflight` to get through.
89
+
90
+ - `mastra server deploy` and `mastra studio deploy` no longer fail with "No env file found for deploy" when the project has no `.env*` file (e.g. in CI). Like `mastra deploy`, they now proceed without uploading env vars so the vars stored on the platform are used, and preflight reports unverifiable env-guarded paths as warnings instead of errors. ([#19082](https://github.com/mastra-ai/mastra/pull/19082))
91
+
92
+ - Added run activity reporting to agent controller sessions. `session.state()` responses include a `running` flag so UIs can show a working indicator immediately when attaching to a session that is already mid-run, and each thread returned by `session.listThreads()` carries a `state` of `'active'` or `'idle'` (backed by the same per-thread run tracking that signal `ifIdle` delivery uses), so one listing can power activity indicators across every worktree or scope sharing a resource instead of polling each session: ([#19357](https://github.com/mastra-ai/mastra/pull/19357))
93
+
94
+ ```ts
95
+ const session = client.getAgentController('code').session(resourceId);
96
+
97
+ const { running } = await session.state(); // is the session mid-run?
98
+
99
+ const threads = await session.listThreads({ tags: { projectPath } });
100
+ const busy = threads.filter(thread => thread.state === 'active');
101
+ ```
102
+
103
+ - Fix three deploy/env usability papercuts: `mastra deploy staging` now fails fast with "Did you mean: mastra deploy --env staging" instead of silently deploying to production, the preflight block message names the exact unblock command (`mastra env db create --kind turso`/`neon` based on the missing variable), and 400 validation errors now show the field name and valid options instead of a bare "invalid fields". ([#19403](https://github.com/mastra-ai/mastra/pull/19403))
104
+
105
+ - Updated dependencies [[`bd6d240`](https://github.com/mastra-ai/mastra/commit/bd6d2402db93dddaef0721667e7e8a030e7c6e16), [`0111486`](https://github.com/mastra-ai/mastra/commit/01114867612593eef5cfa2fda6a1194dfedda841), [`96a3749`](https://github.com/mastra-ai/mastra/commit/96a37492235f5b8076b3e3177d83ed5a5e44a640), [`fe1bda0`](https://github.com/mastra-ai/mastra/commit/fe1bda06f6af92a694a51712db747cda1e7185f0), [`25e7c12`](https://github.com/mastra-ai/mastra/commit/25e7c126a770069ae7fb7ecf1d2adb40e017b009), [`1ce5121`](https://github.com/mastra-ai/mastra/commit/1ce512155d122bb21f47d98383e82ffbf84b39e8), [`fb8aea3`](https://github.com/mastra-ai/mastra/commit/fb8aea384291e77311be3a64ee1717320d5c3c73), [`4adc391`](https://github.com/mastra-ai/mastra/commit/4adc3911075249c352bb4832d2471922826344de), [`a5c6337`](https://github.com/mastra-ai/mastra/commit/a5c6337d23c7686c81a32ce62f550f610543a240), [`3cfc47a`](https://github.com/mastra-ai/mastra/commit/3cfc47a6b89940aadd0f46fb01ae9624a73a865d), [`2bb7817`](https://github.com/mastra-ai/mastra/commit/2bb78176112fde628483de2830528f7eee911e56), [`51d9870`](https://github.com/mastra-ai/mastra/commit/51d987032c689c2855374d0f244f5d654da809d1), [`5cab274`](https://github.com/mastra-ai/mastra/commit/5cab2744250e22d12fefa7b32637dce224233cee), [`7fa27d3`](https://github.com/mastra-ai/mastra/commit/7fa27d3b6f5ed68cd34e454a4d3ad9c482a0cfbc), [`8b97958`](https://github.com/mastra-ai/mastra/commit/8b979589f9aa59ba67cac565949475f2ffeb4ac3), [`8410541`](https://github.com/mastra-ai/mastra/commit/84105412c60ecd3bb33a9838146f59c4b588228f), [`a58dcbb`](https://github.com/mastra-ai/mastra/commit/a58dcbb546d7e1d65ebdc1f39e55f0908fcd9391), [`aa38805`](https://github.com/mastra-ai/mastra/commit/aa38805b878b827403be785eb90688d7172f5a40), [`153bd3b`](https://github.com/mastra-ai/mastra/commit/153bd3b396bdfed6b74cf43de12db8fd2d83c04a), [`45a8e65`](https://github.com/mastra-ai/mastra/commit/45a8e65e1556d1362cb3f25187023c36de26661d), [`e955965`](https://github.com/mastra-ai/mastra/commit/e955965dce575a903e37cf054d28ea99aa48785e), [`2d22570`](https://github.com/mastra-ai/mastra/commit/2d22570c7dfdd02123d0ecc529efb05ccba2d9fc), [`07bb863`](https://github.com/mastra-ai/mastra/commit/07bb8631919c6f7cf377dccd45b096e0f17fbed0), [`c8ed116`](https://github.com/mastra-ai/mastra/commit/c8ed11699f62bcac70102ab4ec84d80d20541da6), [`01b338c`](https://github.com/mastra-ai/mastra/commit/01b338c56271f0219606710e3e8b26dee27ac6c2), [`a99eae8`](https://github.com/mastra-ai/mastra/commit/a99eae8908e500c1b2d12f9d277be616b98617a5), [`860ef7e`](https://github.com/mastra-ai/mastra/commit/860ef7e77d92b63469cbe5857aa1e626197e43e9), [`17e818c`](https://github.com/mastra-ai/mastra/commit/17e818c51a958ba90641b1a959dc38faf8c034e9), [`edce8d2`](https://github.com/mastra-ai/mastra/commit/edce8d2769f19e27a05737c627af2d765472a4f8), [`8a586ec`](https://github.com/mastra-ai/mastra/commit/8a586eca9a4914f31dff6140d0d45ac375b00669), [`4451dfe`](https://github.com/mastra-ai/mastra/commit/4451dfe857428e7abcc0261a507a2e186dae6d47), [`8b7361d`](https://github.com/mastra-ai/mastra/commit/8b7361d35de68b80d05d30a74e0c69e7218fd612), [`1d39058`](https://github.com/mastra-ai/mastra/commit/1d39058e548efd691799985d5c8af2737f1c3bd2), [`3927473`](https://github.com/mastra-ai/mastra/commit/392747323ddb10c643d12be7b9ae913159dfaeed), [`dce50dc`](https://github.com/mastra-ai/mastra/commit/dce50dc9a1c1fcd0f427bb5f6250ec74910cb04b), [`19ac158`](https://github.com/mastra-ai/mastra/commit/19ac158584b34b3ff3e3e6f7ad640c8cb65e30f5), [`fd13f8e`](https://github.com/mastra-ai/mastra/commit/fd13f8e21990f9904c3eedba3a626bb4a929cdb8), [`634caff`](https://github.com/mastra-ai/mastra/commit/634caff29a9200ad058b67d53f96d9e5832fb8a2), [`f703f87`](https://github.com/mastra-ai/mastra/commit/f703f878de072d51fda557f9c50867d8252bef05), [`3e26c87`](https://github.com/mastra-ai/mastra/commit/3e26c87de0c5bc2583b795ce6ca5889b6b161acb), [`33f2b88`](https://github.com/mastra-ai/mastra/commit/33f2b88842c09a567f906fac4cb61cd5277ced59), [`177010f`](https://github.com/mastra-ai/mastra/commit/177010ff096d2e4b28d89803be5b1a4cad2a0d6b), [`0ad646f`](https://github.com/mastra-ai/mastra/commit/0ad646f71a530f2454664299e5e01bfd13fa12e5), [`b486abf`](https://github.com/mastra-ai/mastra/commit/b486abfa2a7528c6f527e4015c819ea9fa54aaad), [`54a51e0`](https://github.com/mastra-ai/mastra/commit/54a51e0a484fe1ebad3fb1f7ef5282a075709eb7), [`c43f3a9`](https://github.com/mastra-ai/mastra/commit/c43f3a9d1efde99b38789364ba4d0ba670f430e3), [`a5008f2`](https://github.com/mastra-ai/mastra/commit/a5008f22ae710ad9402ea9f2547d8c02f74d384b), [`e2d5f37`](https://github.com/mastra-ai/mastra/commit/e2d5f373bd289be534d5f8694d34465010533df6), [`19ac158`](https://github.com/mastra-ai/mastra/commit/19ac158584b34b3ff3e3e6f7ad640c8cb65e30f5), [`4ce0163`](https://github.com/mastra-ai/mastra/commit/4ce0163dc86e675a86809685c8ce6c49f1aeb87e), [`4378341`](https://github.com/mastra-ai/mastra/commit/43783412df5ea3dd35f5b1f6e4851e79c346fc89)]:
106
+ - @mastra/core@1.51.0
107
+ - @mastra/deployer@1.51.0
108
+
109
+ ## 1.19.0-alpha.14
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [[`a99eae8`](https://github.com/mastra-ai/mastra/commit/a99eae8908e500c1b2d12f9d277be616b98617a5), [`fd13f8e`](https://github.com/mastra-ai/mastra/commit/fd13f8e21990f9904c3eedba3a626bb4a929cdb8), [`f703f87`](https://github.com/mastra-ai/mastra/commit/f703f878de072d51fda557f9c50867d8252bef05), [`0ad646f`](https://github.com/mastra-ai/mastra/commit/0ad646f71a530f2454664299e5e01bfd13fa12e5)]:
114
+ - @mastra/core@1.51.0-alpha.13
115
+ - @mastra/deployer@1.51.0-alpha.13
116
+
117
+ ## 1.19.0-alpha.13
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [[`aa38805`](https://github.com/mastra-ai/mastra/commit/aa38805b878b827403be785eb90688d7172f5a40), [`2d22570`](https://github.com/mastra-ai/mastra/commit/2d22570c7dfdd02123d0ecc529efb05ccba2d9fc), [`4378341`](https://github.com/mastra-ai/mastra/commit/43783412df5ea3dd35f5b1f6e4851e79c346fc89)]:
122
+ - @mastra/core@1.51.0-alpha.12
123
+ - @mastra/deployer@1.51.0-alpha.12
124
+
125
+ ## 1.19.0-alpha.12
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [[`45a8e65`](https://github.com/mastra-ai/mastra/commit/45a8e65e1556d1362cb3f25187023c36de26661d), [`c8ed116`](https://github.com/mastra-ai/mastra/commit/c8ed11699f62bcac70102ab4ec84d80d20541da6), [`33f2b88`](https://github.com/mastra-ai/mastra/commit/33f2b88842c09a567f906fac4cb61cd5277ced59)]:
130
+ - @mastra/core@1.51.0-alpha.11
131
+ - @mastra/deployer@1.51.0-alpha.11
132
+
133
+ ## 1.19.0-alpha.11
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies [[`4adc391`](https://github.com/mastra-ai/mastra/commit/4adc3911075249c352bb4832d2471922826344de), [`b486abf`](https://github.com/mastra-ai/mastra/commit/b486abfa2a7528c6f527e4015c819ea9fa54aaad)]:
138
+ - @mastra/core@1.51.0-alpha.10
139
+ - @mastra/deployer@1.51.0-alpha.10
140
+
141
+ ## 1.19.0-alpha.10
142
+
143
+ ### Patch Changes
144
+
145
+ - Fixed the default project scaffold failing the deploy preflight check. New projects now read the database URL from TURSO_DATABASE_URL when it is set (for example from a hosted database created with `mastra env db create`) and fall back to a local file during development, so the first `mastra deploy` is no longer blocked by a local storage path error. ([#19395](https://github.com/mastra-ai/mastra/pull/19395))
146
+
147
+ ## 1.19.0-alpha.9
148
+
149
+ ### Minor Changes
150
+
151
+ - Added `mastra env vars pull [environment]` to download the full set of env vars an environment actually deploys with — vars stored on the environment (for example, added in the dashboard's environment editor) merged with project-level vars. Managed vars from attached databases are listed as comments (names only) since their values are platform-managed secrets. ([#19400](https://github.com/mastra-ai/mastra/pull/19400))
152
+
153
+ ```bash
154
+ mastra env vars pull staging --output .env.staging
155
+ ```
156
+
157
+ Previously the only pull command, `mastra server env pull`, silently read project-level vars only, so vars added through the dashboard were missing from the pulled file. That command now prints a note about its scope and points to `mastra env vars pull`.
158
+
159
+ ### Patch Changes
160
+
161
+ - Rename `mastra env db detach` to `mastra env db delete` and make the confirmation prompt state that the database and all of its data are permanently deleted with the provider. The old name described a non-destructive unlink, but the operation deprovisions the Turso/Neon database — data included. The `detach` name is reserved for a future true non-destructive detach. ([#19402](https://github.com/mastra-ai/mastra/pull/19402))
162
+
163
+ - Fix three deploy/env usability papercuts: `mastra deploy staging` now fails fast with "Did you mean: mastra deploy --env staging" instead of silently deploying to production, the preflight block message names the exact unblock command (`mastra env db create --kind turso`/`neon` based on the missing variable), and 400 validation errors now show the field name and valid options instead of a bare "invalid fields". ([#19403](https://github.com/mastra-ai/mastra/pull/19403))
164
+
165
+ - Updated dependencies [[`edce8d2`](https://github.com/mastra-ai/mastra/commit/edce8d2769f19e27a05737c627af2d765472a4f8)]:
166
+ - @mastra/core@1.51.0-alpha.9
167
+ - @mastra/deployer@1.51.0-alpha.9
168
+
3
169
  ## 1.19.0-alpha.8
4
170
 
5
171
  ### Patch Changes
@@ -1,6 +1,6 @@
1
- export { PosthogAnalytics, bucketApiHost, getAnalytics, setAnalytics } from '../chunk-XCHUVWWD.js';
2
- import '../chunk-4Z57PBTZ.js';
3
- import '../chunk-EXG3XKBK.js';
4
- import '../chunk-L2SGSIJI.js';
1
+ export { PosthogAnalytics, bucketApiHost, getAnalytics, setAnalytics } from '../chunk-I3ZAXMFJ.js';
2
+ import '../chunk-EGDDF6K2.js';
3
+ import '../chunk-YWEV457P.js';
4
+ import '../chunk-DBERXPFF.js';
5
5
  //# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ export { fetchOrgs } from './chunk-EGDDF6K2.js';
2
+ import './chunk-DBERXPFF.js';
3
+ //# sourceMappingURL=api-FT5GISRU.js.map
4
+ //# sourceMappingURL=api-FT5GISRU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"api-FT5GISRU.js"}
@@ -27,9 +27,19 @@ function throwApiError(message, status, detail) {
27
27
  function extractApiErrorDetail(error) {
28
28
  if (!error || typeof error !== "object") return void 0;
29
29
  const o = error;
30
- if (typeof o.detail === "string" && o.detail.trim()) return o.detail;
31
- if (typeof o.message === "string" && o.message.trim()) return o.message;
32
- return void 0;
30
+ let detail;
31
+ if (typeof o.detail === "string" && o.detail.trim()) detail = o.detail;
32
+ else if (typeof o.message === "string" && o.message.trim()) detail = o.message;
33
+ else if (typeof o.error === "string" && o.error.trim()) detail = o.error;
34
+ const fieldErrors = Array.isArray(o.errors) ? o.errors.map((e) => {
35
+ if (!e || typeof e !== "object") return "";
36
+ const fe = e;
37
+ const field = typeof fe.field === "string" ? fe.field : "";
38
+ const message = typeof fe.message === "string" ? fe.message : "";
39
+ return [field, message].filter(Boolean).join(" \u2014 ");
40
+ }).filter(Boolean).join("; ") : "";
41
+ if (detail && fieldErrors) return `${detail}: ${fieldErrors}`;
42
+ return detail ?? (fieldErrors || void 0);
33
43
  }
34
44
  var _currentToken = null;
35
45
  var _refreshInFlight = null;
@@ -51,7 +61,7 @@ async function authenticatedFetch(input, init) {
51
61
  if (!_refreshInFlight) {
52
62
  _refreshInFlight = (async () => {
53
63
  try {
54
- const { tryRefreshToken, loadCredentials } = await import('./credentials-EGXLGJFI.js');
64
+ const { tryRefreshToken, loadCredentials } = await import('./credentials-N4SAI3J3.js');
55
65
  const creds = await loadCredentials();
56
66
  if (!creds) throw new Error("No credentials");
57
67
  const newToken2 = await tryRefreshToken(creds);
@@ -106,5 +116,5 @@ function platformFetch(input, init) {
106
116
  }
107
117
 
108
118
  export { MASTRA_PLATFORM_API_URL, MASTRA_STUDIO_URL, authHeaders, createApiClient, extractApiErrorDetail, platformFetch, throwApiError };
109
- //# sourceMappingURL=chunk-L2SGSIJI.js.map
110
- //# sourceMappingURL=chunk-L2SGSIJI.js.map
119
+ //# sourceMappingURL=chunk-DBERXPFF.js.map
120
+ //# sourceMappingURL=chunk-DBERXPFF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/auth/client.ts"],"names":["newToken","retryHeaders"],"mappings":";;;AAIO,IAAM,uBAAA,GAA0B,OAAA,CAAQ,GAAA,CAAI,uBAAA,IAA2B;AAM9E,SAAS,gBAAA,GAA2B;AAClC,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,kBAAA,EAAoB,OAAO,QAAQ,GAAA,CAAI,kBAAA;AACvD,EAAA,IAAI,uBAAA,CAAwB,QAAA,CAAS,SAAS,CAAA,EAAG,OAAO,0CAAA;AACxD,EAAA,OAAO,kCAAA;AACT;AAEkC,gBAAA;AAMlC,SAAS,eAAA,GAA0B;AACjC,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,iBAAA,EAAmB,OAAO,QAAQ,GAAA,CAAI,iBAAA;AACtD,EAAA,IAAI,uBAAA,CAAwB,QAAA,CAAS,SAAS,CAAA,EAAG,OAAO,kCAAA;AACxD,EAAA,OAAO,0BAAA;AACT;AAEO,IAAM,oBAAoB,eAAA;AAE1B,IAAM,uBAAA,GAA0B,yCAAA;AAOhC,SAAS,aAAA,CAAc,OAAA,EAAiB,MAAA,EAAgB,MAAA,EAAwB;AACrF,EAAA,IAAI,WAAW,GAAA,EAAK;AAClB,IAAA,MAAM,IAAI,MAAM,uBAAuB,CAAA;AAAA,EACzC;AACA,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,MAAM,CAAA,CAAE,CAAA;AACzC;AAG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AAE3B,EAAA,MAAM,OAAA,GAAkC;AAAA,IACtC,aAAA,EAAe,UAAU,KAAK,CAAA;AAAA,GAChC;AACA,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAA,CAAQ,mBAAmB,CAAA,GAAI,KAAA;AAAA,EACjC;AAEA,EAAA,OAAO,YAAA,CAAoB;AAAA,IACzB,OAAA,EAAS,uBAAA;AAAA,IACT,OAAA;AAAA,IACA,KAAA,EAAO;AAAA,GACR,CAAA;AACH;AAKO,SAAS,WAAA,CAAY,OAAe,KAAA,EAAwC;AACjF,EAAA,MAAM,OAAA,GAAkC;AAAA,IACtC,aAAA,EAAe,UAAU,KAAK,CAAA;AAAA,GAChC;AACA,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAA,CAAQ,mBAAmB,CAAA,GAAI,KAAA;AAAA,EACjC;AACA,EAAA,OAAO,OAAA;AACT;AAMO,SAAS,aAAA,CAAc,OAA+B,IAAA,EAAuC;AAClG,EAAA,OAAO,kBAAA,CAAmB,OAAO,IAAI,CAAA;AACvC","file":"chunk-DBERXPFF.js","sourcesContent":["import createClient from 'openapi-fetch';\n\nimport type { paths } from '../platform-api.js';\n\nexport const MASTRA_PLATFORM_API_URL = process.env.MASTRA_PLATFORM_API_URL || 'https://platform.mastra.ai';\n\n/**\n * Derive the gateway URL from the platform URL when not explicitly set.\n * If the platform points at staging, the gateway defaults to staging too.\n */\nfunction deriveGatewayUrl(): string {\n if (process.env.MASTRA_GATEWAY_URL) return process.env.MASTRA_GATEWAY_URL;\n if (MASTRA_PLATFORM_API_URL.includes('staging')) return 'https://gateway-api.staging.mastra.ai/v1';\n return 'https://gateway-api.mastra.ai/v1';\n}\n\nexport const MASTRA_GATEWAY_URL = deriveGatewayUrl();\n\n/**\n * Derive the studio URL from the platform URL when not explicitly set.\n * If the platform points at staging, the studio defaults to staging too.\n */\nfunction deriveStudioUrl(): string {\n if (process.env.MASTRA_STUDIO_URL) return process.env.MASTRA_STUDIO_URL;\n if (MASTRA_PLATFORM_API_URL.includes('staging')) return 'https://studio.staging.mastra.ai';\n return 'https://studio.mastra.ai';\n}\n\nexport const MASTRA_STUDIO_URL = deriveStudioUrl();\n\nexport const SESSION_EXPIRED_MESSAGE = 'Session expired. Run: mastra auth login';\n\n/**\n * Throw a standardized error for API failures.\n * - 401: \"Session expired\" (authentication failed)\n * - Other: Show the server's error detail or fall back to status code\n */\nexport function throwApiError(message: string, status: number, detail?: string): never {\n if (status === 401) {\n throw new Error(SESSION_EXPIRED_MESSAGE);\n }\n if (detail) {\n throw new Error(detail);\n }\n throw new Error(`${message}: ${status}`);\n}\n\n/** Best-effort message from platform JSON error bodies (RFC 7807 `detail`, etc.). */\nexport function extractApiErrorDetail(error: unknown): string | undefined {\n if (!error || typeof error !== 'object') return undefined;\n const o = error as Record<string, unknown>;\n\n let detail: string | undefined;\n if (typeof o.detail === 'string' && o.detail.trim()) detail = o.detail;\n else if (typeof o.message === 'string' && o.message.trim()) detail = o.message;\n else if (typeof o.error === 'string' && o.error.trim()) detail = o.error;\n\n // Validation errors (400) carry the useful part in errors[] — field name plus\n // message (e.g. the valid-options enum for a bad --region). Without this the\n // user only sees \"The request body contains invalid fields\".\n const fieldErrors = Array.isArray(o.errors)\n ? o.errors\n .map(e => {\n if (!e || typeof e !== 'object') return '';\n const fe = e as Record<string, unknown>;\n const field = typeof fe.field === 'string' ? fe.field : '';\n const message = typeof fe.message === 'string' ? fe.message : '';\n return [field, message].filter(Boolean).join(' — ');\n })\n .filter(Boolean)\n .join('; ')\n : '';\n\n if (detail && fieldErrors) return `${detail}: ${fieldErrors}`;\n return detail ?? (fieldErrors || undefined);\n}\n\n// Shared mutable token state — updated by refreshes so all callers see the latest.\nlet _currentToken: string | null = null;\nlet _currentOrgId: string | null = null;\nlet _refreshInFlight: Promise<string> | null = null;\n\n/**\n * Set the current token/orgId used by authenticated fetch.\n * Call this after login or getToken().\n */\nexport function setCurrentAuth(token: string, orgId?: string) {\n _currentToken = token;\n if (orgId !== undefined) _currentOrgId = orgId;\n}\n\n/**\n * Get the current token, if one has been set.\n */\nexport function getCurrentToken(): string | null {\n return _currentToken;\n}\n\n/**\n * A fetch wrapper that auto-refreshes the token on 401 and retries once.\n * Used by both createApiClient (openapi-fetch) and raw fetch calls.\n */\nasync function authenticatedFetch(input: string | URL | Request, init?: RequestInit): Promise<Response> {\n // openapi-fetch passes a single Request object (no init). If the first\n // fetch() returns 401 we need to retry, but the original Request's body\n // will already be consumed. Clone it up front so the retry can use the clone.\n const clonedRequest = input instanceof Request ? input.clone() : null;\n\n // Prime _currentToken from the request headers so the 401-retry path works\n // even when callers use platformFetch() directly instead of createApiClient().\n if (!_currentToken) {\n const authHeader =\n (input instanceof Request ? input.headers.get('Authorization') : null) ??\n (init?.headers instanceof Headers\n ? init.headers.get('Authorization')\n : typeof init?.headers === 'object' && init.headers && !Array.isArray(init.headers)\n ? (init.headers as Record<string, string>)['Authorization']\n : null);\n if (authHeader?.startsWith('Bearer ')) {\n _currentToken = authHeader.slice(7);\n }\n }\n\n const response = await fetch(input, init);\n\n if (response.status !== 401 || !_currentToken) {\n return response;\n }\n\n // Avoid multiple concurrent refreshes\n if (!_refreshInFlight) {\n _refreshInFlight = (async () => {\n try {\n // Dynamic import to avoid circular dependency\n const { tryRefreshToken, loadCredentials } = await import('./credentials.js');\n const creds = await loadCredentials();\n if (!creds) throw new Error('No credentials');\n\n const newToken = await tryRefreshToken(creds);\n if (!newToken) throw new Error('Refresh failed');\n\n _currentToken = newToken;\n return newToken;\n } finally {\n _refreshInFlight = null;\n }\n })();\n }\n\n let newToken: string;\n try {\n newToken = await _refreshInFlight;\n } catch {\n // Refresh failed — return the original 401 response\n return response;\n }\n\n // Retry with the refreshed token.\n if (clonedRequest) {\n // Rebuild from the clone so headers + body are intact.\n const retryHeaders = new Headers(clonedRequest.headers);\n retryHeaders.set('Authorization', `Bearer ${newToken}`);\n return fetch(new Request(clonedRequest, { headers: retryHeaders }));\n }\n\n const retryHeaders = new Headers(init?.headers);\n retryHeaders.set('Authorization', `Bearer ${newToken}`);\n return fetch(input, { ...init, headers: retryHeaders });\n}\n\n/**\n * Create a typed API client with Bearer token + org ID headers.\n * Uses authenticatedFetch for automatic 401 retry.\n */\nexport function createApiClient(token: string, orgId?: string) {\n setCurrentAuth(token, orgId);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${token}`,\n };\n if (orgId) {\n headers['x-organization-id'] = orgId;\n }\n\n return createClient<paths>({\n baseUrl: MASTRA_PLATFORM_API_URL,\n headers,\n fetch: authenticatedFetch,\n });\n}\n\n/**\n * Build auth headers for raw fetch calls (zip upload, SSE streaming, tokens).\n */\nexport function authHeaders(token: string, orgId?: string): Record<string, string> {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${token}`,\n };\n if (orgId) {\n headers['x-organization-id'] = orgId;\n }\n return headers;\n}\n\n/**\n * Make an authenticated fetch call that auto-refreshes on 401.\n * Use this instead of raw fetch() for platform API calls.\n */\nexport function platformFetch(input: string | URL | Request, init?: RequestInit): Promise<Response> {\n return authenticatedFetch(input, init);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { createApiClient, throwApiError } from './chunk-L2SGSIJI.js';
1
+ import { createApiClient, throwApiError } from './chunk-DBERXPFF.js';
2
2
 
3
3
  // src/commands/auth/api.ts
4
4
  async function fetchOrgs(token) {
@@ -11,5 +11,5 @@ async function fetchOrgs(token) {
11
11
  }
12
12
 
13
13
  export { fetchOrgs };
14
- //# sourceMappingURL=chunk-4Z57PBTZ.js.map
15
- //# sourceMappingURL=chunk-4Z57PBTZ.js.map
14
+ //# sourceMappingURL=chunk-EGDDF6K2.js.map
15
+ //# sourceMappingURL=chunk-EGDDF6K2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/auth/api.ts"],"names":[],"mappings":";;;AASA,eAAsB,UAAU,KAAA,EAA+B;AAC7D,EAAA,MAAM,MAAA,GAAS,gBAAgB,KAAK,CAAA;AACpC,EAAA,MAAM,EAAE,MAAM,KAAA,EAAO,QAAA,KAAa,MAAM,MAAA,CAAO,IAAI,eAAe,CAAA;AAElE,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,aAAA,CAAc,sBAAA,EAAwB,QAAA,CAAS,MAAA,EAAQ,KAAA,CAAM,MAAM,CAAA;AAAA,EACrE;AAEA,EAAA,OAAO,IAAA,CAAK,aAAA;AACd","file":"chunk-4Z57PBTZ.js","sourcesContent":["import { createApiClient, throwApiError } from './client.js';\n\nexport interface Org {\n id: string;\n name: string;\n role: string | null;\n isCurrent: boolean;\n}\n\nexport async function fetchOrgs(token: string): Promise<Org[]> {\n const client = createApiClient(token);\n const { data, error, response } = await client.GET('/v1/auth/orgs');\n\n if (error) {\n throwApiError('Failed to fetch orgs', response.status, error.detail);\n }\n\n return data.organizations;\n}\n"]}
1
+ {"version":3,"sources":["../src/commands/auth/api.ts"],"names":[],"mappings":";;;AASA,eAAsB,UAAU,KAAA,EAA+B;AAC7D,EAAA,MAAM,MAAA,GAAS,gBAAgB,KAAK,CAAA;AACpC,EAAA,MAAM,EAAE,MAAM,KAAA,EAAO,QAAA,KAAa,MAAM,MAAA,CAAO,IAAI,eAAe,CAAA;AAElE,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,aAAA,CAAc,sBAAA,EAAwB,QAAA,CAAS,MAAA,EAAQ,KAAA,CAAM,MAAM,CAAA;AAAA,EACrE;AAEA,EAAA,OAAO,IAAA,CAAK,aAAA;AACd","file":"chunk-EGDDF6K2.js","sourcesContent":["import { createApiClient, throwApiError } from './client.js';\n\nexport interface Org {\n id: string;\n name: string;\n role: string | null;\n isCurrent: boolean;\n}\n\nexport async function fetchOrgs(token: string): Promise<Org[]> {\n const client = createApiClient(token);\n const { data, error, response } = await client.GET('/v1/auth/orgs');\n\n if (error) {\n throwApiError('Failed to fetch orgs', response.status, error.detail);\n }\n\n return data.organizations;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { fetchOrgs } from './chunk-4Z57PBTZ.js';
2
- import { getCurrentOrgId, setCurrentOrgId, getToken, loadCredentials } from './chunk-EXG3XKBK.js';
1
+ import { fetchOrgs } from './chunk-EGDDF6K2.js';
2
+ import { getCurrentOrgId, setCurrentOrgId, getToken, loadCredentials } from './chunk-YWEV457P.js';
3
3
  import { randomUUID } from 'crypto';
4
4
  import fs3, { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
5
5
  import os from 'os';
@@ -919,7 +919,10 @@ export const mastra = new Mastra({
919
919
  id: 'composite-storage',
920
920
  default: new LibSQLStore({
921
921
  id: "mastra-storage",
922
- url: "file:./mastra.db",
922
+ // Uses a hosted database when deployed (mastra env db create --kind turso),
923
+ // and a local file during development.
924
+ url: process.env.TURSO_DATABASE_URL ?? "file:./mastra.db",
925
+ authToken: process.env.TURSO_AUTH_TOKEN,
923
926
  }),
924
927
  domains: {
925
928
  observability: await new DuckDBStore().getStore('observability'),
@@ -1669,5 +1672,5 @@ var PosthogAnalytics = class _PosthogAnalytics {
1669
1672
  };
1670
1673
 
1671
1674
  export { COMPONENTS, DepsService, FileService, LLMProvider, LLM_PROVIDERS, PosthogAnalytics, bucketApiHost, checkAndInstallCoreDeps, checkForPkgJson, createComponentsDir, createMastraDir, getAPIKey, getAnalytics, getModelIdentifier, getPackageManager, getPackageManagerAddCommand, getVersionTag, gitInit, installMastraDocsMCPServer, interactivePrompt, isGitInitialized, listOrgsAction, parseComponents, parseLlmProvider, parseMcp, parseSkills, readPackageName, resolveCurrentOrg, setAnalytics, shouldSkipDotenvLoading, switchOrgAction, wrapAction, writeAPIKey, writeAgentsMarkdown, writeClaudeMarkdown, writeCodeSample, writeIndexFile, writeObservabilityEnv };
1672
- //# sourceMappingURL=chunk-XCHUVWWD.js.map
1673
- //# sourceMappingURL=chunk-XCHUVWWD.js.map
1675
+ //# sourceMappingURL=chunk-I3ZAXMFJ.js.map
1676
+ //# sourceMappingURL=chunk-I3ZAXMFJ.js.map