@mastra/code-sdk 1.15.0-alpha.2 → 1.15.0-alpha.3

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.
@@ -0,0 +1,200 @@
1
+ import { join } from "path";
2
+ import { execFile } from "child_process";
3
+ import { homedir } from "os";
4
+ import { chmod, mkdir, readFile, writeFile } from "fs/promises";
5
+ import { createServer } from "http";
6
+ //#region src/platform/index.ts
7
+ /**
8
+ * Mastra Platform client for Mastra Code.
9
+ *
10
+ * Shares `~/.mastra/credentials.json` with the `mastra` CLI so a single login
11
+ * works for both. Unlike the CLI flow, nothing here writes to stdout or reads
12
+ * stdin, so it is safe to drive from the TUI.
13
+ */
14
+ const MASTRA_PLATFORM_API_URL = process.env.MASTRA_PLATFORM_API_URL || "https://platform.mastra.ai";
15
+ const CREDENTIALS_FILE = join(join(homedir(), ".mastra"), "credentials.json");
16
+ async function loadPlatformCredentials(filePath = CREDENTIALS_FILE) {
17
+ try {
18
+ return JSON.parse(await readFile(filePath, "utf-8"));
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+ async function savePlatformCredentials(creds, filePath = CREDENTIALS_FILE) {
24
+ await mkdir(join(filePath, ".."), {
25
+ recursive: true,
26
+ mode: 448
27
+ });
28
+ await writeFile(filePath, JSON.stringify(creds, null, 2), { mode: 384 });
29
+ await chmod(filePath, 384).catch(() => {});
30
+ }
31
+ async function verifyToken(token, signal) {
32
+ try {
33
+ return (await fetch(`${MASTRA_PLATFORM_API_URL}/v1/auth/verify`, {
34
+ headers: { Authorization: `Bearer ${token}` },
35
+ signal
36
+ })).ok;
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+ async function refreshToken(creds, signal) {
42
+ if (!creds.refreshToken) return null;
43
+ try {
44
+ const res = await fetch(`${MASTRA_PLATFORM_API_URL}/v1/auth/refresh-token`, {
45
+ method: "POST",
46
+ headers: { "Content-Type": "application/json" },
47
+ body: JSON.stringify({ refreshToken: creds.refreshToken }),
48
+ signal
49
+ });
50
+ if (!res.ok) return null;
51
+ const data = await res.json();
52
+ creds.token = data.accessToken;
53
+ creds.refreshToken = data.refreshToken;
54
+ await savePlatformCredentials(creds);
55
+ return data.accessToken;
56
+ } catch {
57
+ return null;
58
+ }
59
+ }
60
+ /**
61
+ * Returns a valid session from env (`MASTRA_API_TOKEN` + `MASTRA_ORG_ID`) or
62
+ * stored credentials, refreshing the token if needed. Returns null when the
63
+ * user must log in.
64
+ */
65
+ async function getPlatformSession(signal) {
66
+ const envToken = process.env.MASTRA_API_TOKEN;
67
+ const envOrg = process.env.MASTRA_ORG_ID;
68
+ if (envToken && envOrg) return {
69
+ token: envToken,
70
+ orgId: envOrg
71
+ };
72
+ const creds = await loadPlatformCredentials();
73
+ if (!creds) return null;
74
+ const orgId = envOrg ?? creds.currentOrgId ?? creds.organizationId;
75
+ if (await verifyToken(creds.token, signal)) return {
76
+ token: creds.token,
77
+ orgId
78
+ };
79
+ const refreshed = await refreshToken(creds, signal);
80
+ return refreshed ? {
81
+ token: refreshed,
82
+ orgId
83
+ } : null;
84
+ }
85
+ function openBrowser(url) {
86
+ const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", [
87
+ "/c",
88
+ "start",
89
+ "",
90
+ url
91
+ ]] : ["xdg-open", [url]];
92
+ execFile(cmd, args, () => {});
93
+ }
94
+ const CALLBACK_HTML = (ok) => `<!doctype html><html><body style="background:#0d0d0d;color:#fff;font-family:system-ui;display:flex;align-items:center;justify-content:center;min-height:100vh"><div style="text-align:center"><h1>${ok ? "Logged in!" : "Login failed"}</h1><p>${ok ? "You can close this tab and return to Mastra Code." : "Close this tab and try again."}</p></div></body></html>`;
95
+ /** Browser-based Mastra Platform login using the same callback protocol as `mastra auth login`. */
96
+ async function loginToPlatform(options = {}) {
97
+ const { signal } = options;
98
+ signal?.throwIfAborted();
99
+ const server = createServer();
100
+ const state = Buffer.from(globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16))).toString("hex");
101
+ const port = await new Promise((resolve, reject) => {
102
+ server.once("error", reject);
103
+ server.listen(0, "127.0.0.1", () => {
104
+ const addr = server.address();
105
+ if (typeof addr === "object" && addr) resolve(addr.port);
106
+ });
107
+ });
108
+ const loginUrl = `${MASTRA_PLATFORM_API_URL}/v1/auth/login?product=cli&cli_port=${port}&state=${state}`;
109
+ options.onUrl?.(loginUrl);
110
+ (options.openUrl ?? openBrowser)(loginUrl);
111
+ const creds = await new Promise((resolve, reject) => {
112
+ let settled = false;
113
+ const finish = (cb) => {
114
+ if (settled) return;
115
+ settled = true;
116
+ clearTimeout(timeout);
117
+ signal?.removeEventListener("abort", onAbort);
118
+ server.close(cb);
119
+ server.closeAllConnections();
120
+ };
121
+ const onAbort = () => finish(() => reject(/* @__PURE__ */ new Error("Login cancelled")));
122
+ const timeout = setTimeout(() => finish(() => reject(/* @__PURE__ */ new Error("Login timed out"))), options.timeoutMs ?? 300 * 1e3);
123
+ signal?.addEventListener("abort", onAbort, { once: true });
124
+ server.on("request", (req, res) => {
125
+ const url = new URL(req.url ?? "/", `http://localhost:${port}`);
126
+ if (url.pathname !== "/callback") return void res.writeHead(404).end();
127
+ const token = url.searchParams.get("token");
128
+ const userParam = url.searchParams.get("user");
129
+ const orgId = url.searchParams.get("org");
130
+ if (url.searchParams.get("state") !== state || !token || !userParam || !orgId) {
131
+ res.writeHead(400, { "Content-Type": "text/html" }).end(CALLBACK_HTML(false));
132
+ return;
133
+ }
134
+ let user;
135
+ try {
136
+ user = JSON.parse(decodeURIComponent(userParam));
137
+ } catch {
138
+ res.writeHead(400, { "Content-Type": "text/html" }).end(CALLBACK_HTML(false));
139
+ return;
140
+ }
141
+ const refresh = url.searchParams.get("refresh_token");
142
+ res.writeHead(200, {
143
+ "Content-Type": "text/html",
144
+ Connection: "close"
145
+ }).end(CALLBACK_HTML(true));
146
+ finish(() => resolve({
147
+ token,
148
+ ...refresh ? { refreshToken: refresh } : {},
149
+ user,
150
+ organizationId: orgId
151
+ }));
152
+ });
153
+ });
154
+ await savePlatformCredentials(creds, options.credentialsPath);
155
+ return creds;
156
+ }
157
+ async function platformGet(session, path, signal) {
158
+ const res = await fetch(`${MASTRA_PLATFORM_API_URL}${path}`, {
159
+ headers: {
160
+ Authorization: `Bearer ${session.token}`,
161
+ "x-organization-id": session.orgId
162
+ },
163
+ signal
164
+ });
165
+ if (!res.ok) {
166
+ const body = await res.json().catch(() => ({}));
167
+ throw new Error(`Mastra Platform request failed (${res.status}): ${body.message ?? body.error ?? path}`);
168
+ }
169
+ return await res.json();
170
+ }
171
+ async function fetchPlatformOrgs(session, signal) {
172
+ const data = await platformGet(session, "/v1/auth/orgs", signal);
173
+ return data.organizations ?? data.orgs ?? [];
174
+ }
175
+ async function fetchPlatformProjects(session, signal) {
176
+ return (await platformGet(session, "/v1/projects", signal)).projects;
177
+ }
178
+ async function fetchPlatformEnvironments(session, projectId, signal) {
179
+ return (await platformGet(session, `/v1/projects/${encodeURIComponent(projectId)}/environments`, signal)).environments;
180
+ }
181
+ const FACTORY_DOMAIN = "factory.mastra.cloud";
182
+ /**
183
+ * The Factory server URL for a deployed environment: a custom server wins,
184
+ * otherwise the managed `<env slug>.factory.mastra.cloud` domain.
185
+ */
186
+ function resolveFactoryUrl(env) {
187
+ if (env.customServerUrl) try {
188
+ const url = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(env.customServerUrl) ? env.customServerUrl : `https://${env.customServerUrl}`);
189
+ if (url.protocol !== "https:") return null;
190
+ return `${url.origin}${url.pathname}`.replace(/\/+$/, "");
191
+ } catch {
192
+ return null;
193
+ }
194
+ if (!env.instanceUrl) return null;
195
+ return `https://${env.slug}.${FACTORY_DOMAIN}`;
196
+ }
197
+ //#endregion
198
+ export { FACTORY_DOMAIN, MASTRA_PLATFORM_API_URL, fetchPlatformEnvironments, fetchPlatformOrgs, fetchPlatformProjects, getPlatformSession, loadPlatformCredentials, loginToPlatform, resolveFactoryUrl, savePlatformCredentials };
199
+
200
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/platform/index.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { createServer } from 'node:http';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\n\n/**\n * Mastra Platform client for Mastra Code.\n *\n * Shares `~/.mastra/credentials.json` with the `mastra` CLI so a single login\n * works for both. Unlike the CLI flow, nothing here writes to stdout or reads\n * stdin, so it is safe to drive from the TUI.\n */\n\nexport const MASTRA_PLATFORM_API_URL = process.env.MASTRA_PLATFORM_API_URL || 'https://platform.mastra.ai';\n\nconst CREDENTIALS_DIR = join(homedir(), '.mastra');\nconst CREDENTIALS_FILE = join(CREDENTIALS_DIR, 'credentials.json');\n\nexport interface PlatformCredentials {\n token: string;\n refreshToken?: string;\n user: { id: string; email: string; firstName: string | null; lastName: string | null };\n organizationId: string;\n currentOrgId?: string;\n}\n\nexport interface PlatformOrg {\n id: string;\n name: string;\n role?: string;\n isCurrent?: boolean;\n}\n\nexport interface PlatformProject {\n id: string;\n name: string;\n slug: string | null;\n organizationId: string;\n}\n\nexport interface PlatformEnvironment {\n id: string;\n projectId: string;\n name: string;\n slug: string;\n type: 'production' | 'staging' | 'preview';\n instanceUrl: string | null;\n customServerUrl: string | null;\n}\n\nexport interface PlatformSession {\n token: string;\n orgId: string;\n}\n\nexport async function loadPlatformCredentials(filePath = CREDENTIALS_FILE): Promise<PlatformCredentials | null> {\n try {\n return JSON.parse(await readFile(filePath, 'utf-8')) as PlatformCredentials;\n } catch {\n return null;\n }\n}\n\nexport async function savePlatformCredentials(creds: PlatformCredentials, filePath = CREDENTIALS_FILE): Promise<void> {\n const dir = join(filePath, '..');\n await mkdir(dir, { recursive: true, mode: 0o700 });\n await writeFile(filePath, JSON.stringify(creds, null, 2), { mode: 0o600 });\n await chmod(filePath, 0o600).catch(() => {});\n}\n\nasync function verifyToken(token: string, signal?: AbortSignal): Promise<boolean> {\n try {\n const res = await fetch(`${MASTRA_PLATFORM_API_URL}/v1/auth/verify`, {\n headers: { Authorization: `Bearer ${token}` },\n signal,\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nasync function refreshToken(creds: PlatformCredentials, signal?: AbortSignal): Promise<string | null> {\n if (!creds.refreshToken) return null;\n try {\n const res = await fetch(`${MASTRA_PLATFORM_API_URL}/v1/auth/refresh-token`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ refreshToken: creds.refreshToken }),\n signal,\n });\n if (!res.ok) return null;\n const data = (await res.json()) as { accessToken: string; refreshToken: string };\n creds.token = data.accessToken;\n creds.refreshToken = data.refreshToken;\n await savePlatformCredentials(creds);\n return data.accessToken;\n } catch {\n return null;\n }\n}\n\n/**\n * Returns a valid session from env (`MASTRA_API_TOKEN` + `MASTRA_ORG_ID`) or\n * stored credentials, refreshing the token if needed. Returns null when the\n * user must log in.\n */\nexport async function getPlatformSession(signal?: AbortSignal): Promise<PlatformSession | null> {\n const envToken = process.env.MASTRA_API_TOKEN;\n const envOrg = process.env.MASTRA_ORG_ID;\n if (envToken && envOrg) return { token: envToken, orgId: envOrg };\n\n const creds = await loadPlatformCredentials();\n if (!creds) return null;\n const orgId = envOrg ?? creds.currentOrgId ?? creds.organizationId;\n if (await verifyToken(creds.token, signal)) return { token: creds.token, orgId };\n const refreshed = await refreshToken(creds, signal);\n return refreshed ? { token: refreshed, orgId } : null;\n}\n\nfunction openBrowser(url: string): void {\n const [cmd, args] =\n process.platform === 'darwin'\n ? ['open', [url]]\n : process.platform === 'win32'\n ? ['cmd', ['/c', 'start', '', url]]\n : ['xdg-open', [url]];\n execFile(cmd, args as string[], () => {});\n}\n\nexport interface PlatformLoginOptions {\n signal?: AbortSignal;\n timeoutMs?: number;\n /** Called with the login URL so the UI can display it in case the browser does not open. */\n onUrl?: (url: string) => void;\n /** Override for tests. */\n openUrl?: (url: string) => void;\n credentialsPath?: string;\n}\n\nconst CALLBACK_HTML = (ok: boolean) =>\n `<!doctype html><html><body style=\"background:#0d0d0d;color:#fff;font-family:system-ui;display:flex;align-items:center;justify-content:center;min-height:100vh\"><div style=\"text-align:center\"><h1>${\n ok ? 'Logged in!' : 'Login failed'\n }</h1><p>${ok ? 'You can close this tab and return to Mastra Code.' : 'Close this tab and try again.'}</p></div></body></html>`;\n\n/** Browser-based Mastra Platform login using the same callback protocol as `mastra auth login`. */\nexport async function loginToPlatform(options: PlatformLoginOptions = {}): Promise<PlatformCredentials> {\n const { signal } = options;\n signal?.throwIfAborted();\n\n const server = createServer();\n const state = Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(16))).toString('hex');\n const port = await new Promise<number>((resolve, reject) => {\n server.once('error', reject);\n server.listen(0, '127.0.0.1', () => {\n const addr = server.address();\n if (typeof addr === 'object' && addr) resolve(addr.port);\n });\n });\n\n const loginUrl = `${MASTRA_PLATFORM_API_URL}/v1/auth/login?product=cli&cli_port=${port}&state=${state}`;\n options.onUrl?.(loginUrl);\n (options.openUrl ?? openBrowser)(loginUrl);\n\n const creds = await new Promise<PlatformCredentials>((resolve, reject) => {\n let settled = false;\n const finish = (cb: () => void) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n signal?.removeEventListener('abort', onAbort);\n server.close(cb);\n server.closeAllConnections();\n };\n const onAbort = () => finish(() => reject(new Error('Login cancelled')));\n const timeout = setTimeout(\n () => finish(() => reject(new Error('Login timed out'))),\n options.timeoutMs ?? 5 * 60 * 1000,\n );\n signal?.addEventListener('abort', onAbort, { once: true });\n\n server.on('request', (req, res) => {\n const url = new URL(req.url ?? '/', `http://localhost:${port}`);\n if (url.pathname !== '/callback') return void res.writeHead(404).end();\n\n const token = url.searchParams.get('token');\n const userParam = url.searchParams.get('user');\n const orgId = url.searchParams.get('org');\n if (url.searchParams.get('state') !== state || !token || !userParam || !orgId) {\n res.writeHead(400, { 'Content-Type': 'text/html' }).end(CALLBACK_HTML(false));\n return;\n }\n let user: PlatformCredentials['user'];\n try {\n user = JSON.parse(decodeURIComponent(userParam));\n } catch {\n res.writeHead(400, { 'Content-Type': 'text/html' }).end(CALLBACK_HTML(false));\n return;\n }\n const refresh = url.searchParams.get('refresh_token');\n res.writeHead(200, { 'Content-Type': 'text/html', Connection: 'close' }).end(CALLBACK_HTML(true));\n finish(() =>\n resolve({\n token,\n ...(refresh ? { refreshToken: refresh } : {}),\n user,\n organizationId: orgId,\n }),\n );\n });\n });\n\n await savePlatformCredentials(creds, options.credentialsPath);\n return creds;\n}\n\nasync function platformGet<T>(session: PlatformSession, path: string, signal?: AbortSignal): Promise<T> {\n const res = await fetch(`${MASTRA_PLATFORM_API_URL}${path}`, {\n headers: { Authorization: `Bearer ${session.token}`, 'x-organization-id': session.orgId },\n signal,\n });\n if (!res.ok) {\n const body = (await res.json().catch(() => ({}))) as { error?: string; message?: string };\n throw new Error(`Mastra Platform request failed (${res.status}): ${body.message ?? body.error ?? path}`);\n }\n return (await res.json()) as T;\n}\n\nexport async function fetchPlatformOrgs(session: PlatformSession, signal?: AbortSignal): Promise<PlatformOrg[]> {\n const data = await platformGet<{ organizations?: PlatformOrg[]; orgs?: PlatformOrg[] }>(\n session,\n '/v1/auth/orgs',\n signal,\n );\n return data.organizations ?? data.orgs ?? [];\n}\n\nexport async function fetchPlatformProjects(\n session: PlatformSession,\n signal?: AbortSignal,\n): Promise<PlatformProject[]> {\n return (await platformGet<{ projects: PlatformProject[] }>(session, '/v1/projects', signal)).projects;\n}\n\nexport async function fetchPlatformEnvironments(\n session: PlatformSession,\n projectId: string,\n signal?: AbortSignal,\n): Promise<PlatformEnvironment[]> {\n return (\n await platformGet<{ environments: PlatformEnvironment[] }>(\n session,\n `/v1/projects/${encodeURIComponent(projectId)}/environments`,\n signal,\n )\n ).environments;\n}\n\nexport const FACTORY_DOMAIN = 'factory.mastra.cloud';\n\n/**\n * The Factory server URL for a deployed environment: a custom server wins,\n * otherwise the managed `<env slug>.factory.mastra.cloud` domain.\n */\nexport function resolveFactoryUrl(env: PlatformEnvironment): string | null {\n if (env.customServerUrl) {\n // The Platform session token is sent to this URL, so only accept HTTPS.\n try {\n const url = new URL(\n /^[a-z][a-z\\d+.-]*:\\/\\//i.test(env.customServerUrl) ? env.customServerUrl : `https://${env.customServerUrl}`,\n );\n if (url.protocol !== 'https:') return null;\n return `${url.origin}${url.pathname}`.replace(/\\/+$/, '');\n } catch {\n return null;\n }\n }\n if (!env.instanceUrl) return null;\n return `https://${env.slug}.${FACTORY_DOMAIN}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,0BAA0B,QAAQ,IAAI,2BAA2B;AAG9E,MAAM,mBAAmB,KADD,KAAK,QAAQ,GAAG,SACI,GAAG,kBAAkB;AAuCjE,eAAsB,wBAAwB,WAAW,kBAAuD;CAC9G,IAAI;EACF,OAAO,KAAK,MAAM,MAAM,SAAS,UAAU,OAAO,CAAC;CACrD,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,wBAAwB,OAA4B,WAAW,kBAAiC;CAEpH,MAAM,MADM,KAAK,UAAU,IACb,GAAG;EAAE,WAAW;EAAM,MAAM;CAAM,CAAC;CACjD,MAAM,UAAU,UAAU,KAAK,UAAU,OAAO,MAAM,CAAC,GAAG,EAAE,MAAM,IAAM,CAAC;CACzE,MAAM,MAAM,UAAU,GAAK,CAAC,CAAC,YAAY,CAAC,CAAC;AAC7C;AAEA,eAAe,YAAY,OAAe,QAAwC;CAChF,IAAI;EAKF,QAAO,MAJW,MAAM,GAAG,wBAAwB,kBAAkB;GACnE,SAAS,EAAE,eAAe,UAAU,QAAQ;GAC5C;EACF,CAAC,EAAA,CACU;CACb,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAe,aAAa,OAA4B,QAA8C;CACpG,IAAI,CAAC,MAAM,cAAc,OAAO;CAChC,IAAI;EACF,MAAM,MAAM,MAAM,MAAM,GAAG,wBAAwB,yBAAyB;GAC1E,QAAQ;GACR,SAAS,EAAE,g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AAgB,MAAM,EAAA,CAAG;AAC/F;AAEA,eAAsB,0BACpB,SACA,WACA,QACgC;CAChC,QACE,MAAM,YACJ,SACA,gBAAgB,mBAAmB,SAAS,EAAE,gBAC9C,MACF,EAAA,CACA;AACJ;AAEA,MAAa,iBAAiB;;;;;AAM9B,SAAgB,kBAAkB,KAAyC;CACzE,IAAI,IAAI,iBAEN,IAAI;EACF,MAAM,MAAM,IAAI,IACd,0BAA0B,KAAK,IAAI,eAAe,IAAI,IAAI,kBAAkB,WAAW,IAAI,iBAC7F;EACA,IAAI,IAAI,aAAa,UAAU,OAAO;EACtC,OAAO,GAAG,IAAI,SAAS,IAAI,WAAW,QAAQ,QAAQ,EAAE;CAC1D,QAAQ;EACN,OAAO;CACT;CAEF,IAAI,CAAC,IAAI,aAAa,OAAO;CAC7B,OAAO,WAAW,IAAI,KAAK,GAAG;AAChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/code-sdk",
3
- "version": "1.15.0-alpha.2",
3
+ "version": "1.15.0-alpha.3",
4
4
  "description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -63,19 +63,20 @@
63
63
  "yaml": "^2.7.1",
64
64
  "zod": "^4.6.4",
65
65
  "@mastra/agent-browser": "0.5.4-alpha.0",
66
+ "@mastra/client-js": "1.56.0-alpha.3",
67
+ "@mastra/core": "1.79.0-alpha.3",
66
68
  "@mastra/duckdb": "1.15.0-alpha.2",
67
- "@mastra/core": "1.79.0-alpha.2",
69
+ "@mastra/fastembed": "1.3.4-alpha.1",
68
70
  "@mastra/github-signals": "0.5.2-alpha.0",
69
71
  "@mastra/libsql": "1.27.0-alpha.2",
70
- "@mastra/fastembed": "1.3.4-alpha.1",
71
72
  "@mastra/mcp": "2.4.2-alpha.0",
72
- "@mastra/memory": "1.39.0-alpha.0",
73
+ "@mastra/memory": "1.39.0-alpha.1",
73
74
  "@mastra/observability": "1.21.0-alpha.1",
74
75
  "@mastra/parallel": "0.1.3-alpha.0",
75
76
  "@mastra/pg": "1.32.0-alpha.2",
76
77
  "@mastra/schema-compat": "1.3.16-alpha.0",
77
- "@mastra/stagehand": "0.3.6-alpha.0",
78
- "@mastra/tavily": "1.1.3-alpha.0"
78
+ "@mastra/tavily": "1.1.3-alpha.0",
79
+ "@mastra/stagehand": "0.3.6-alpha.0"
79
80
  },
80
81
  "devDependencies": {
81
82
  "@libsql/client": "^0.18.0",
@@ -86,9 +87,9 @@
86
87
  "typescript": "^6.0.3",
87
88
  "typescript-eslint": "^8.57.0",
88
89
  "vitest": "4.1.11",
90
+ "@internal/workspace-test-utils": "0.0.88",
89
91
  "@internal/types-builder": "0.0.119",
90
- "@internal/lint": "0.0.144",
91
- "@internal/workspace-test-utils": "0.0.88"
92
+ "@internal/lint": "0.0.144"
92
93
  },
93
94
  "engines": {
94
95
  "node": ">=22.19.0"