@mastra/deployer 1.82.0 → 1.83.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/{analyze-DNnGuzqf.cjs → analyze-BMEF7WrY.cjs} +17 -4
  2. package/dist/{analyze-DNnGuzqf.cjs.map → analyze-BMEF7WrY.cjs.map} +1 -1
  3. package/dist/{analyze-CW9fEusV.js → analyze-CZjd0SOO.js} +18 -26
  4. package/dist/{analyze-CW9fEusV.js.map → analyze-CZjd0SOO.js.map} +1 -1
  5. package/dist/build/analyze.cjs +1 -1
  6. package/dist/build/analyze.d.ts.map +1 -1
  7. package/dist/build/analyze.js +1 -1
  8. package/dist/build/babel/detect-pino-transports.d.ts +6 -0
  9. package/dist/build/babel/detect-pino-transports.d.ts.map +1 -1
  10. package/dist/build/bundler.cjs +1 -1
  11. package/dist/build/bundler.js +1 -1
  12. package/dist/build/index.cjs +5 -5
  13. package/dist/build/index.js +5 -5
  14. package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
  15. package/dist/build/plugins/remove-deployer.d.ts.map +1 -1
  16. package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
  17. package/dist/{build-Cc9X11g7.cjs → build-CefteFGe.cjs} +5 -5
  18. package/dist/{build-Cc9X11g7.cjs.map → build-CefteFGe.cjs.map} +1 -1
  19. package/dist/{build-PqRB5M-E.js → build-CrmQBpO1.js} +5 -5
  20. package/dist/{build-PqRB5M-E.js.map → build-CrmQBpO1.js.map} +1 -1
  21. package/dist/bundler/index.cjs +1 -1
  22. package/dist/bundler/index.d.ts.map +1 -1
  23. package/dist/bundler/index.js +1 -1
  24. package/dist/{bundler-DRlNM9-F.js → bundler-CID-r2aS.js} +7 -6
  25. package/dist/bundler-CID-r2aS.js.map +1 -0
  26. package/dist/{bundler-CbiKhVps.js → bundler-Cl8WL5zI.js} +5 -3
  27. package/dist/bundler-Cl8WL5zI.js.map +1 -0
  28. package/dist/{bundler-UKxJsU8E.cjs → bundler-CoDL07Rb.cjs} +5 -3
  29. package/dist/bundler-CoDL07Rb.cjs.map +1 -0
  30. package/dist/{bundler-8GO8sXwa.cjs → bundler-fiF6vsGu.cjs} +7 -6
  31. package/dist/bundler-fiF6vsGu.cjs.map +1 -0
  32. package/dist/{bundlerOptions-CPMQkWfY.cjs → bundlerOptions-BICFyOWY.cjs} +6 -4
  33. package/dist/{bundlerOptions-CPMQkWfY.cjs.map → bundlerOptions-BICFyOWY.cjs.map} +1 -1
  34. package/dist/{bundlerOptions-ScfCrul-.js → bundlerOptions-XBDvJpe6.js} +6 -4
  35. package/dist/{bundlerOptions-ScfCrul-.js.map → bundlerOptions-XBDvJpe6.js.map} +1 -1
  36. package/dist/docs/SKILL.md +1 -1
  37. package/dist/docs/assets/SOURCE_MAP.json +33 -2
  38. package/dist/index.cjs +4 -4
  39. package/dist/index.js +4 -4
  40. package/dist/rolldown-runtime-CO0Nlsmt.js +23 -0
  41. package/dist/server/index.cjs +37 -12
  42. package/dist/server/index.cjs.map +1 -1
  43. package/dist/server/index.d.ts +2 -2
  44. package/dist/server/index.js +37 -12
  45. package/dist/server/index.js.map +1 -1
  46. package/dist/services/deps.d.ts.map +1 -1
  47. package/dist/services/index.cjs +1 -1
  48. package/dist/services/index.js +1 -1
  49. package/dist/{services-DbgqQ_yI.cjs → services-B8neClCI.cjs} +52 -5
  50. package/dist/services-B8neClCI.cjs.map +1 -0
  51. package/dist/{services-PA2YqqQJ.js → services-BKh9M2E5.js} +51 -5
  52. package/dist/services-BKh9M2E5.js.map +1 -0
  53. package/package.json +9 -6
  54. package/dist/bundler-8GO8sXwa.cjs.map +0 -1
  55. package/dist/bundler-CbiKhVps.js.map +0 -1
  56. package/dist/bundler-DRlNM9-F.js.map +0 -1
  57. package/dist/bundler-UKxJsU8E.cjs.map +0 -1
  58. package/dist/services-DbgqQ_yI.cjs.map +0 -1
  59. package/dist/services-PA2YqqQJ.js.map +0 -1
  60. /package/dist/_types/{@hono_node-server@2.1.5 → @hono_node-server@2.1.6}/dist/index.d.mts +0 -0
  61. /package/dist/_types/{@hono_node-server@2.1.5 → @hono_node-server@2.1.6}/package.json +0 -0
  62. /package/dist/_types/{@mastra_hono@1.7.24 → @mastra_hono@1.7.25-alpha.1}/dist/auth-middleware.d.ts +0 -0
  63. /package/dist/_types/{@mastra_hono@1.7.24 → @mastra_hono@1.7.25-alpha.1}/dist/browser-stream/index.d.ts +0 -0
  64. /package/dist/_types/{@mastra_hono@1.7.24 → @mastra_hono@1.7.25-alpha.1}/dist/index.d.ts +0 -0
  65. /package/dist/_types/{@mastra_hono@1.7.24 → @mastra_hono@1.7.25-alpha.1}/package.json +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"bundlerOptions-ScfCrul-.js","names":["t","t"],"sources":["../src/build/babel/remove-all-options-except.ts","../src/build/plugins/remove-all-except.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport type { NodePath, PluginObject, types } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n): PluginObject {\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports, but keep the underlying declarations — the\n // extracted option may reference them (e.g. `export const deployer = ...`\n // used as `new Mastra({ deployer })`). Unreferenced declarations are\n // dropped by the cleanup pass afterwards.\n exit(path) {\n if (path.node.declaration) {\n const [declaration] = path.replaceWith(path.node.declaration);\n // Already traversed — don't requeue, or the NewExpression visitor\n // would append the extracted export a second time.\n declaration.skip();\n } else {\n path.remove();\n }\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n // Find the config property, skipping SpreadElement nodes\n let configProperty = mastraArgs.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option,\n );\n let configValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {\n result.hasCustomConfig = true;\n configValue = configProperty.value;\n\n if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {\n const configBinding = state.file.scope.getBinding(option)!;\n\n if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init!));\n configValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), configValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn('Mastra config could not be extracted', {\n option,\n details:\n 'Please make sure your entry file looks like this:\\nexport const mastra = new Mastra({\\n <option>: <value>\\n})',\n });\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } satisfies PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { Plugin, SourceMapInput } from 'rollup';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\n\nexport function removeAllOptionsFromMastraExceptPlugin(\n mastraEntry: string,\n name: keyof MastraConfig,\n result: { hasCustomConfig: boolean },\n options?: { sourcemap?: boolean; logger?: IMastraLogger },\n): Plugin {\n return {\n name: `remove-${name}`,\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],\n sourceMaps: options?.sourcemap,\n }).then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import { types as t } from '@babel/core';\nimport type { PluginObject } from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport async function recursiveRemoveNonReferencedNodes(code: string): Promise<{ code: string; map: any }> {\n const result = await transformAsync(code, {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes],\n });\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!);\n }\n\n return {\n code: result!.code!,\n map: result!.map!,\n };\n}\n","import { realpathSync } from 'node:fs';\nimport { dirname, isAbsolute, sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as pkg from 'empathic/package';\nimport { rollup } from 'rollup';\nimport type { Plugin, RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport { removeAllOptionsFromMastraExceptPlugin } from '../plugins/remove-all-except';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\nimport { getNodeResolveOptions, isBareModuleSpecifier } from '../utils';\n\nconst TS_SOURCE = /\\.tsx?$/;\nconst NODE_MODULES = `${sep}node_modules${sep}`;\n\n/**\n * Packages outside node_modules, such as workspace packages, may ship raw TypeScript (e.g. `exports` pointing to\n * `src/index.ts`), which Node cannot load from the extracted config. Inline those so esbuild transpiles them. Bare\n * imports made from inlined sources stay external but are pinned to the file they resolve to from that source: the\n * extracted config lives in `.mastra/output` and can't see the package's own `node_modules` (e.g. pnpm isolated\n * installs). The app's own imports keep resolving by name.\n */\nfunction typescriptSourcesResolver(entryFile: string): Plugin {\n const appPackageJson = pkg.up({ cwd: dirname(entryFile) });\n const appDir = appPackageJson ? dirname(appPackageJson) : dirname(entryFile);\n // App files keep the entry's path, files resolved by node-resolve are real paths\n const appRoots = [appDir + sep, realpathSync(appDir) + sep];\n const isInlinedSource = (file: string) =>\n isAbsolute(file) && !file.includes(NODE_MODULES) && !appRoots.some(root => file.startsWith(root));\n\n const resolver = nodeResolve({\n ...getNodeResolveOptions('node'),\n extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'],\n });\n const resolveHook = resolver.resolveId!;\n const resolve = typeof resolveHook === 'function' ? resolveHook : resolveHook.handler;\n\n return {\n ...resolver,\n name: 'typescript-sources-resolver',\n async resolveId(id, importer, options) {\n if (!importer || !isBareModuleSpecifier(id)) {\n return null;\n }\n\n const resolved = await resolve.call(this, id, importer, options);\n if (!resolved || typeof resolved !== 'object' || resolved.external) {\n return null;\n }\n\n if (TS_SOURCE.test(resolved.id) && !resolved.id.includes(NODE_MODULES)) {\n return resolved.id;\n }\n\n return isInlinedSource(importer) ? { id: pathToFileURL(resolved.id).href, external: true } : null;\n },\n };\n}\n\nexport function extractMastraOptionBundler(\n name: keyof MastraConfig,\n entryFile: string,\n result: {\n hasCustomConfig: boolean;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n typescriptSourcesResolver(entryFile),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T extends keyof MastraConfig>(\n name: T,\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<MastraConfig[T]>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n };\n\n const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(pathToFileURL(configPath).href).then(m => m[name] as MastraConfig[T]),\n };\n }\n\n return null;\n}\n","import type { IMastraLogger } from '@internal/core/logger';\nimport type { BundlerConfig } from '@internal/deployer';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<BundlerConfig | undefined | null> {\n const result = await extractMastraOption('bundler', entryFile, outputDir, logger);\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAgB,iCACd,QACA,QACA,QACc;CACd,OAAO;EACL,MAAM,uBAAuB,SAAS;EACtC,SAAS;GACP,wBAAwB,EAKtB,KAAK,MAAM;IACT,IAAI,KAAK,KAAK,aAAa;KACzB,MAAM,CAAC,eAAe,KAAK,YAAY,KAAK,KAAK,WAAW;KAG5D,YAAY,KAAK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;CACR,MAAM,SAAS,EACb,iBAAiB,MACnB;CAIA,MAAM,SAAS,OAAM,MAFC,2BAA2B,MAAM,WAAW,QAAQ,MAAM,EAAA,CAEnD,MAAM;EACjC,KAAK;EACL,QAAQ;EACR,gBAAgB;CAClB,CAAC;CAED,IAAI,OAAO,iBAAiB;EAC1B,MAAM,aAAa,GAAG,UAAU,GAAG,KAAK;EAExC,OAAO;GACL,cAAc;GACd,iBAAiB,OAAO,cAAc,UAAU,CAAC,CAAC,KAAK,CAAC,MAAK,MAAK,EAAE,KAAwB;EAC9F;CACF;CAEA,OAAO;AACT;;ACnIA,eAAsB,kBACpB,WACA,WACA,QAC2C;CAC3C,MAAM,SAAS,MAAM,oBAAoB,WAAW,WAAW,WAAW,MAAM;CAEhF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
1
+ {"version":3,"file":"bundlerOptions-XBDvJpe6.js","names":["t","t"],"sources":["../src/build/babel/remove-all-options-except.ts","../src/build/plugins/remove-all-except.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport type { NodePath, PluginObject, types } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n): PluginObject {\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports, but keep the underlying declarations — the\n // extracted option may reference them (e.g. `export const deployer = ...`\n // used as `new Mastra({ deployer })`). Unreferenced declarations are\n // dropped by the cleanup pass afterwards.\n exit(path) {\n if (path.node.declaration) {\n const [declaration] = path.replaceWith(path.node.declaration);\n // Already traversed — don't requeue, or the NewExpression visitor\n // would append the extracted export a second time.\n declaration.skip();\n } else {\n path.remove();\n }\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n // Find the config property, skipping SpreadElement nodes\n let configProperty = mastraArgs.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option,\n );\n let configValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {\n result.hasCustomConfig = true;\n configValue = configProperty.value;\n\n if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {\n const configBinding = state.file.scope.getBinding(option)!;\n\n if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init!));\n configValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), configValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn('Mastra config could not be extracted', {\n option,\n details:\n 'Please make sure your entry file looks like this:\\nexport const mastra = new Mastra({\\n <option>: <value>\\n})',\n });\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } satisfies PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { Plugin, SourceMapInput } from 'rollup';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\n\nexport function removeAllOptionsFromMastraExceptPlugin(\n mastraEntry: string,\n name: keyof MastraConfig,\n result: { hasCustomConfig: boolean },\n options?: { sourcemap?: boolean; logger?: IMastraLogger },\n): Plugin {\n return {\n name: `remove-${name}`,\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],\n sourceMaps: options?.sourcemap,\n }).then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import { types as t } from '@babel/core';\nimport type { PluginObject } from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport async function recursiveRemoveNonReferencedNodes(code: string): Promise<{ code: string; map: any }> {\n const result = await transformAsync(code, {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes],\n });\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!);\n }\n\n return {\n code: result!.code!,\n map: result!.map!,\n };\n}\n","import { realpathSync } from 'node:fs';\nimport { dirname, isAbsolute, sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as pkg from 'empathic/package';\nimport { rollup } from 'rollup';\nimport type { Plugin, RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport { removeAllOptionsFromMastraExceptPlugin } from '../plugins/remove-all-except';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\nimport { getNodeResolveOptions, isBareModuleSpecifier } from '../utils';\n\nconst TS_SOURCE = /\\.tsx?$/;\nconst NODE_MODULES = `${sep}node_modules${sep}`;\n\n/**\n * Packages outside node_modules, such as workspace packages, may ship raw TypeScript (e.g. `exports` pointing to\n * `src/index.ts`), which Node cannot load from the extracted config. Inline those so esbuild transpiles them. Bare\n * imports made from inlined sources stay external but are pinned to the file they resolve to from that source: the\n * extracted config lives in `.mastra/output` and can't see the package's own `node_modules` (e.g. pnpm isolated\n * installs). The app's own imports keep resolving by name.\n */\nfunction typescriptSourcesResolver(entryFile: string): Plugin {\n const appPackageJson = pkg.up({ cwd: dirname(entryFile) });\n const appDir = appPackageJson ? dirname(appPackageJson) : dirname(entryFile);\n // App files keep the entry's path, files resolved by node-resolve are real paths\n const appRoots = [appDir + sep, realpathSync(appDir) + sep];\n const isInlinedSource = (file: string) =>\n isAbsolute(file) && !file.includes(NODE_MODULES) && !appRoots.some(root => file.startsWith(root));\n\n const resolver = nodeResolve({\n ...getNodeResolveOptions('node'),\n extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'],\n });\n const resolveHook = resolver.resolveId!;\n const resolve = typeof resolveHook === 'function' ? resolveHook : resolveHook.handler;\n\n return {\n ...resolver,\n name: 'typescript-sources-resolver',\n async resolveId(id, importer, options) {\n if (!importer || !isBareModuleSpecifier(id)) {\n return null;\n }\n\n // node-resolve passes each result back through `this.resolve`, and the commonjs plugin's resolveId loads every\n // `.js` result to check whether it is CommonJS. With the live context that loads and transforms every installed\n // package reachable from a surviving import, recursively, though all of them end up external.\n const context = Object.create(this, { resolve: { value: async () => null } });\n const resolved = await resolve.call(context, id, importer, options);\n if (!resolved || typeof resolved !== 'object' || resolved.external) {\n return null;\n }\n\n if (TS_SOURCE.test(resolved.id) && !resolved.id.includes(NODE_MODULES)) {\n return resolved.id;\n }\n\n return isInlinedSource(importer) ? { id: pathToFileURL(resolved.id).href, external: true } : null;\n },\n };\n}\n\nexport function extractMastraOptionBundler(\n name: keyof MastraConfig,\n entryFile: string,\n result: {\n hasCustomConfig: boolean;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n typescriptSourcesResolver(entryFile),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T extends keyof MastraConfig>(\n name: T,\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<MastraConfig[T]>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n };\n\n const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n // Chunks are written outside any package with \"type\": \"module\", so a `.js` chunk would be loaded as CommonJS\n // (#28491). The hash keeps them distinct from the main bundle's chunks in `.mastra/output`.\n chunkFileNames: '[name]-[hash].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(pathToFileURL(configPath).href).then(m => m[name] as MastraConfig[T]),\n };\n }\n\n return null;\n}\n","import type { IMastraLogger } from '@internal/core/logger';\nimport type { BundlerConfig } from '@internal/deployer';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<BundlerConfig | undefined | null> {\n const result = await extractMastraOption('bundler', entryFile, outputDir, logger);\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAgB,iCACd,QACA,QACA,QACc;CACd,OAAO;EACL,MAAM,uBAAuB,SAAS;EACtC,SAAS;GACP,wBAAwB,EAKtB,KAAK,MAAM;IACT,IAAI,KAAK,KAAK,aAAa;KACzB,MAAM,CAAC,eAAe,KAAK,YAAY,KAAK,KAAK,WAAW;KAG5D,YAAY,KAAK;IACnB,OACE,KAAK,OAAO;GAEhB,EACF;GAEA,cAAc,MAAM,OAAO;IAGzB,IAAI,CADsB,KAAK,YAAW,SAAQA,MAAE,qBAAqB,KAAK,IAAI,CAC7D,GACnB;IAGF,MAAM,aAAa,KAAK,WAAW;IAEnC,IAAI,CAACA,MAAE,qBAAqB,UAAU,KAAK,CAACA,MAAE,aAAa,WAAW,EAAE,KAAK,WAAW,GAAG,SAAS,UAClG;IAGF,IAAI,aAAaA,MAAE,iBAAiB,CAAC,CAAC;IACtC,IAAIA,MAAE,mBAAmB,KAAK,KAAK,UAAU,EAAE,GAC7C,aAAa,KAAK,KAAK,UAAU;IAInC,IAAI,iBAAiB,WAAW,WAAW,MACzC,SAAQA,MAAE,iBAAiB,IAAI,KAAKA,MAAE,aAAa,KAAK,GAAG,KAAK,KAAK,IAAI,SAAS,MACpF;IACA,IAAI,cAAgCA,MAAE,iBAAiB,CAAC,CAAC;IAEzD,MAAM,cAAc,KAAK,MAAM,iBAAiB,CAAC,CAAC;IAClD,IAAI,CAAC,aACH;IAGF,IAAI,kBAAkBA,MAAE,iBAAiB,cAAc,KAAKA,MAAE,aAAa,eAAe,KAAK,GAAG;KAChG,OAAO,kBAAkB;KACzB,cAAc,eAAe;KAE7B,IAAIA,MAAE,aAAa,eAAe,KAAK,KAAK,eAAe,MAAM,SAAS,QAAQ;MAChF,MAAM,gBAAgB,MAAM,KAAK,MAA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AAW;EACX,SAAS;GACP,cAAc;GACd,0BAA0B,SAAS;GAEnC,QAAQ;GACR,sBAAsB,EACpB,SAAS,uBACX,CAAC;GACD,SAAS;IACP,YAAY,CAAC,OAAO,KAAK;IACzB,gBAAgB;IAChB,yBAAyB;IACzB,gBAAgB;GAClB,CAAC;GACD,KAAK;GACL,uCAAuC,WAAW,MAAM,QAAQ,EAAE,OAAO,CAAC;GAE1E,QAAQ;GACR;IACE,MAAM;IACN,UAAU,MAAM,IAAI;KAClB,IAAI,OAAO,WACT;KAGF,OAAO,kCAAkC,IAAI;IAC/C;GACF;GAEA,QAAQ;EACV;CACF,CAAC;AACH;AAEA,eAAsB,oBACpB,MACA,WACA,WACA,QAIQ;CACR,MAAM,SAAS,EACb,iBAAiB,MACnB;CAIA,MAAM,SAAS,OAAM,MAFC,2BAA2B,MAAM,WAAW,QAAQ,MAAM,EAAA,CAEnD,MAAM;EACjC,KAAK;EACL,QAAQ;EACR,gBAAgB;EAGhB,gBAAgB;CAClB,CAAC;CAED,IAAI,OAAO,iBAAiB;EAC1B,MAAM,aAAa,GAAG,UAAU,GAAG,KAAK;EAExC,OAAO;GACL,cAAc;GACd,iBAAiB,OAAO,cAAc,UAAU,CAAC,CAAC,KAAK,CAAC,MAAK,MAAK,EAAE,KAAwB;EAC9F;CACF;CAEA,OAAO;AACT;;AC1IA,eAAsB,kBACpB,WACA,WACA,QAC2C;CAC3C,MAAM,SAAS,MAAM,oBAAoB,WAAW,WAAW,WAAW,MAAM;CAEhF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
@@ -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.82.0"
6
+ version: "1.83.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,6 +1,37 @@
1
1
  {
2
- "version": "1.82.0",
2
+ "version": "1.83.0-alpha.1",
3
3
  "package": "@mastra/deployer",
4
- "exports": {},
4
+ "exports": {
5
+ "Deployer": {
6
+ "types": "dist/deploy/base.d.ts",
7
+ "implementation": "dist/index.js",
8
+ "line": 6
9
+ },
10
+ "Deps": {
11
+ "types": "dist/services/deps.d.ts",
12
+ "implementation": "dist/services-BKh9M2E5.js",
13
+ "line": 824
14
+ },
15
+ "FileService": {
16
+ "types": "dist/services/fs.d.ts",
17
+ "implementation": "dist/services-BKh9M2E5.js",
18
+ "line": 1255
19
+ },
20
+ "createChildProcessLogger": {
21
+ "types": "dist/deploy/log.d.ts",
22
+ "implementation": "dist/services-BKh9M2E5.js",
23
+ "line": 320
24
+ },
25
+ "createPinoStream": {
26
+ "types": "dist/deploy/log.d.ts",
27
+ "implementation": "dist/services-BKh9M2E5.js",
28
+ "line": 303
29
+ },
30
+ "getDeployer": {
31
+ "types": "dist/build/deployer.d.ts",
32
+ "implementation": "dist/index.js",
33
+ "line": 21
34
+ }
35
+ },
5
36
  "modules": {}
6
37
  }
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_services = require("./services-DbgqQ_yI.cjs");
3
- const require_bundler = require("./bundler-8GO8sXwa.cjs");
4
- const require_bundlerOptions = require("./bundlerOptions-CPMQkWfY.cjs");
5
- require("./build-Cc9X11g7.cjs");
2
+ const require_bundler = require("./bundler-fiF6vsGu.cjs");
3
+ const require_services = require("./services-B8neClCI.cjs");
4
+ require("./build-CefteFGe.cjs");
5
+ const require_bundlerOptions = require("./bundlerOptions-BICFyOWY.cjs");
6
6
  // src/deploy/base.ts
7
7
  var Deployer = class extends require_bundler.Bundler {
8
8
  deps = new require_services.DepsService();
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { c as createPinoStream, i as DepsService, r as Deps, s as createChildProcessLogger, t as FileService } from "./services-PA2YqqQJ.js";
2
- import { t as Bundler } from "./bundler-DRlNM9-F.js";
3
- import { n as extractMastraOption } from "./bundlerOptions-ScfCrul-.js";
4
- import "./build-PqRB5M-E.js";
1
+ import { t as Bundler } from "./bundler-CID-r2aS.js";
2
+ import { c as createPinoStream, i as DepsService, r as Deps, s as createChildProcessLogger, t as FileService } from "./services-BKh9M2E5.js";
3
+ import "./build-CrmQBpO1.js";
4
+ import { n as extractMastraOption } from "./bundlerOptions-XBDvJpe6.js";
5
5
  // src/deploy/base.ts
6
6
  var Deployer = class extends Bundler {
7
7
  deps = new DepsService();
@@ -0,0 +1,23 @@
1
+ // \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ export { __toESM as n, __commonJSMin as t };
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("../rolldown-runtime-Bc0pwXKd.cjs");
3
- const require_utils = require("../utils-CDNA_ewa.cjs");
4
3
  require("../index-CLddUTqr-CeV0aeBL.cjs");
4
+ const require_utils = require("../utils-CDNA_ewa.cjs");
5
5
  let fs = require("fs");
6
6
  let fs_promises = require("fs/promises");
7
7
  let path = require("path");
@@ -36,7 +36,7 @@ require("hono/utils/handler");
36
36
  require("hono/utils/url");
37
37
  require("hono/validator");
38
38
  let hono_http_exception = require("hono/http-exception");
39
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/node-server/2.1.5/c64acaa22e289f28d8358ed7eb315e04e16f012a2b67390803ba774efd774a1e/node_modules/@hono/node-server/dist/index.mjs
39
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/node-server/2.1.6/fdc2ef0c1fce27248082afaacb1b446b5df0c539a71d22f10b0596ee5aa343f0/node_modules/@hono/node-server/dist/index.mjs
40
40
  var RequestError = class extends Error {
41
41
  constructor(message, options) {
42
42
  super(message, options);
@@ -194,16 +194,27 @@ const newHeadersFromIncoming = (incoming) => globalThis.Headers === GlobalHeader
194
194
  const reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
195
195
  const reDotSegment = /\/\.\.?(?:[/?#]|$)/;
196
196
  const reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
197
+ const validateRequestTarget = (target) => {
198
+ const backslash = target.indexOf("\\");
199
+ if (backslash !== -1) {
200
+ const query = target.indexOf("?");
201
+ if (query === -1 || backslash < query) throw new RequestError("Backslash in request path");
202
+ }
203
+ };
197
204
  const buildUrl = (scheme, host, incomingUrl) => {
198
205
  const url = `${scheme}://${host}${incomingUrl}`;
199
206
  if (!reValidHost.test(host)) {
207
+ validateRequestTarget(incomingUrl);
200
208
  const urlObj = new URL(url);
201
209
  if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
202
210
  return urlObj.href;
203
211
  } else if (incomingUrl.length === 0) return url + "/";
204
212
  else {
205
213
  if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
206
- if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
214
+ if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) {
215
+ validateRequestTarget(incomingUrl);
216
+ return new URL(url).href;
217
+ }
207
218
  return url;
208
219
  }
209
220
  };
@@ -612,6 +623,7 @@ const newRequest = (incoming, defaultHostname) => {
612
623
  if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
613
624
  if (incoming instanceof http2.Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
614
625
  try {
626
+ validateRequestTarget(incomingUrl);
615
627
  req[urlKey] = new URL(incomingUrl).href;
616
628
  } catch (e) {
617
629
  throw new RequestError("Invalid absolute URL", { cause: e });
@@ -1152,6 +1164,7 @@ const appendResponseHeaders = (headers, responseHeaders) => {
1152
1164
  });
1153
1165
  };
1154
1166
  const rejectUpgradeRequest = (socket, status, responseHeaders) => {
1167
+ if (socket.destroyed) return;
1155
1168
  const responseLines = ["Connection: close", "Content-Length: 0"];
1156
1169
  appendResponseHeaders(responseLines, responseHeaders);
1157
1170
  socket.end(`HTTP/1.1 ${status.toString()} ${http.STATUS_CODES[status] ?? ""}\r\n${responseLines.join("\r\n")}\r\n\r
@@ -1159,7 +1172,12 @@ const rejectUpgradeRequest = (socket, status, responseHeaders) => {
1159
1172
  };
1160
1173
  const createUpgradeRequest = (request) => {
1161
1174
  const protocol = request.socket.encrypted ? "https" : "http";
1162
- const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
1175
+ const incomingUrl = request.url ?? "/";
1176
+ let url;
1177
+ if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
1178
+ validateRequestTarget(incomingUrl);
1179
+ url = new URL(incomingUrl).href;
1180
+ } else url = buildUrl(protocol, request.headers.host ?? "localhost", incomingUrl);
1163
1181
  const headers = new Headers();
1164
1182
  for (const key in request.headers) {
1165
1183
  const value = request.headers[key];
@@ -1196,6 +1214,10 @@ const setupWebSocket = (options) => {
1196
1214
  };
1197
1215
  server.on("upgrade", async (request, socket, head) => {
1198
1216
  if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
1217
+ const ignoreSocketError = () => {};
1218
+ const reclaimWaiterOnClose = () => rejectWaiter(request);
1219
+ socket.on("error", ignoreSocketError);
1220
+ socket.once("close", reclaimWaiterOnClose);
1199
1221
  const env = {
1200
1222
  incoming: request,
1201
1223
  outgoing: void 0,
@@ -1210,8 +1232,12 @@ const setupWebSocket = (options) => {
1210
1232
  status = response.status;
1211
1233
  responseHeaders = response.headers;
1212
1234
  }
1213
- } catch {
1214
- if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
1235
+ } catch (error) {
1236
+ if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, error instanceof RequestError ? 400 : 500);
1237
+ return;
1238
+ }
1239
+ if (socket.destroyed) {
1240
+ rejectWaiter(request);
1215
1241
  return;
1216
1242
  }
1217
1243
  const waiter = waiterMap.get(request);
@@ -1223,12 +1249,11 @@ const setupWebSocket = (options) => {
1223
1249
  const addResponseHeaders = (headers) => {
1224
1250
  appendResponseHeaders(headers, responseHeaders);
1225
1251
  };
1226
- const reclaimWaiterOnClose = () => rejectWaiter(request);
1227
- socket.once("close", reclaimWaiterOnClose);
1228
1252
  wss.on("headers", addResponseHeaders);
1229
1253
  try {
1230
1254
  wss.handleUpgrade(request, socket, head, (ws) => {
1231
1255
  socket.off("close", reclaimWaiterOnClose);
1256
+ socket.off("error", ignoreSocketError);
1232
1257
  wss.emit("connection", ws, request);
1233
1258
  });
1234
1259
  } finally {
@@ -1337,7 +1362,7 @@ const serve = (options, listeningListener) => {
1337
1362
  });
1338
1363
  return server;
1339
1364
  };
1340
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/node-server/2.1.5/c64acaa22e289f28d8358ed7eb315e04e16f012a2b67390803ba774efd774a1e/node_modules/@hono/node-server/dist/utils/stream.mjs
1365
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/node-server/2.1.6/fdc2ef0c1fce27248082afaacb1b446b5df0c539a71d22f10b0596ee5aa343f0/node_modules/@hono/node-server/dist/utils/stream.mjs
1341
1366
  const pr54206Applied = () => {
1342
1367
  const [major, minor] = process$1.versions.node.split(".").map((component) => parseInt(component));
1343
1368
  return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
@@ -1395,7 +1420,7 @@ const createStreamBody = (stream$2, useNativeReadableToWeb = useReadableToWeb) =
1395
1420
  }
1396
1421
  });
1397
1422
  };
1398
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/node-server/2.1.5/c64acaa22e289f28d8358ed7eb315e04e16f012a2b67390803ba774efd774a1e/node_modules/@hono/node-server/dist/serve-static.mjs
1423
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/node-server/2.1.6/fdc2ef0c1fce27248082afaacb1b446b5df0c539a71d22f10b0596ee5aa343f0/node_modules/@hono/node-server/dist/serve-static.mjs
1399
1424
  const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
1400
1425
  const ENCODINGS = {
1401
1426
  br: ".br",
@@ -1539,7 +1564,7 @@ const serveStatic = (options = { root: "" }) => {
1539
1564
  return result;
1540
1565
  };
1541
1566
  };
1542
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/swagger-ui/0.5.3/fe1b4a78fef400a9bb4ccec4e91cddbbd9b43706afe50dd3266b2297c015e5bf/node_modules/@hono/swagger-ui/dist/index.js
1567
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@hono/swagger-ui/0.5.3/2d64a3444a8e781b9d0909ff286ca728dbe5419d9721688c851938b2e50a9382/node_modules/@hono/swagger-ui/dist/index.js
1543
1568
  const RENDER_TYPE = {
1544
1569
  STRING_ARRAY: "string_array",
1545
1570
  STRING: "string",
@@ -4114,7 +4139,7 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
4114
4139
  });
4115
4140
  }
4116
4141
  };
4117
- // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-openapi/1.5.0/aba075f9c000905a9976a3be5624e02cbca659679195a7801fa8cc48a73fcf35/node_modules/hono-openapi/dist/index.js
4142
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-openapi/1.5.0/6ca93514d06afdfd0d7befe948e629b04e66fbf3f0241f2ac71dd8ec9b8121b7/node_modules/hono-openapi/dist/index.js
4118
4143
  const uniqueSymbol = Symbol.for("hono-openapi");
4119
4144
  function describeRoute(spec) {
4120
4145
  const middleware = async (_c, next) => {