@mastra/deployer 1.58.0-alpha.12 → 1.58.0-alpha.14

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 @@
1
+ {"version":3,"file":"index.js","names":["createBundlerUtil"],"sources":["../../src/bundler/index.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { readFile, rm, stat, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { MastraBundler } from '@mastra/core/bundler';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport type { Config } from '@mastra/core/mastra';\nimport virtual from '@rollup/plugin-virtual';\nimport * as pkg from 'empathic/package';\nimport fsExtra, { copy, ensureDir, emptyDir, readJSON } from 'fs-extra/esm';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { glob } from 'tinyglobby';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport type { BundlerOptions, ExternalDependencyInfo } from '../build/types';\nimport type { BundlerPlatform } from '../build/utils';\nimport { getPackageName, isBareModuleSpecifier, slash } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport {\n collectTransitiveWorkspaceDependencies,\n getWorkspaceInformation,\n packWorkspaceDependencies,\n} from './workspaceDependencies';\n\nexport type { BundlerOptions, ExternalDependencyInfo } from '../build/types';\nexport type { BundlerPlatform } from '../build/utils';\n\nexport const IS_DEFAULT = Symbol('IS_DEFAULT');\n\nconst NPM_ALIAS_PREFIX = 'npm:';\n/** Characters a registry range or dist tag can contain. Protocols need `:`, git shorthand needs `/` or `#`. */\nconst REGISTRY_SPEC_PATTERN = /^[A-Za-z0-9.+_^~><=*|!\\s-]+$/;\nconst PACKAGE_NAME_PATTERN = /^(?:@[A-Za-z0-9._-]+\\/)?[A-Za-z0-9._-]+$/;\nconst TARBALL_SUFFIX_PATTERN = /\\.(?:tgz|tar\\.gz|tar)$/i;\n/** npm reads a value starting like this as a path, whatever follows. A bare `~` is a semver range. */\nconst FILE_SPEC_PREFIX_PATTERN = /^(?:\\.|~[/\\\\]|[/\\\\]|[A-Za-z]:[/\\\\])/;\n/** A range admitting any published version: `*`, `x`, `>=0`, and any union containing one. */\nconst UNBOUNDED_RANGE_PATTERN = /(?:^|\\|\\||\\s)\\s*(?:[*xX]|>=?\\s*0(?:\\.0)*(?:\\.0)*)\\s*(?:$|\\|\\|)/;\n\n/**\n * Constraints declared by the source app, plus the packages some resolution field pins.\n *\n * Only `dependencies` values are read. Override fields contribute names, never values: which of\n * `overrides`, `resolutions`, `pnpm.overrides` or `pnpm-workspace.yaml` a given install honoured\n * depends on the package manager and its version, so reproducing that precedence would mean\n * emulating three package managers. A name appearing in any of them is enough to know the resolved\n * version was chosen deliberately, which is all this needs.\n */\nexport type SourceDependencyConstraints = {\n dependencies: Record<string, string>;\n pinnedByResolutionField: Set<string>;\n};\n\nconst toStringRecord = (value: unknown): Record<string, string> => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(value).filter((entry): entry is [string, string] => typeof entry[1] === 'string'),\n );\n};\n\n/**\n * True when a specifier is something the isolated install in `.mastra/output` can resolve from the\n * registry: a semver range, a dist tag, a wildcard, or an npm alias whose target is a registry\n * package and range.\n *\n * This is an allowlist rather than a denylist of known protocols, so an unfamiliar protocol is\n * rejected without this code having to know it exists. The output directory is not a workspace, has\n * no catalog definitions and has a different relative-path base, so `catalog:`, `workspace:`,\n * `file:`, `link:` and git specifiers are all either uninstallable there or point somewhere else.\n */\nexport const isRegistryVersionSpec = (spec: string): boolean => {\n if (FILE_SPEC_PREFIX_PATTERN.test(spec) || TARBALL_SUFFIX_PATTERN.test(spec)) {\n return false;\n }\n\n if (spec.startsWith(NPM_ALIAS_PREFIX)) {\n const alias = spec.slice(NPM_ALIAS_PREFIX.length);\n // Skip index 0 so `npm:@scope/pkg` reads as an alias with no range rather than an empty name.\n const rangeSeparator = alias.lastIndexOf('@');\n const name = rangeSeparator > 0 ? alias.slice(0, rangeSeparator) : alias;\n const range = rangeSeparator > 0 ? alias.slice(rangeSeparator + 1) : '*';\n\n return PACKAGE_NAME_PATTERN.test(name) && isRegistryVersionSpec(range);\n }\n\n return REGISTRY_SPEC_PATTERN.test(spec);\n};\n\n/**\n * True when a specifier names a version the output install can be held to.\n *\n * A range admitting anything (`*`, `latest`, `>=0`, an alias with no range) is looser than the\n * version already resolved, so writing it would let a later install pull something the bundle was\n * never analyzed against.\n */\nconst isBoundedVersionSpec = (spec: string): boolean => {\n const range = spec.startsWith(NPM_ALIAS_PREFIX)\n ? (() => {\n const alias = spec.slice(NPM_ALIAS_PREFIX.length);\n const rangeSeparator = alias.lastIndexOf('@');\n return rangeSeparator > 0 ? alias.slice(rangeSeparator + 1) : '';\n })()\n : spec;\n\n return /\\d/.test(range) && !UNBOUNDED_RANGE_PATTERN.test(range);\n};\n\nconst readManifest = async (manifestPath: string | undefined): Promise<Record<string, unknown> | undefined> => {\n if (!manifestPath) {\n return undefined;\n }\n\n try {\n const manifest = await readJSON(manifestPath);\n return manifest && typeof manifest === 'object' ? manifest : undefined;\n } catch {\n // A manifest that cannot be read tells us nothing about intent.\n return undefined;\n }\n};\n\n/** Collect the package names a manifest's resolution fields pin, ignoring their values. */\nconst collectManifestPinnedNames = (manifest: Record<string, unknown> | undefined, pinned: Set<string>) => {\n const pnpmSection = manifest?.pnpm;\n const records = [\n manifest?.overrides,\n manifest?.resolutions,\n pnpmSection && typeof pnpmSection === 'object' ? (pnpmSection as { overrides?: unknown }).overrides : undefined,\n ];\n\n for (const record of records) {\n if (record && typeof record === 'object' && !Array.isArray(record)) {\n for (const key of Object.keys(record)) {\n pinned.add(key);\n }\n }\n }\n};\n\n/**\n * Collect the names under a top-level `overrides:` block in `pnpm-workspace.yaml`.\n *\n * pnpm moved overrides out of `package.json` into this file, so a workspace on a current pnpm keeps\n * them only here. Reading names off the indented block avoids a YAML dependency, the same tradeoff\n * `copyPnpmWorkspaceSettings` already makes for the top-level keys it copies.\n */\nconst collectPnpmWorkspacePinnedNames = (source: string, pinned: Set<string>) => {\n const lines = source.split(/\\r?\\n/);\n let insideOverrides = false;\n\n for (const line of lines) {\n if (/^\\S/.test(line)) {\n insideOverrides = /^overrides:\\s*$/.test(line);\n continue;\n }\n\n if (!insideOverrides) {\n continue;\n }\n\n const key = /^\\s+(?:'([^']+)'|\"([^\"]+)\"|([^'\"\\s:][^:]*?))\\s*:/.exec(line);\n if (key) {\n pinned.add((key[1] ?? key[2] ?? key[3] ?? '').trim());\n }\n }\n};\n\n/**\n * Read the constraints the source app declared.\n *\n * `dependencies` come from the manifest at `projectRoot`, the package the build was invoked for and\n * whose directory receives the output, falling back to the manifest above the entry file. Anchoring\n * on `projectRoot` rather than the entry file keeps the answer deterministic when the entry handed\n * to the bundler is a generated wrapper rather than the app's own source file.\n *\n * Resolution-field names are collected from both that manifest and the workspace root, including the\n * root `pnpm-workspace.yaml`, because a name pinned anywhere means the resolved version may have been\n * chosen deliberately rather than hoisted by accident.\n */\nexport const getSourceDependencyConstraints = async ({\n projectRoot,\n mastraEntryFile,\n workspaceRoot,\n}: {\n projectRoot: string;\n mastraEntryFile: string;\n workspaceRoot?: string;\n}): Promise<SourceDependencyConstraints> => {\n const manifestPaths = [pkg.up({ cwd: projectRoot }), pkg.up({ cwd: dirname(mastraEntryFile) })].filter(\n (entry, index, entries): entry is string => !!entry && entries.indexOf(entry) === index,\n );\n\n if (workspaceRoot) {\n manifestPaths.push(join(workspaceRoot, 'package.json'));\n }\n\n const pinnedByResolutionField = new Set<string>();\n let dependencies: Record<string, string> | undefined;\n\n for (const manifestPath of manifestPaths) {\n const manifest = await readManifest(manifestPath);\n if (!manifest) {\n continue;\n }\n\n // Nearest manifest wins, and an empty `dependencies` record is still that package's answer.\n dependencies ??= toStringRecord(manifest.dependencies);\n collectManifestPinnedNames(manifest, pinnedByResolutionField);\n }\n\n if (workspaceRoot) {\n try {\n collectPnpmWorkspacePinnedNames(\n await readFile(join(workspaceRoot, 'pnpm-workspace.yaml'), 'utf-8'),\n pinnedByResolutionField,\n );\n } catch {\n // No pnpm workspace config, or unreadable: nothing to learn from it.\n }\n }\n\n return { dependencies: dependencies ?? {}, pinnedByResolutionField };\n};\n\nconst findDeclaredConstraint = (\n constraints: SourceDependencyConstraints,\n dependencyName: string,\n): string | undefined => {\n const names = [dependencyName, getPackageName(dependencyName)].filter(\n (name, index, all): name is string => !!name && all.indexOf(name) === index,\n );\n\n for (const name of names) {\n // A pinned package's resolved version is the deliberate answer, so leave it as `main` wrote it.\n if (constraints.pinnedByResolutionField.has(name)) {\n return undefined;\n }\n }\n\n for (const name of names) {\n const declared = (constraints.dependencies[name] ?? '').trim();\n if (declared && isBoundedVersionSpec(declared) && isRegistryVersionSpec(declared)) {\n return declared;\n }\n }\n\n return undefined;\n};\n\n/**\n * Prefer the constraint the app declared over the version resolved from `node_modules`.\n *\n * The resolved version is whatever the install happened to hoist, so an app declaring `zod: ^4.3.6`\n * next to a hoisted `zod@3.25.76` gets the hoisted version written into the output manifest and the\n * isolated install then locks it in.\n */\nexport const applySourceDependencyRange = (\n dependencyName: string,\n dependencyInfo: ExternalDependencyInfo,\n constraints: SourceDependencyConstraints,\n): ExternalDependencyInfo => {\n const declared = findDeclaredConstraint(constraints, dependencyName);\n if (!declared) {\n return dependencyInfo;\n }\n\n if (declared.startsWith(NPM_ALIAS_PREFIX)) {\n return { ...dependencyInfo, packageSpec: declared };\n }\n\n // `packageSpec` is set only when the resolved package's own name differs from the requested one, so\n // a bare range under this key describes a different package and the resolved alias is the answer.\n if (dependencyInfo.packageSpec) {\n return dependencyInfo;\n }\n\n return { ...dependencyInfo, version: declared };\n};\n\nexport abstract class Bundler extends MastraBundler {\n protected analyzeOutputDir = '.build';\n protected outputDir = 'output';\n protected platform: BundlerPlatform = 'node';\n\n constructor(name: string, component: 'BUNDLER' | 'DEPLOYER' = 'BUNDLER') {\n super({ name, component });\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n // Clean up the output directory first\n await emptyDir(outputDirectory);\n\n await ensureDir(join(outputDirectory, this.analyzeOutputDir));\n await ensureDir(join(outputDirectory, this.outputDir));\n }\n\n async writePackageJson(\n outputDirectory: string,\n dependencies: Map<string, string | ExternalDependencyInfo>,\n resolutions?: Record<string, string>,\n ) {\n this.logger.debug(\"Writing project's package.json\");\n\n await ensureDir(outputDirectory);\n const pkgPath = join(outputDirectory, 'package.json');\n\n const dependenciesMap = new Map();\n for (const [key, value] of dependencies.entries()) {\n const dependencyValue = typeof value === 'string' ? value : (value.packageSpec ?? value.version ?? 'latest');\n if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);\n } else {\n // For non-scoped packages, take only the first part before any slash\n const pkgName = key.split('/')[0] || key;\n dependenciesMap.set(pkgName, dependencyValue);\n }\n }\n\n await writeFile(\n pkgPath,\n JSON.stringify(\n {\n name: 'server',\n version: '1.0.0',\n private: true,\n type: 'module',\n main: 'index.mjs',\n scripts: {\n start: 'node ./index.mjs',\n },\n dependencies: Object.fromEntries(dependenciesMap.entries()),\n ...(Object.keys(resolutions ?? {}).length > 0 && { resolutions }),\n },\n null,\n 2,\n ),\n );\n }\n\n protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & { dir: string }) {\n return createBundlerUtil(inputOptions, outputOptions);\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const defaultBundlerOptions: Config['bundler'] = {\n externals: [],\n sourcemap: false,\n transpilePackages: [],\n [IS_DEFAULT]: true,\n } as const;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, outputDirectory);\n\n return bundlerOptions ?? defaultBundlerOptions;\n } catch (error) {\n this.logger.debug('Failed to get bundler options, sourcemap will be disabled', { error });\n }\n\n return defaultBundlerOptions;\n }\n\n protected async analyze(entry: string | string[], mastraFile: string, outputDirectory: string) {\n return await analyzeBundle(\n ([] as string[]).concat(entry),\n mastraFile,\n {\n outputDir: join(outputDirectory, this.analyzeOutputDir),\n projectRoot: outputDirectory,\n platform: this.platform,\n },\n this.logger,\n );\n }\n\n protected pnpmNodeLinker?: 'hoisted';\n\n protected async installDependencies(\n outputDirectory: string,\n rootDir = process.cwd(),\n pnpmOverrides?: Record<string, string>,\n ) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n pnpmOverrides,\n pnpmNodeLinker: this.pnpmNodeLinker,\n });\n }\n\n /**\n * Generate a package-lock.json for the output directory so that deploy targets\n * can use `npm ci` instead of `npm install`, skipping version resolution entirely.\n * This is a lockfile-only operation — no packages are downloaded.\n *\n * Temporarily moves node_modules out of the way because pnpm's symlink-based\n * layout confuses npm's arborist, then restores it afterwards so that\n * `mastra start` (or wrangler) can still resolve dependencies at runtime.\n */\n private async generateNpmLockfile(outputDir: string): Promise<void> {\n const nodeModules = join(outputDir, 'node_modules');\n const nodeModulesTmp = join(outputDir, 'node_modules.__tmp');\n let movedNodeModules = false;\n try {\n // Move node_modules aside — pnpm's symlink layout confuses npm's arborist\n if (await fsExtra.pathExists(nodeModules)) {\n await fsExtra.move(nodeModules, nodeModulesTmp, { overwrite: true });\n movedNodeModules = true;\n }\n execSync('npm install --package-lock-only --force', {\n cwd: outputDir,\n stdio: 'pipe',\n timeout: 60_000,\n });\n } catch {\n this.logger.warn('Failed to generate package-lock.json — deploy will fall back to npm install');\n } finally {\n // Restore node_modules so runtime resolution works\n if (movedNodeModules) {\n await rm(nodeModules, { recursive: true, force: true });\n await fsExtra.move(nodeModulesTmp, nodeModules, { overwrite: true });\n }\n }\n }\n\n protected async copyPublic(mastraDir: string, outputDirectory: string) {\n const publicDir = join(mastraDir, 'public');\n\n try {\n await stat(publicDir);\n } catch {\n return;\n }\n\n await copy(publicDir, join(outputDirectory, this.outputDir));\n }\n\n protected async copyDOTNPMRC({\n rootDir = process.cwd(),\n outputDirectory,\n }: {\n rootDir?: string;\n outputDirectory: string;\n }) {\n const sourceDotNpmRcPath = join(rootDir, '.npmrc');\n const targetDotNpmRcPath = join(outputDirectory, this.outputDir, '.npmrc');\n\n try {\n await stat(sourceDotNpmRcPath);\n await copy(sourceDotNpmRcPath, targetDotNpmRcPath);\n } catch {\n return;\n }\n }\n\n /**\n * Writes the `mastra-project.json` deployment marker for Software Factory\n * projects after public assets have been copied. Verifies that the Factory\n * SPA (`factory/index.html`) exists in the output before emitting the marker.\n */\n protected async writeFactoryMarker(outputDirectory: string): Promise<void> {\n const outputDir = join(outputDirectory, this.outputDir);\n const factoryIndex = join(outputDir, 'factory', 'index.html');\n if (!existsSync(factoryIndex)) {\n throw new MastraError({\n id: 'DEPLOYER_BUNDLER_FACTORY_UI_MISSING',\n text: 'Software Factory project detected but factory/index.html was not found after copying the prebuilt Factory UI.',\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n });\n }\n await writeFile(\n join(outputDir, 'mastra-project.json'),\n JSON.stringify({ schemaVersion: 1, projectType: 'factory', assets: { ui: 'factory' } }, null, 2),\n );\n this.logger.info('Wrote mastra-project.json for Software Factory project');\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n { enableSourcemap, enableMinify, enableEsmShim, externals }: BundlerOptions,\n ) {\n const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });\n const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });\n const projectRoot = closestPkgJson ? dirname(closestPkgJson) : process.cwd();\n\n const inputOptions: InputOptions = await getInputOptions(\n mastraEntryFile,\n analyzedBundleInfo,\n this.platform,\n {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n },\n {\n sourcemap: enableSourcemap,\n minify: enableMinify,\n workspaceRoot,\n projectRoot,\n enableEsmShim,\n externalsPreset: externals === true,\n },\n );\n const isVirtual = serverFile.includes('\\n') || !existsSync(serverFile);\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n\n if (isVirtual) {\n inputOptions.input = { index: '#entry', ...toolsInputOptions };\n\n if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.unshift(virtual({ '#entry': serverFile }));\n } else {\n inputOptions.plugins = [virtual({ '#entry': serverFile })];\n }\n } else {\n inputOptions.input = { index: serverFile, ...toolsInputOptions };\n }\n\n return inputOptions;\n }\n\n getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[] = []): (string | string[])[] {\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedMastraDir = slash(mastraDir);\n\n // Prepare default tools paths with glob patterns\n const defaultToolsPath = posix.join(normalizedMastraDir, 'tools/**/*.{js,ts}');\n const defaultToolsIgnorePaths = [\n `!${posix.join(normalizedMastraDir, 'tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'tools/**/__tests__/**')}`,\n ];\n\n // Combine default path with ignore patterns\n const defaultPaths = [defaultToolsPath, ...defaultToolsIgnorePaths];\n\n // If no tools paths provided, use only the default paths\n if (toolsPaths.length === 0) {\n return [defaultPaths];\n }\n\n // If tools paths are provided, add the default paths to ensure standard tools are always included\n return [...toolsPaths, defaultPaths];\n }\n\n async listToolsInputOptions(toolsPaths: (string | string[])[]) {\n const inputs: Record<string, string> = {};\n\n for (const toolPath of toolsPaths) {\n const expandedPaths = await glob(toolPath, {\n absolute: true,\n expandDirectories: false,\n });\n\n for (const path of expandedPaths) {\n if (await fsExtra.pathExists(path)) {\n const fileService = new FileService();\n const entryFile = fileService.getFirstExistingFile([\n join(path, 'index.ts'),\n join(path, 'index.js'),\n path, // if path itself is a file\n ]);\n\n // if it doesn't exist or is a dir skip it. using a dir as a tool will crash the process\n if (!entryFile || (await stat(entryFile)).isDirectory()) {\n this.logger.warn('No entry file found, skipping', { path });\n continue;\n }\n\n const uniqueToolID = crypto.randomUUID();\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;\n } else {\n this.logger.warn('Tool path does not exist, skipping', { path });\n }\n }\n }\n\n return inputs;\n }\n\n protected async _bundle(\n serverFile: string,\n mastraEntryFile: string,\n {\n projectRoot,\n outputDirectory,\n enableEsmShim = true,\n }: {\n projectRoot: string;\n outputDirectory: string;\n enableEsmShim?: boolean;\n },\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n const analyzeDir = join(outputDirectory, this.analyzeOutputDir);\n\n const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n const internalBundlerOptions: BundlerOptions = {\n enableSourcemap: !!bundlerOptions.sourcemap,\n enableMinify: !!bundlerOptions.minify,\n externals: bundlerOptions.externals ?? [],\n enableEsmShim,\n dynamicPackages: bundlerOptions.dynamicPackages,\n };\n\n let analyzedBundleInfo;\n try {\n const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n {\n outputDir: analyzeDir,\n projectRoot,\n platform: this.platform,\n bundlerOptions: internalBundlerOptions,\n },\n this.logger,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n if (error instanceof MastraError) {\n throw error;\n }\n\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_ANALYZE_FAILED',\n text: `Failed to analyze Mastra application: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n const { workspaceRoot } = await getWorkspaceInformation({ dir: projectRoot, mastraEntryFile });\n const sourceDependencyConstraints = await getSourceDependencyConstraints({\n projectRoot,\n mastraEntryFile,\n workspaceRoot,\n });\n const dependenciesToInstall = new Map<string, ExternalDependencyInfo>();\n for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {\n if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) {\n continue;\n }\n\n dependenciesToInstall.set(dep, applySourceDependencyRange(dep, depInfo, sourceDependencyConstraints));\n }\n\n const initialWorkspaceDependencies = new Set<string>();\n for (const dep of analyzedBundleInfo.dependencies.keys()) {\n const pkgName = getPackageName(dep);\n if (pkgName && analyzedBundleInfo.workspaceMap.has(pkgName)) {\n initialWorkspaceDependencies.add(pkgName);\n }\n }\n\n const transitiveWorkspaceDependencies = collectTransitiveWorkspaceDependencies({\n workspaceMap: analyzedBundleInfo.workspaceMap,\n initialDependencies: initialWorkspaceDependencies,\n logger: this.logger,\n });\n\n for (const [dep, packageSpec] of Object.entries(transitiveWorkspaceDependencies.resolutions)) {\n dependenciesToInstall.set(dep, {\n version: analyzedBundleInfo.workspaceMap.get(dep)?.version,\n packageSpec,\n });\n }\n\n try {\n await this.writePackageJson(\n join(outputDirectory, this.outputDir),\n dependenciesToInstall,\n transitiveWorkspaceDependencies.resolutions,\n );\n if (transitiveWorkspaceDependencies.usedWorkspacePackages.size > 0) {\n await packWorkspaceDependencies({\n workspaceMap: analyzedBundleInfo.workspaceMap,\n usedWorkspacePackages: transitiveWorkspaceDependencies.usedWorkspacePackages,\n bundleOutputDir: join(outputDirectory, this.outputDir),\n logger: this.logger,\n });\n }\n\n this.logger.info('Bundling Mastra application');\n\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n internalBundlerOptions,\n );\n\n const bundler = await this.createBundler(\n {\n ...inputOptions,\n logLevel: inputOptions.logLevel === 'silent' ? 'warn' : inputOptions.logLevel,\n onwarn: warning => {\n if (warning.code === 'CIRCULAR_DEPENDENCY') {\n if (warning.ids?.[0]?.includes('node_modules')) {\n return;\n }\n\n this.logger.warn('Circular dependency found', {\n dependency: warning.message.replace('Circular dependency: ', ''),\n });\n }\n },\n },\n {\n dir: bundleLocation,\n manualChunks: {\n mastra: ['#mastra'],\n },\n sourcemap: internalBundlerOptions.enableSourcemap,\n },\n );\n\n await bundler.write();\n const toolImports: string[] = [];\n const toolsExports: string[] = [];\n Array.from(Object.keys(inputOptions.input || {}))\n .filter(key => key.startsWith('tools/'))\n .forEach((key, index) => {\n const toolExport = `tool${index}`;\n toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);\n toolsExports.push(toolExport);\n });\n\n await writeFile(\n join(bundleLocation, 'tools.mjs'),\n `${toolImports.join('\\n')}\n\nexport const tools = [${toolsExports.join(', ')}]`,\n );\n this.logger.info('Bundling Mastra done');\n\n this.logger.info('Copying public files');\n await this.copyPublic(dirname(mastraEntryFile), outputDirectory);\n this.logger.info('Done copying public files');\n\n // For Software Factory projects, write a deterministic deployment marker\n // after public assets (including the SPA) have been copied.\n if (analyzedBundleInfo.projectType === 'factory') {\n await this.writeFactoryMarker(outputDirectory);\n }\n\n this.logger.info('Copying .npmrc file');\n await this.copyDOTNPMRC({ outputDirectory, rootDir: projectRoot });\n\n this.logger.info('Done copying .npmrc file');\n\n this.logger.info('Installing dependencies');\n await this.installDependencies(outputDirectory, projectRoot, transitiveWorkspaceDependencies.resolutions);\n this.logger.info('Done installing dependencies');\n\n if (Object.keys(transitiveWorkspaceDependencies.resolutions).length === 0) {\n this.logger.info('Generating package-lock.json for deploy');\n await this.generateNpmLockfile(join(outputDirectory, this.outputDir));\n this.logger.info('Done generating package-lock.json');\n } else {\n this.logger.warn(\n 'Skipping package-lock.json generation because the output contains packed workspace dependencies',\n );\n }\n } catch (error) {\n if (error instanceof MastraError && error.id === 'DEPLOYER_BUNDLER_FACTORY_UI_MISSING') {\n throw error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED',\n text: `Failed during bundler bundle stage: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n }\n\n async lint(_entryFile: string, _outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n const toolsLength = Object.keys(toolsInputOptions).length;\n if (toolsLength > 0) {\n this.logger.info('Found tools', { count: toolsLength });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAa,aAAa,OAAO,YAAY;AAE7C,MAAM,mBAAmB;;AAEzB,MAAM,wBAAwB;AAC9B,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;;AAE/B,MAAM,2BAA2B;;AAEjC,MAAM,0BAA0B;AAgBhC,MAAM,kBAAkB,UAA2C;CACjE,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAC5D,OAAO,CAAC;CAGV,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,UAAqC,OAAO,MAAM,OAAO,QAAQ,CACjG;AACF;;;;;;;;;;;AAYA,MAAa,yBAAyB,SAA0B;CAC9D,IAAI,yBAAyB,KAAK,IAAI,KAAK,uBAAuB,KAAK,IAAI,GACzE,OAAO;CAGT,IAAI,KAAK,WAAW,gBAAgB,GAAG;EACrC,MAAM,QAAQ,KAAK,MAAM,CAAuB;EAEhD,MAAM,iBAAiB,MAAM,YAAY,GAAG;EAC5C,MAAM,OAAO,iBAAiB,IAAI,MAAM,MAAM,GAAG,cAAc,IAAI;EACnE,MAAM,QAAQ,iBAAiB,IAAI,MAAM,MAAM,iBAAiB,CAAC,IAAI;EAErE,OAAO,qBAAqB,KAAK,IAAI,KAAK,sBAAsB,KAAK;CACvE;CAEA,OAAO,sBAAsB,KAAK,IAAI;AACxC;;;;;;;;AASA,MAAM,wBAAwB,SAA0B;CACtD,MAAM,QAAQ,K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K,OAAO,KAAK,mCAAmC;GACtD,OACE,KAAK,OAAO,KACV,iGACF;EAEJ,SAAS,OAAO;GACd,IAAI,iBAAiB,eAAe,MAAM,OAAO,uCAC/C,MAAM;GAIR,MAAM,IAAI,YACR;IACE,IAAI;IACJ,MAAM,uCAJM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAKjE,QAAQ,YAAY;IACpB,UAAU,cAAc;GAC1B,GACA,KACF;EACF;CACF;CAEA,MAAM,KAAK,YAAoB,kBAA0B,YAAkD;EACzG,MAAM,oBAAoB,MAAM,KAAK,sBAAsB,UAAU;EACrE,MAAM,cAAc,OAAO,KAAK,iBAAiB,CAAC,CAAC;EACnD,IAAI,cAAc,GAChB,KAAK,OAAO,KAAK,eAAe,EAAE,OAAO,YAAY,CAAC;CAE1D;AACF"}
@@ -3,7 +3,7 @@ name: mastra-deployer
3
3
  description: Documentation for @mastra/deployer. Use when working with @mastra/deployer APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/deployer"
6
- version: "1.58.0-alpha.12"
6
+ version: "1.58.0-alpha.14"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.58.0-alpha.12",
2
+ "version": "1.58.0-alpha.14",
3
3
  "package": "@mastra/deployer",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -12,12 +12,12 @@ Mastra provides a platform to deploy your server to the cloud. Read the [Mastra
12
12
 
13
13
  The following guides show how to deploy Mastra to specific cloud providers:
14
14
 
15
- - [Amazon Bedrock AgentCore](https://mastra.ai/guides/deployment/aws-bedrock-agentcore)
16
- - [Amazon EC2](https://mastra.ai/guides/deployment/amazon-ec2)
17
- - [AWS Lambda](https://mastra.ai/guides/deployment/aws-lambda)
18
- - [Azure App Services](https://mastra.ai/guides/deployment/azure-app-services)
19
- - [Cloudflare](https://mastra.ai/guides/deployment/cloudflare)
20
- - [Digital Ocean](https://mastra.ai/guides/deployment/digital-ocean)
21
- - [Kubernetes](https://mastra.ai/guides/deployment/kubernetes)
22
- - [Netlify](https://mastra.ai/guides/deployment/netlify)
23
- - [Vercel](https://mastra.ai/guides/deployment/vercel)
15
+ - [Amazon Bedrock AgentCore](https://mastra.ai/integrations/deploy/aws-bedrock-agentcore)
16
+ - [Amazon EC2](https://mastra.ai/integrations/deploy/amazon-ec2)
17
+ - [AWS Lambda](https://mastra.ai/integrations/deploy/aws-lambda)
18
+ - [Azure App Services](https://mastra.ai/integrations/deploy/azure-app-services)
19
+ - [Cloudflare](https://mastra.ai/integrations/deploy/cloudflare)
20
+ - [Digital Ocean](https://mastra.ai/integrations/deploy/digital-ocean)
21
+ - [Kubernetes](https://mastra.ai/integrations/deploy/kubernetes)
22
+ - [Netlify](https://mastra.ai/integrations/deploy/netlify)
23
+ - [Vercel](https://mastra.ai/integrations/deploy/vercel)
@@ -43,14 +43,14 @@ Mastra applications can be deployed to cloud providers and serverless platforms.
43
43
 
44
44
  Use this option for auto-scaling, minimal infrastructure management, or when you're already using one of these platforms.
45
45
 
46
- - [Amazon EC2](https://mastra.ai/guides/deployment/amazon-ec2)
47
- - [AWS Lambda](https://mastra.ai/guides/deployment/aws-lambda)
48
- - [Azure App Services](https://mastra.ai/guides/deployment/azure-app-services)
49
- - [Cloudflare](https://mastra.ai/guides/deployment/cloudflare)
50
- - [Digital Ocean](https://mastra.ai/guides/deployment/digital-ocean)
51
- - [Kubernetes](https://mastra.ai/guides/deployment/kubernetes)
52
- - [Netlify](https://mastra.ai/guides/deployment/netlify)
53
- - [Vercel](https://mastra.ai/guides/deployment/vercel)
46
+ - [Amazon EC2](https://mastra.ai/integrations/deploy/amazon-ec2)
47
+ - [AWS Lambda](https://mastra.ai/integrations/deploy/aws-lambda)
48
+ - [Azure App Services](https://mastra.ai/integrations/deploy/azure-app-services)
49
+ - [Cloudflare](https://mastra.ai/integrations/deploy/cloudflare)
50
+ - [Digital Ocean](https://mastra.ai/integrations/deploy/digital-ocean)
51
+ - [Kubernetes](https://mastra.ai/integrations/deploy/kubernetes)
52
+ - [Netlify](https://mastra.ai/integrations/deploy/netlify)
53
+ - [Vercel](https://mastra.ai/integrations/deploy/vercel)
54
54
 
55
55
  ### Sandbox
56
56
 
@@ -72,7 +72,7 @@ Use these guides when adding Mastra to an existing Next.js or Astro application.
72
72
 
73
73
  Mastra workflows run using the built-in execution engine by default. For production workloads requiring managed infrastructure, workflows can also be deployed to specialized platforms like [Inngest](https://www.inngest.com) that provide step memoization, automatic retries, and real-time monitoring.
74
74
 
75
- Visit the [Workflow Runners guide](https://mastra.ai/docs/deployment/workflow-runners) for execution options and the [Inngest deployment guide](https://mastra.ai/guides/deployment/inngest) for setup instructions.
75
+ Visit the [Workflow Runners guide](https://mastra.ai/docs/deployment/workflow-runners) for execution options and the [Inngest deployment guide](https://mastra.ai/integrations/deploy/inngest) for setup instructions.
76
76
 
77
77
  ## Workers
78
78
 
@@ -4,16 +4,16 @@
4
4
 
5
5
  When Mastra is integrated with a web framework, it deploys alongside your application using the framework's standard deployment process. Follow the instructions below to ensure your Mastra integration deploys correctly.
6
6
 
7
- > **Warning:** If you're deploying to a cloud provider, remove any usage of [LibSQLStore](https://mastra.ai/reference/storage/libsql) from your Mastra configuration. LibSQLStore requires filesystem access and isn't compatible with serverless platforms.
7
+ > **Warning:** If you're deploying to a cloud provider, remove any usage of [LibSQLStore](https://mastra.ai/integrations/databases/libsql) from your Mastra configuration. LibSQLStore requires filesystem access and isn't compatible with serverless platforms.
8
8
 
9
9
  Integration guides:
10
10
 
11
- - [With Next.js](https://mastra.ai/guides/getting-started/next-js)
12
- - [With Astro](https://mastra.ai/guides/getting-started/astro)
11
+ - [With Next.js](https://mastra.ai/integrations/frameworks/next-js)
12
+ - [With Astro](https://mastra.ai/integrations/frameworks/astro)
13
13
 
14
14
  ## With Next.js on Vercel
15
15
 
16
- If you've integrated Mastra with Next.js [by following our guide](https://mastra.ai/guides/getting-started/next-js) and plan to deploy to Vercel, add `serverExternalPackages: ["@mastra/*"]` to your `next.config.ts`:
16
+ If you've integrated Mastra with Next.js [by following our guide](https://mastra.ai/integrations/frameworks/next-js) and plan to deploy to Vercel, add `serverExternalPackages: ["@mastra/*"]` to your `next.config.ts`:
17
17
 
18
18
  ```typescript
19
19
  import type { NextConfig } from 'next'
@@ -27,7 +27,7 @@ export default nextConfig
27
27
 
28
28
  ## With Astro on Vercel
29
29
 
30
- If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/guides/getting-started/astro) and plan to deploy to Vercel, add the Vercel adapter and server output to your `astro.config.mjs`:
30
+ If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/integrations/frameworks/astro) and plan to deploy to Vercel, add the Vercel adapter and server output to your `astro.config.mjs`:
31
31
 
32
32
  ```javascript
33
33
  import { defineConfig } from 'astro/config'
@@ -41,7 +41,7 @@ export default defineConfig({
41
41
 
42
42
  ## With Astro on Netlify
43
43
 
44
- If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/guides/getting-started/astro) and plan to deploy to Netlify, add the Netlify adapter and server output to your `astro.config.mjs`:
44
+ If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/integrations/frameworks/astro) and plan to deploy to Netlify, add the Netlify adapter and server output to your `astro.config.mjs`:
45
45
 
46
46
  ```javascript
47
47
  import { defineConfig } from 'astro/config'
@@ -8,10 +8,10 @@ Mastra [workflows](https://mastra.ai/docs/workflows/overview) can be executed us
8
8
 
9
9
  Inngest is a developer platform for running background workflows without managing infrastructure. Mastra workflows can be deployed to Inngest, which provides step memoization, automatic retries, real-time monitoring, and suspend/resume capabilities.
10
10
 
11
- Visit the [Inngest deployment guide](https://mastra.ai/guides/deployment/inngest) for setup instructions and the [Inngest workflow example](https://github.com/mastra-ai/mastra/tree/main/examples/inngest) for a complete implementation.
11
+ Visit the [Inngest deployment guide](https://mastra.ai/integrations/deploy/inngest) for setup instructions and the [Inngest workflow example](https://github.com/mastra-ai/mastra/tree/main/examples/inngest) for a complete implementation.
12
12
 
13
13
  ## Temporal
14
14
 
15
15
  Temporal is a durable execution platform for orchestrating long-running workflows. Mastra workflows can run on Temporal workers, with each `createStep` mapped to a Temporal activity for automatic retries and durable state.
16
16
 
17
- The `@mastra/temporal` package is experimental and not ready for production use. Visit the [Temporal deployment guide](https://mastra.ai/guides/deployment/temporal) for setup instructions.
17
+ The `@mastra/temporal` package is experimental and not ready for production use. Visit the [Temporal deployment guide](https://mastra.ai/integrations/deploy/temporal) for setup instructions.
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_services = require("./services-_ksvysL5.cjs");
3
3
  const require_bundlerOptions = require("./bundlerOptions-CjjAPZYp.cjs");
4
- const require_bundler = require("./bundler-DLXwkS7b.cjs");
4
+ const require_bundler_index = require("./bundler/index.cjs");
5
5
  require("./build-BERX35Pi.cjs");
6
6
  //#region src/deploy/base.ts
7
- var Deployer = class extends require_bundler.Bundler {
7
+ var Deployer = class extends require_bundler_index.Bundler {
8
8
  deps = new require_services.DepsService();
9
9
  constructor(args) {
10
10
  super(args.name, "DEPLOYER");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Bundler","DepsService","FileService","extractMastraOption"],"sources":["../src/deploy/base.ts","../src/build/deployer.ts"],"sourcesContent":["import type { IDeployer } from '@mastra/core/deployer';\n\nimport { Bundler } from '../bundler';\nimport { DepsService } from '../services/deps.js';\nimport { FileService } from '../services/fs.js';\n\nexport abstract class Deployer extends Bundler implements IDeployer {\n deps: DepsService = new DepsService();\n\n constructor(args: { name: string }) {\n super(args.name, 'DEPLOYER');\n\n this.deps.__setLogger(this.logger);\n }\n\n getEnvFiles(): Promise<string[]> {\n const possibleFiles = ['.env.production', '.env.local', '.env'];\n\n try {\n const fileService = new FileService();\n const envFile = fileService.getFirstExistingFile(possibleFiles);\n\n return Promise.resolve([envFile]);\n } catch {}\n\n return Promise.resolve([]);\n }\n\n abstract deploy(outputDirectory: string): Promise<void>;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getDeployerBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('deployer', entryFile, result);\n}\n\nexport async function getDeployer(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['deployer'] | null> {\n const result = await extractMastraOption('deployer', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;AAMA,IAAsB,WAAtB,cAAuCA,gBAAAA,QAA6B;CAClE,OAAoB,IAAIC,iBAAAA,YAAY;CAEpC,YAAY,MAAwB;EAClC,MAAM,KAAK,MAAM,UAAU;EAE3B,KAAK,KAAK,YAAY,KAAK,MAAM;CACnC;CAEA,cAAiC;EAC/B,MAAM,gBAAgB;GAAC;GAAmB;GAAc;EAAM;EAE9D,IAAI;GAEF,MAAM,UAAU,IADQC,iBAAAA,YACE,CAAC,CAAC,qBAAqB,aAAa;GAE9D,OAAO,QAAQ,QAAQ,CAAC,OAAO,CAAC;EAClC,QAAQ,CAAC;EAET,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;AAGF;;;AChBA,eAAsB,YACpB,WACA,WACA,QACoC;CACpC,MAAM,SAAS,MAAMC,uBAAAA,oBAAoB,YAAY,WAAW,WAAW,MAAM;CACjF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
1
+ {"version":3,"file":"index.cjs","names":["Bundler","DepsService","FileService","extractMastraOption"],"sources":["../src/deploy/base.ts","../src/build/deployer.ts"],"sourcesContent":["import type { IDeployer } from '@mastra/core/deployer';\n\nimport { Bundler } from '../bundler';\nimport { DepsService } from '../services/deps.js';\nimport { FileService } from '../services/fs.js';\n\nexport abstract class Deployer extends Bundler implements IDeployer {\n deps: DepsService = new DepsService();\n\n constructor(args: { name: string }) {\n super(args.name, 'DEPLOYER');\n\n this.deps.__setLogger(this.logger);\n }\n\n getEnvFiles(): Promise<string[]> {\n const possibleFiles = ['.env.production', '.env.local', '.env'];\n\n try {\n const fileService = new FileService();\n const envFile = fileService.getFirstExistingFile(possibleFiles);\n\n return Promise.resolve([envFile]);\n } catch {}\n\n return Promise.resolve([]);\n }\n\n abstract deploy(outputDirectory: string): Promise<void>;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getDeployerBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('deployer', entryFile, result);\n}\n\nexport async function getDeployer(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['deployer'] | null> {\n const result = await extractMastraOption('deployer', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;AAMA,IAAsB,WAAtB,cAAuCA,sBAAAA,QAA6B;CAClE,OAAoB,IAAIC,iBAAAA,YAAY;CAEpC,YAAY,MAAwB;EAClC,MAAM,KAAK,MAAM,UAAU;EAE3B,KAAK,KAAK,YAAY,KAAK,MAAM;CACnC;CAEA,cAAiC;EAC/B,MAAM,gBAAgB;GAAC;GAAmB;GAAc;EAAM;EAE9D,IAAI;GAEF,MAAM,UAAU,IADQC,iBAAAA,YACE,CAAC,CAAC,qBAAqB,aAAa;GAE9D,OAAO,QAAQ,QAAQ,CAAC,OAAO,CAAC;EAClC,QAAQ,CAAC;EAET,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;AAGF;;;AChBA,eAAsB,YACpB,WACA,WACA,QACoC;CACpC,MAAM,SAAS,MAAMC,uBAAAA,oBAAoB,YAAY,WAAW,WAAW,MAAM;CACjF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as createChildProcessLogger, i as DepsService, o as createPinoStream, r as Deps, t as FileService } from "./services-BRF1RRXB.js";
2
2
  import { n as extractMastraOption } from "./bundlerOptions-NMtZPD7p.js";
3
- import { t as Bundler } from "./bundler-Ct1ToG6x.js";
3
+ import { Bundler } from "./bundler/index.js";
4
4
  import "./build-kZfvpuh9.js";
5
5
  //#region src/deploy/base.ts
6
6
  var Deployer = class extends Bundler {
@@ -3555,8 +3555,8 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
3555
3555
  });
3556
3556
  }
3557
3557
  async registerCustomApiRoutes() {
3558
- if (!await this.buildCustomRouteHandler()) return;
3559
- const routes = this.customApiRoutes ?? this.mastra.getServer()?.apiRoutes ?? [];
3558
+ const routes = await this.registerSchemaApiRoutes();
3559
+ if (!await this.buildCustomRouteHandler(routes)) return;
3560
3560
  for (const route of routes) {
3561
3561
  const serverRoute = {
3562
3562
  method: route.method,
@@ -4368,6 +4368,9 @@ const getStudioPath = () => {
4368
4368
  if (require("url").pathToFileURL(__filename).href) __dirname = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
4369
4369
  return process.env.MASTRA_STUDIO_PATH || (0, path.join)(__dirname, "studio");
4370
4370
  };
4371
+ function isSchemaApiRoute(route) {
4372
+ return "_mastraSchemaRoute" in route && route._mastraSchemaRoute === true;
4373
+ }
4371
4374
  const DEFAULT_CORS_ALLOW_METHODS = [
4372
4375
  "GET",
4373
4376
  "POST",
@@ -4399,7 +4402,8 @@ function getCorsConfig(serverCors, credentialsDefault) {
4399
4402
  };
4400
4403
  }
4401
4404
  function getRouteCorsConfig(apiRoutes, pathname, method) {
4402
- return ((0, _mastra_server_auth.findMatchingCustomRoute)(pathname, method, apiRoutes)?.route)?.cors;
4405
+ const route = (0, _mastra_server_auth.findMatchingCustomRoute)(pathname, method, apiRoutes)?.route;
4406
+ return route && !isSchemaApiRoute(route) ? route.cors : void 0;
4403
4407
  }
4404
4408
  function getToolExports(tools) {
4405
4409
  try {
@@ -4425,7 +4429,8 @@ async function createHonoServer(mastra, options = { tools: {} }) {
4425
4429
  const apiPrefix = server?.apiPrefix ?? "/api";
4426
4430
  const a2aTaskStore = new _mastra_server_a2a_store.InMemoryTaskStore();
4427
4431
  const processedRoutes = (server?.apiRoutes)?.map((route) => {
4428
- if ("openapi" in route && route.openapi) {
4432
+ if (isSchemaApiRoute(route)) return route;
4433
+ if (route.openapi) {
4429
4434
  const existingMiddleware = route.middleware ? Array.isArray(route.middleware) ? route.middleware : [route.middleware] : [];
4430
4435
  return {
4431
4436
  ...route,