@mastra/deployer 1.16.0-alpha.0 → 1.16.0-alpha.2
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.
- package/CHANGELOG.md +18 -0
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +21 -21
- package/dist/build/index.js +5 -5
- package/dist/build/utils.d.ts +1 -0
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/bundler/index.cjs +3 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-KVARA33X.js → chunk-34EZA3VL.js} +3 -2
- package/dist/chunk-34EZA3VL.js.map +1 -0
- package/dist/{chunk-H57LFQ6F.js → chunk-4GYV7HPY.js} +4 -4
- package/dist/{chunk-H57LFQ6F.js.map → chunk-4GYV7HPY.js.map} +1 -1
- package/dist/{chunk-GMDZEJJ4.js → chunk-54GWKZXE.js} +3 -3
- package/dist/{chunk-GMDZEJJ4.js.map → chunk-54GWKZXE.js.map} +1 -1
- package/dist/{chunk-FMHCK2VO.cjs → chunk-7UHLTY6V.cjs} +41 -41
- package/dist/{chunk-FMHCK2VO.cjs.map → chunk-7UHLTY6V.cjs.map} +1 -1
- package/dist/{chunk-K4SOPFMG.js → chunk-A6RLN5PF.js} +7 -7
- package/dist/{chunk-K4SOPFMG.js.map → chunk-A6RLN5PF.js.map} +1 -1
- package/dist/{chunk-ASGQG7XA.js → chunk-D3PYJIUL.js} +7 -7
- package/dist/{chunk-ASGQG7XA.js.map → chunk-D3PYJIUL.js.map} +1 -1
- package/dist/{chunk-LPMM6HII.cjs → chunk-DZCBXCHX.cjs} +17 -17
- package/dist/{chunk-LPMM6HII.cjs.map → chunk-DZCBXCHX.cjs.map} +1 -1
- package/dist/{chunk-POPCNNQ6.cjs → chunk-IUT5KPFY.cjs} +16 -16
- package/dist/{chunk-POPCNNQ6.cjs.map → chunk-IUT5KPFY.cjs.map} +1 -1
- package/dist/{chunk-CKCUMDQY.js → chunk-MHKOD7VM.js} +4 -4
- package/dist/{chunk-CKCUMDQY.js.map → chunk-MHKOD7VM.js.map} +1 -1
- package/dist/{chunk-HRFQEG5Y.cjs → chunk-MQVH6J4E.cjs} +16 -16
- package/dist/{chunk-HRFQEG5Y.cjs.map → chunk-MQVH6J4E.cjs.map} +1 -1
- package/dist/{chunk-OY3LBAOC.cjs → chunk-PVO6IGR4.cjs} +7 -7
- package/dist/{chunk-OY3LBAOC.cjs.map → chunk-PVO6IGR4.cjs.map} +1 -1
- package/dist/{chunk-Q57SABM6.cjs → chunk-UTKMY26P.cjs} +3 -2
- package/dist/chunk-UTKMY26P.cjs.map +1 -0
- package/dist/{chunk-4OVBCW4T.js → chunk-XM2HQJPB.js} +3 -3
- package/dist/{chunk-4OVBCW4T.js.map → chunk-XM2HQJPB.js.map} +1 -1
- package/dist/{chunk-UUMAFVGW.cjs → chunk-XQ6IBOYH.cjs} +4 -4
- package/dist/{chunk-UUMAFVGW.cjs.map → chunk-XQ6IBOYH.cjs.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +6 -6
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -3
- package/dist/server/index.js.map +1 -1
- package/dist/validator/custom-resolver.cjs +3 -3
- package/dist/validator/custom-resolver.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-KVARA33X.js.map +0 -1
- package/dist/chunk-Q57SABM6.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUTKMY26P_cjs = require('../chunk-UTKMY26P.cjs');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var promises = require('fs/promises');
|
|
6
6
|
var module$1 = require('module');
|
|
@@ -43,7 +43,7 @@ async function getParentPath(specifier, url) {
|
|
|
43
43
|
if (!importers) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
-
const matchedPackage = Object.keys(importers).find((external) =>
|
|
46
|
+
const matchedPackage = Object.keys(importers).find((external) => chunkUTKMY26P_cjs.isDependencyPartOfPackage(specifier, external));
|
|
47
47
|
if (!matchedPackage) {
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
@@ -59,7 +59,7 @@ async function resolve(specifier, context, nextResolve) {
|
|
|
59
59
|
}
|
|
60
60
|
const stubbedExternals = getStubbedExternals();
|
|
61
61
|
if (stubbedExternals.length > 0) {
|
|
62
|
-
const isStubbed = stubbedExternals.some((ext) =>
|
|
62
|
+
const isStubbed = stubbedExternals.some((ext) => chunkUTKMY26P_cjs.isDependencyPartOfPackage(specifier, ext));
|
|
63
63
|
if (isStubbed) {
|
|
64
64
|
return { url: `${STUB_PREFIX}${specifier}`, shortCircuit: true };
|
|
65
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "1.16.0-alpha.
|
|
3
|
+
"version": "1.16.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"strip-json-comments": "^5.0.3",
|
|
112
112
|
"tinyglobby": "^0.2.15",
|
|
113
113
|
"typescript-paths": "^1.5.1",
|
|
114
|
-
"@mastra/server": "1.16.0-alpha.
|
|
114
|
+
"@mastra/server": "1.16.0-alpha.2"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@hono/node-server": "^1.19.11",
|
|
@@ -133,10 +133,10 @@
|
|
|
133
133
|
"zod": "^4.3.6",
|
|
134
134
|
"@internal/lint": "0.0.73",
|
|
135
135
|
"@internal/types-builder": "0.0.48",
|
|
136
|
-
"@mastra/
|
|
137
|
-
"@mastra/
|
|
138
|
-
"@mastra/
|
|
139
|
-
"@mastra/
|
|
136
|
+
"@mastra/hono": "1.3.0-alpha.2",
|
|
137
|
+
"@mastra/mcp": "^1.3.1",
|
|
138
|
+
"@mastra/core": "1.16.0-alpha.2",
|
|
139
|
+
"@mastra/server": "1.16.0-alpha.2"
|
|
140
140
|
},
|
|
141
141
|
"peerDependencies": {
|
|
142
142
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/build/utils.ts"],"names":[],"mappings":";;;;AA0BO,SAAS,sBAAsB,QAAA,EAAqD;AACzF,EAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,IAAA,OAAO;AAAA,MACL,cAAA,EAAgB,KAAA;AAAA,MAChB,OAAA,EAAS,IAAA;AAAA,MACT,gBAAA,EAAkB,CAAC,SAAA,EAAW,QAAA,EAAU,SAAS;AAAA,KACnD;AAAA,EACF;AACA,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,IAAA;AAAA,IAChB,gBAAA,EAAkB,CAAC,MAAM;AAAA,GAC3B;AACF;AASO,SAAS,aAAA,GAAiC;AAC/C,EAAA,IAAI,OAAA,CAAQ,UAAU,GAAA,EAAK;AACzB,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA;AACT;AAWO,SAAS,yBAAA,CAA0B,KAAa,WAAA,EAAqB;AAC1E,EAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,GAAA,CAAI,UAAA,CAAW,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG,CAAA;AACzC;AAKO,SAAS,eAAe,EAAA,EAAY;AACzC,EAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,KAAA,CAAM,GAAG,CAAA;AAE1B,EAAA,IAAI,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA,EA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CAAA,+BAAA,CAAA,EAAmC,MAAA,CAAO,gBAAgB,CAAA;AAC9E,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,kCAAA,CAAA,EAAsC,MAAA,CAAO,oBAAoB,CAAA;AACrF,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,sBAAA,CAAA,EAA0B,MAAA,CAAO,SAAS,CAAA;AAC9D,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,+BAAA,CAAA,EAAmC,MAAA,CAAO,iBAAiB,CAAA;AAC/E,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,oCAAA,CAAA,EAAwC,MAAA,CAAO,qBAAqB,CAAA;AACxF,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,yBAAA,CAAA,EAA6B,MAAA,CAAO,WAAW,CAAA;AACnE,EAAA,IAAI,OAAO,aAAA,EAAe;AACxB,IAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,4BAAA,CAAA,EAAgC,MAAA,CAAO,aAAa,CAAA;AAAA,EAC1E;AACA,EAAA,IAAA,GAAO,IAAA,CAAK,UAAA,CAAW,6BAAA,EAA+B,MAAA,CAAO,QAAQ,CAAA;AAErE,EAAA,OAAO,IAAA;AACT;AAOO,SAAS,gBAAgB,SAAA,EAA4B;AAC1D,EAAA,OACE,cAAA,CAAe,QAAA,CAAS,SAAS,CAAA,IACjC,UAAU,UAAA,CAAW,OAAO,CAAA,IAC5B,cAAA,CAAe,QAAA,CAAS,SAAA,CAAU,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAC,CAAA;AAE3D","file":"chunk-KVARA33X.js","sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, mkdirSync } from 'node:fs';\nimport { builtinModules } from 'node:module';\nimport { basename, join, relative } from 'node:path';\nimport type { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';\n\n/** The detected JavaScript runtime environment */\nexport type RuntimePlatform = 'node' | 'bun';\n\n/**\n * The esbuild/bundler platform setting.\n * - 'node': Assumes Node.js environment, externalizes built-in modules\n * - 'browser': Assumes browser environment, polyfills Node APIs\n * - 'neutral': Runtime-agnostic, preserves all globals as-is (used for Bun)\n */\nexport type BundlerPlatform = 'node' | 'browser' | 'neutral';\n\n/**\n * Get nodeResolve plugin options based on the target platform.\n *\n * For 'browser' platform (e.g., Cloudflare Workers), uses browser-compatible\n * export conditions so packages like the Cloudflare SDK resolve to their\n * web runtime instead of Node.js-specific code.\n *\n * For 'node' and 'neutral' (Bun) platforms, uses Node.js module resolution.\n */\nexport function getNodeResolveOptions(platform: BundlerPlatform): RollupNodeResolveOptions {\n if (platform === 'browser') {\n return {\n preferBuiltins: false,\n browser: true,\n exportConditions: ['browser', 'worker', 'default'],\n };\n }\n return {\n preferBuiltins: true,\n exportConditions: ['node'],\n };\n}\n\n/**\n * Detect the current JavaScript runtime environment.\n *\n * This is used by the bundler to determine the appropriate esbuild platform\n * setting. When running under Bun, we need to use 'neutral' platform to\n * preserve Bun-specific globals (like Bun.s3).\n */\nexport function detectRuntime(): RuntimePlatform {\n if (process.versions?.bun) {\n return 'bun';\n }\n return 'node';\n}\n\nexport function upsertMastraDir({ dir = process.cwd() }: { dir?: string }) {\n const dirPath = join(dir, '.mastra');\n\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n execSync(`echo \".mastra\" >> .gitignore`);\n }\n}\n\nexport function isDependencyPartOfPackage(dep: string, packageName: string) {\n if (dep === packageName) {\n return true;\n }\n\n return dep.startsWith(`${packageName}/`);\n}\n\n/**\n * Get the package name from a module ID\n */\nexport function getPackageName(id: string) {\n const parts = id.split('/');\n\n if (id.startsWith('@')) {\n return parts.slice(0, 2).join('/');\n }\n\n return parts[0];\n}\n\n/**\n * During `mastra dev` we are compiling TS files to JS (inside workspaces) so that users can just their workspace packages.\n * We store these compiled files inside `node_modules/.cache` for each workspace package.\n */\nexport function getCompiledDepCachePath(rootPath: string, packageName: string) {\n return slash(join(rootPath, 'node_modules', '.cache', packageName));\n}\n\n/**\n * Convert windows backslashes to posix slashes\n *\n * @example\n * ```ts\n * slash('C:\\\\Users\\\\user\\\\code\\\\mastra') // 'C:/Users/user/code/mastra'\n * ```\n */\nexport function slash(path: string) {\n const isExtendedLengthPath = path.startsWith('\\\\\\\\?\\\\');\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll('\\\\', '/');\n}\n\n/**\n * Make a Rollup-safe name: pathless, POSIX, and without parent/absolute segments\n */\nexport function rollupSafeName(name: string, rootDir: string) {\n const rel = relative(rootDir, name);\n let entry = slash(rel);\n entry = entry.replace(/^(\\.\\.\\/)+/, '');\n entry = entry.replace(/^\\/+/, '');\n entry = entry.replace(/^[A-Za-z]:\\//, '');\n if (!entry) {\n entry = slash(basename(name));\n }\n return entry;\n}\n\n/**\n * Native binding loaders and infrastructure packages that should be ignored when identifying the actual package that requires native bindings\n */\nconst NATIVE_BINDING_LOADERS = [\n 'node-gyp-build',\n 'prebuild-install',\n 'bindings',\n 'node-addon-api',\n 'node-pre-gyp',\n 'nan', // Native Abstractions for Node.js\n] as const;\n\n/**\n * Finds the first real package from node_modules that likely contains native bindings, filtering out virtual modules and native binding loader infrastructure.\n *\n * @param moduleIds - Array of module IDs from a Rollup chunk\n * @returns The module ID of the actual native package, or undefined if not found\n *\n * @example\n * const moduleIds = [\n * '\\x00/path/node_modules/bcrypt/bcrypt.js?commonjs-module',\n * '/path/node_modules/node-gyp-build/index.js',\n * '/path/node_modules/bcrypt/bcrypt.js',\n * ];\n * findNativePackageModule(moduleIds); // Returns '/path/node_modules/bcrypt/bcrypt.js'\n */\nexport function findNativePackageModule(moduleIds: string[]): string | undefined {\n return moduleIds.find(id => {\n // Skip virtual modules (Rollup plugin-generated)\n if (id.startsWith('\\x00')) {\n return false;\n }\n\n // Must be from node_modules\n if (!id.includes('/node_modules/')) {\n return false;\n }\n\n // Skip native binding loader infrastructure\n for (const loader of NATIVE_BINDING_LOADERS) {\n if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {\n return false;\n }\n }\n\n return true;\n });\n}\n\n/**\n * Ensures that server.studioBase is normalized:\n * - Adds leading slash if missing (e.g., 'admin' → '/admin')\n * - Removes trailing slashes (e.g., '/admin/' → '/admin')\n * - Normalizes multiple slashes to single slash (e.g., '//api' → '/api')\n * - Returns empty string for root paths ('/' or '')\n *\n * @param studioBase - The studioBase path to normalize\n * @returns Normalized studioBase path string\n * @throws Error if path contains invalid characters ('..', '?', '#')\n */\nexport function normalizeStudioBase(studioBase: string): string {\n studioBase = studioBase.trim();\n\n // Validate: no path traversal, no query params, no special chars\n if (studioBase.includes('..') || studioBase.includes('?') || studioBase.includes('#')) {\n throw new Error(`Invalid base path: \"${studioBase}\". Base path cannot contain '..', '?', or '#'`);\n }\n\n // Normalize multiple slashes to single slash\n studioBase = studioBase.replace(/\\/+/g, '/');\n\n // Handle default value cases\n if (studioBase === '/' || studioBase === '') {\n return '';\n }\n\n // Remove trailing slash\n if (studioBase.endsWith('/')) {\n studioBase = studioBase.slice(0, -1);\n }\n\n // Add leading slash if missing\n if (!studioBase.startsWith('/')) {\n studioBase = `/${studioBase}`;\n }\n\n return studioBase;\n}\n\n/**\n * Configuration values for Studio's index.html placeholder injection.\n *\n * Each value is the **exact JavaScript expression** that replaces the\n * corresponding `'%%PLACEHOLDER%%'` token (including surrounding quotes).\n *\n * For literal strings pass `\"'value'\"` (quoted).\n * For runtime expressions pass the raw JS, e.g. `\"window.location.hostname\"`.\n */\nexport interface StudioInjectionConfig {\n host: string;\n port: string;\n protocol: string;\n apiPrefix: string;\n basePath: string;\n hideCloudCta: string;\n cloudApiEndpoint: string;\n experimentalFeatures: string;\n templates: string;\n telemetryDisabled: string;\n requestContextPresets: string;\n themeToggle: string;\n autoDetectUrl?: string;\n}\n\n/**\n * Replace all `%%MASTRA_*%%` placeholders in the Studio `index.html` with the\n * supplied configuration values.\n *\n * The `<base href>` tag and the `window.MASTRA_STUDIO_BASE_PATH` assignment\n * use `basePath` as a plain string (no surrounding quotes), while all other\n * placeholders replace `'%%TOKEN%%'` (with surrounding single-quotes in the\n * source HTML) with the provided expression verbatim.\n */\nexport function injectStudioHtmlConfig(html: string, config: StudioInjectionConfig): string {\n html = html.replace(`'%%MASTRA_SERVER_HOST%%'`, config.host);\n html = html.replace(`'%%MASTRA_SERVER_PORT%%'`, config.port);\n html = html.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, config.protocol);\n html = html.replace(`'%%MASTRA_API_PREFIX%%'`, config.apiPrefix);\n html = html.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, config.hideCloudCta);\n html = html.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, config.cloudApiEndpoint);\n html = html.replace(`'%%MASTRA_EXPERIMENTAL_FEATURES%%'`, config.experimentalFeatures);\n html = html.replace(`'%%MASTRA_TEMPLATES%%'`, config.templates);\n html = html.replace(`'%%MASTRA_TELEMETRY_DISABLED%%'`, config.telemetryDisabled);\n html = html.replace(`'%%MASTRA_REQUEST_CONTEXT_PRESETS%%'`, config.requestContextPresets);\n html = html.replace(`'%%MASTRA_THEME_TOGGLE%%'`, config.themeToggle);\n if (config.autoDetectUrl) {\n html = html.replace(`'%%MASTRA_AUTO_DETECT_URL%%'`, config.autoDetectUrl);\n }\n html = html.replaceAll('%%MASTRA_STUDIO_BASE_PATH%%', config.basePath);\n\n return html;\n}\n\n/**\n * Check if a module is a Node.js builtin module\n * @param specifier - Module specifier\n * @returns True if it's a builtin module\n */\nexport function isBuiltinModule(specifier: string): boolean {\n return (\n builtinModules.includes(specifier) ||\n specifier.startsWith('node:') ||\n builtinModules.includes(specifier.replace(/^node:/, ''))\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/build/utils.ts"],"names":["join","relative","basename","builtinModules"],"mappings":";;;;;;AA0BO,SAAS,sBAAsB,QAAA,EAAqD;AACzF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,EAAwC,MAAA,CAAO,qBAAqB,CAAA;AACxF,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,yBAAA,CAAA,EAA6B,MAAA,CAAO,WAAW,CAAA;AACnE,EAAA,IAAI,OAAO,aAAA,EAAe;AACxB,IAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,4BAAA,CAAA,EAAgC,MAAA,CAAO,aAAa,CAAA;AAAA,EAC1E;AACA,EAAA,IAAA,GAAO,IAAA,CAAK,UAAA,CAAW,6BAAA,EAA+B,MAAA,CAAO,QAAQ,CAAA;AAErE,EAAA,OAAO,IAAA;AACT;AAOO,SAAS,gBAAgB,SAAA,EAA4B;AAC1D,EAAA,OACEC,uBAAA,CAAe,QAAA,CAAS,SAAS,CAAA,IACjC,UAAU,UAAA,CAAW,OAAO,CAAA,IAC5BA,uBAAA,CAAe,QAAA,CAAS,SAAA,CAAU,OAAA,CAAQ,QAAA,EAAU,EAAE,CAAC,CAAA;AAE3D","file":"chunk-Q57SABM6.cjs","sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, mkdirSync } from 'node:fs';\nimport { builtinModules } from 'node:module';\nimport { basename, join, relative } from 'node:path';\nimport type { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';\n\n/** The detected JavaScript runtime environment */\nexport type RuntimePlatform = 'node' | 'bun';\n\n/**\n * The esbuild/bundler platform setting.\n * - 'node': Assumes Node.js environment, externalizes built-in modules\n * - 'browser': Assumes browser environment, polyfills Node APIs\n * - 'neutral': Runtime-agnostic, preserves all globals as-is (used for Bun)\n */\nexport type BundlerPlatform = 'node' | 'browser' | 'neutral';\n\n/**\n * Get nodeResolve plugin options based on the target platform.\n *\n * For 'browser' platform (e.g., Cloudflare Workers), uses browser-compatible\n * export conditions so packages like the Cloudflare SDK resolve to their\n * web runtime instead of Node.js-specific code.\n *\n * For 'node' and 'neutral' (Bun) platforms, uses Node.js module resolution.\n */\nexport function getNodeResolveOptions(platform: BundlerPlatform): RollupNodeResolveOptions {\n if (platform === 'browser') {\n return {\n preferBuiltins: false,\n browser: true,\n exportConditions: ['browser', 'worker', 'default'],\n };\n }\n return {\n preferBuiltins: true,\n exportConditions: ['node'],\n };\n}\n\n/**\n * Detect the current JavaScript runtime environment.\n *\n * This is used by the bundler to determine the appropriate esbuild platform\n * setting. When running under Bun, we need to use 'neutral' platform to\n * preserve Bun-specific globals (like Bun.s3).\n */\nexport function detectRuntime(): RuntimePlatform {\n if (process.versions?.bun) {\n return 'bun';\n }\n return 'node';\n}\n\nexport function upsertMastraDir({ dir = process.cwd() }: { dir?: string }) {\n const dirPath = join(dir, '.mastra');\n\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n execSync(`echo \".mastra\" >> .gitignore`);\n }\n}\n\nexport function isDependencyPartOfPackage(dep: string, packageName: string) {\n if (dep === packageName) {\n return true;\n }\n\n return dep.startsWith(`${packageName}/`);\n}\n\n/**\n * Get the package name from a module ID\n */\nexport function getPackageName(id: string) {\n const parts = id.split('/');\n\n if (id.startsWith('@')) {\n return parts.slice(0, 2).join('/');\n }\n\n return parts[0];\n}\n\n/**\n * During `mastra dev` we are compiling TS files to JS (inside workspaces) so that users can just their workspace packages.\n * We store these compiled files inside `node_modules/.cache` for each workspace package.\n */\nexport function getCompiledDepCachePath(rootPath: string, packageName: string) {\n return slash(join(rootPath, 'node_modules', '.cache', packageName));\n}\n\n/**\n * Convert windows backslashes to posix slashes\n *\n * @example\n * ```ts\n * slash('C:\\\\Users\\\\user\\\\code\\\\mastra') // 'C:/Users/user/code/mastra'\n * ```\n */\nexport function slash(path: string) {\n const isExtendedLengthPath = path.startsWith('\\\\\\\\?\\\\');\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll('\\\\', '/');\n}\n\n/**\n * Make a Rollup-safe name: pathless, POSIX, and without parent/absolute segments\n */\nexport function rollupSafeName(name: string, rootDir: string) {\n const rel = relative(rootDir, name);\n let entry = slash(rel);\n entry = entry.replace(/^(\\.\\.\\/)+/, '');\n entry = entry.replace(/^\\/+/, '');\n entry = entry.replace(/^[A-Za-z]:\\//, '');\n if (!entry) {\n entry = slash(basename(name));\n }\n return entry;\n}\n\n/**\n * Native binding loaders and infrastructure packages that should be ignored when identifying the actual package that requires native bindings\n */\nconst NATIVE_BINDING_LOADERS = [\n 'node-gyp-build',\n 'prebuild-install',\n 'bindings',\n 'node-addon-api',\n 'node-pre-gyp',\n 'nan', // Native Abstractions for Node.js\n] as const;\n\n/**\n * Finds the first real package from node_modules that likely contains native bindings, filtering out virtual modules and native binding loader infrastructure.\n *\n * @param moduleIds - Array of module IDs from a Rollup chunk\n * @returns The module ID of the actual native package, or undefined if not found\n *\n * @example\n * const moduleIds = [\n * '\\x00/path/node_modules/bcrypt/bcrypt.js?commonjs-module',\n * '/path/node_modules/node-gyp-build/index.js',\n * '/path/node_modules/bcrypt/bcrypt.js',\n * ];\n * findNativePackageModule(moduleIds); // Returns '/path/node_modules/bcrypt/bcrypt.js'\n */\nexport function findNativePackageModule(moduleIds: string[]): string | undefined {\n return moduleIds.find(id => {\n // Skip virtual modules (Rollup plugin-generated)\n if (id.startsWith('\\x00')) {\n return false;\n }\n\n // Must be from node_modules\n if (!id.includes('/node_modules/')) {\n return false;\n }\n\n // Skip native binding loader infrastructure\n for (const loader of NATIVE_BINDING_LOADERS) {\n if (id.includes(`/${loader}/`) || id.includes(`/${loader}@`)) {\n return false;\n }\n }\n\n return true;\n });\n}\n\n/**\n * Ensures that server.studioBase is normalized:\n * - Adds leading slash if missing (e.g., 'admin' → '/admin')\n * - Removes trailing slashes (e.g., '/admin/' → '/admin')\n * - Normalizes multiple slashes to single slash (e.g., '//api' → '/api')\n * - Returns empty string for root paths ('/' or '')\n *\n * @param studioBase - The studioBase path to normalize\n * @returns Normalized studioBase path string\n * @throws Error if path contains invalid characters ('..', '?', '#')\n */\nexport function normalizeStudioBase(studioBase: string): string {\n studioBase = studioBase.trim();\n\n // Validate: no path traversal, no query params, no special chars\n if (studioBase.includes('..') || studioBase.includes('?') || studioBase.includes('#')) {\n throw new Error(`Invalid base path: \"${studioBase}\". Base path cannot contain '..', '?', or '#'`);\n }\n\n // Normalize multiple slashes to single slash\n studioBase = studioBase.replace(/\\/+/g, '/');\n\n // Handle default value cases\n if (studioBase === '/' || studioBase === '') {\n return '';\n }\n\n // Remove trailing slash\n if (studioBase.endsWith('/')) {\n studioBase = studioBase.slice(0, -1);\n }\n\n // Add leading slash if missing\n if (!studioBase.startsWith('/')) {\n studioBase = `/${studioBase}`;\n }\n\n return studioBase;\n}\n\n/**\n * Configuration values for Studio's index.html placeholder injection.\n *\n * Each value is the **exact JavaScript expression** that replaces the\n * corresponding `'%%PLACEHOLDER%%'` token (including surrounding quotes).\n *\n * For literal strings pass `\"'value'\"` (quoted).\n * For runtime expressions pass the raw JS, e.g. `\"window.location.hostname\"`.\n */\nexport interface StudioInjectionConfig {\n host: string;\n port: string;\n protocol: string;\n apiPrefix: string;\n basePath: string;\n hideCloudCta: string;\n cloudApiEndpoint: string;\n experimentalFeatures: string;\n templates: string;\n telemetryDisabled: string;\n requestContextPresets: string;\n themeToggle: string;\n autoDetectUrl?: string;\n}\n\n/**\n * Replace all `%%MASTRA_*%%` placeholders in the Studio `index.html` with the\n * supplied configuration values.\n *\n * The `<base href>` tag and the `window.MASTRA_STUDIO_BASE_PATH` assignment\n * use `basePath` as a plain string (no surrounding quotes), while all other\n * placeholders replace `'%%TOKEN%%'` (with surrounding single-quotes in the\n * source HTML) with the provided expression verbatim.\n */\nexport function injectStudioHtmlConfig(html: string, config: StudioInjectionConfig): string {\n html = html.replace(`'%%MASTRA_SERVER_HOST%%'`, config.host);\n html = html.replace(`'%%MASTRA_SERVER_PORT%%'`, config.port);\n html = html.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, config.protocol);\n html = html.replace(`'%%MASTRA_API_PREFIX%%'`, config.apiPrefix);\n html = html.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, config.hideCloudCta);\n html = html.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, config.cloudApiEndpoint);\n html = html.replace(`'%%MASTRA_EXPERIMENTAL_FEATURES%%'`, config.experimentalFeatures);\n html = html.replace(`'%%MASTRA_TEMPLATES%%'`, config.templates);\n html = html.replace(`'%%MASTRA_TELEMETRY_DISABLED%%'`, config.telemetryDisabled);\n html = html.replace(`'%%MASTRA_REQUEST_CONTEXT_PRESETS%%'`, config.requestContextPresets);\n html = html.replace(`'%%MASTRA_THEME_TOGGLE%%'`, config.themeToggle);\n if (config.autoDetectUrl) {\n html = html.replace(`'%%MASTRA_AUTO_DETECT_URL%%'`, config.autoDetectUrl);\n }\n html = html.replaceAll('%%MASTRA_STUDIO_BASE_PATH%%', config.basePath);\n\n return html;\n}\n\n/**\n * Check if a module is a Node.js builtin module\n * @param specifier - Module specifier\n * @returns True if it's a builtin module\n */\nexport function isBuiltinModule(specifier: string): boolean {\n return (\n builtinModules.includes(specifier) ||\n specifier.startsWith('node:') ||\n builtinModules.includes(specifier.replace(/^node:/, ''))\n );\n}\n"]}
|