{"version":3,"file":"worker.cjs","names":["t","t","t","toWorkflowType","#bundleMastra","#prebuildPath","#compiledActivitiesModules","#loadCompiledActivitiesModule","#loadActivityBindings","#generateActivityBindings"],"sources":["../src/transforms/shared.ts","../src/transforms/activities.ts","../src/transforms/workflows.ts","../src/plugin.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { parse } from '@babel/parser';\nimport type { ParserPlugin } from '@babel/parser';\nimport * as t from '@babel/types';\n\nexport const parserPlugins = ['typescript', 'jsx', 'decorators-legacy'] satisfies ParserPlugin[];\nexport function parseModule(filePath: string, sourceText?: string): t.File {\n  if (!sourceText) {\n    sourceText = readFileSync(filePath, 'utf8');\n  }\n\n  return parse(sourceText, {\n    sourceType: 'module',\n    plugins: parserPlugins,\n    sourceFilename: filePath,\n  });\n}\n\nexport function isIdentifierNamed(node: t.Node, name: string): boolean {\n  return t.isIdentifier(node) && node.name === name;\n}\n\nexport function isTemporalHelperModule(source: string): boolean {\n  return typeof source === 'string' && /(^|\\/)temporal\\.(ts|tsx|js|jsx|mts|mjs)$/.test(source);\n}\n\nexport const strippedExternalModules = new Set(['@temporalio/client', '@temporalio/envconfig']);\n\nexport function isStrippedExternalModule(source: string): boolean {\n  return typeof source === 'string' && strippedExternalModules.has(source);\n}\n\nexport function collectImportedNames(statement: t.ImportDeclaration): Set<string> {\n  const names = new Set<string>();\n\n  for (const specifier of statement.specifiers) {\n    if (\n      t.isImportDefaultSpecifier(specifier) ||\n      t.isImportNamespaceSpecifier(specifier) ||\n      t.isImportSpecifier(specifier)\n    ) {\n      if (t.isIdentifier(specifier.local)) {\n        names.add(specifier.local.name);\n      }\n    }\n  }\n\n  return names;\n}\n\nexport function nodeReferencesName(node: t.Node, names: Set<string>): boolean {\n  let found = false;\n\n  walk(node, current => {\n    if (t.isIdentifier(current) && names.has(current.name)) {\n      found = true;\n      return false;\n    }\n  });\n\n  return found;\n}\n\nexport function isWorkflowHelperDestructure(declaration: t.VariableDeclarator): boolean {\n  if (!t.isObjectPattern(declaration.id)) {\n    return false;\n  }\n\n  return declaration.id.properties.some(\n    property =>\n      t.isObjectProperty(property) &&\n      !property.computed &&\n      t.isIdentifier(property.value) &&\n      (property.value.name === 'createStep' || property.value.name === 'createWorkflow'),\n  );\n}\n\nexport function isCreateWorkflowCall(node: t.Node): node is t.CallExpression {\n  return t.isCallExpression(node) && isIdentifierNamed(node.callee, 'createWorkflow');\n}\n\nexport function isCreateStepCall(node: t.Node): node is t.CallExpression {\n  return t.isCallExpression(node) && isIdentifierNamed(node.callee, 'createStep');\n}\n\nexport function getObjectPropertyName(property: t.ObjectProperty | t.ObjectMethod): string | null {\n  if (property.computed) {\n    return null;\n  }\n\n  if (t.isIdentifier(property.key)) {\n    return property.key.name;\n  }\n\n  if (t.isStringLiteral(property.key)) {\n    return property.key.value;\n  }\n\n  return null;\n}\n\nexport function walk(node: t.Node | null | undefined, visitor: (node: t.Node) => false | void): void {\n  if (!node) {\n    return;\n  }\n\n  const result = visitor(node);\n  if (result === false) {\n    return;\n  }\n\n  const keys = (t.VISITOR_KEYS as Record<string, string[]>)[node.type] ?? [];\n  for (const key of keys) {\n    const value = (node as unknown as Record<string, unknown>)[key];\n\n    if (Array.isArray(value)) {\n      for (const child of value) {\n        if (child && typeof (child as t.Node).type === 'string') {\n          walk(child as t.Node, visitor);\n        }\n      }\n      continue;\n    }\n\n    if (value && typeof (value as t.Node).type === 'string') {\n      walk(value as t.Node, visitor);\n    }\n  }\n}\n\nexport function hasCreateWorkflowCall(node: t.Node): boolean {\n  let found = false;\n\n  walk(node, current => {\n    if (isCreateWorkflowCall(current)) {\n      found = true;\n      return false;\n    }\n  });\n\n  return found;\n}\n\nexport function getStepNameFromCall(node: t.CallExpression): string | null {\n  const stepId = getCreateStepId(node);\n  if (!stepId) {\n    return null;\n  }\n\n  return stepId\n    .replace(/[^a-zA-Z0-9]+(.)/g, (_match, char: string) => char.toUpperCase())\n    .replace(/^[^a-zA-Z_$]+/, '')\n    .replace(/^(.)/, (char: string) => char.toLowerCase());\n}\n\nexport function createExportedStepStatement(name: string, initializer: t.Expression): t.ExportNamedDeclaration {\n  return t.exportNamedDeclaration(\n    t.variableDeclaration('const', [t.variableDeclarator(t.identifier(name), t.cloneNode(initializer, true))]),\n  );\n}\n\nexport function collectInlineCreateSteps(\n  node: t.Node,\n  seenNames: Set<string>,\n  statements: t.Statement[],\n  onStep?: (exportName: string, call: t.CallExpression) => void,\n): void {\n  walk(node, current => {\n    if (!isCreateStepCall(current)) {\n      return;\n    }\n\n    const stepName = getStepNameFromCall(current);\n    if (!stepName || seenNames.has(stepName)) {\n      return false;\n    }\n\n    seenNames.add(stepName);\n    onStep?.(stepName, current);\n    statements.push(createExportedStepStatement(stepName, current));\n    return false;\n  });\n}\n\nexport function getReturnedCreateStepCall(node: t.Node | null | undefined): t.CallExpression | null {\n  if (!node) {\n    return null;\n  }\n\n  if (t.isArrowFunctionExpression(node) && !t.isBlockStatement(node.body)) {\n    return t.isCallExpression(node.body) && isIdentifierNamed(node.body.callee, 'createStep') ? node.body : null;\n  }\n\n  if (!t.isFunctionDeclaration(node) && !t.isFunctionExpression(node) && !t.isArrowFunctionExpression(node)) {\n    return null;\n  }\n\n  if (!t.isBlockStatement(node.body)) {\n    return null;\n  }\n\n  for (const statement of node.body.body) {\n    if (\n      t.isReturnStatement(statement) &&\n      t.isCallExpression(statement.argument) &&\n      isIdentifierNamed(statement.argument.callee, 'createStep')\n    ) {\n      return statement.argument;\n    }\n  }\n\n  return null;\n}\n\nexport function collectCreateStepFactoryBindings(program: t.Program): Map<string, t.CallExpression> {\n  const factories = new Map<string, t.CallExpression>();\n\n  for (const statement of program.body) {\n    const declaration = t.isExportNamedDeclaration(statement) ? statement.declaration : statement;\n\n    if (t.isFunctionDeclaration(declaration) && declaration.id) {\n      const createStepCall = getReturnedCreateStepCall(declaration);\n      if (createStepCall) {\n        factories.set(declaration.id.name, createStepCall);\n      }\n      continue;\n    }\n\n    if (!t.isVariableDeclaration(declaration)) {\n      continue;\n    }\n\n    for (const declarator of declaration.declarations) {\n      if (!t.isIdentifier(declarator.id) || !declarator.init) {\n        continue;\n      }\n\n      const createStepCall = getReturnedCreateStepCall(declarator.init);\n      if (createStepCall) {\n        factories.set(declarator.id.name, createStepCall);\n      }\n    }\n  }\n\n  return factories;\n}\n\nexport function getCreateStepCallFromExpression(\n  node: t.Node | null | undefined,\n  factoryBindings: Map<string, t.CallExpression>,\n): t.CallExpression | null {\n  if (!node) {\n    return null;\n  }\n\n  if (t.isCallExpression(node)) {\n    if (isIdentifierNamed(node.callee, 'createStep')) {\n      return node;\n    }\n\n    if (t.isIdentifier(node.callee)) {\n      return factoryBindings.get(node.callee.name) ?? null;\n    }\n  }\n\n  const returnedCreateStepCall = getReturnedCreateStepCall(node);\n  if (returnedCreateStepCall) {\n    return returnedCreateStepCall;\n  }\n\n  return null;\n}\n\nexport function getCreateStepId(node: t.Node | null | undefined): string | null {\n  if (!node || !isCreateStepCall(node)) {\n    return null;\n  }\n\n  const [config] = node.arguments;\n  if (!t.isObjectExpression(config)) {\n    return null;\n  }\n\n  for (const property of config.properties) {\n    if (!t.isObjectProperty(property) && !t.isObjectMethod(property)) {\n      continue;\n    }\n\n    if (getObjectPropertyName(property) !== 'id') {\n      continue;\n    }\n\n    const value = t.isObjectMethod(property) ? null : property.value;\n    return t.isStringLiteral(value) ? value.value : null;\n  }\n\n  return null;\n}\n\nexport function shouldCountIdentifierAsReference(parent: t.Node | null, key: string | null): boolean {\n  if (!parent) {\n    return true;\n  }\n\n  if ((t.isObjectProperty(parent) || t.isObjectMethod(parent)) && key === 'key' && !parent.computed) {\n    return false;\n  }\n\n  if (t.isMemberExpression(parent) && key === 'property' && !parent.computed) {\n    return false;\n  }\n\n  if (t.isVariableDeclarator(parent) && key === 'id') {\n    return false;\n  }\n\n  if (\n    (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent) || t.isArrowFunctionExpression(parent)) &&\n    key === 'params'\n  ) {\n    return false;\n  }\n\n  if (\n    (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent) || t.isClassDeclaration(parent)) &&\n    key === 'id'\n  ) {\n    return false;\n  }\n\n  if (\n    (t.isImportSpecifier(parent) || t.isImportDefaultSpecifier(parent) || t.isImportNamespaceSpecifier(parent)) &&\n    (key === 'local' || key === 'imported')\n  ) {\n    return false;\n  }\n\n  if (t.isExportSpecifier(parent) && key === 'exported') {\n    return false;\n  }\n\n  if (t.isLabeledStatement(parent) && key === 'label') {\n    return false;\n  }\n\n  if (t.isCatchClause(parent) && key === 'param') {\n    return false;\n  }\n\n  if (t.isRestElement(parent) && key === 'argument') {\n    return false;\n  }\n\n  if (t.isAssignmentPattern(parent) && key === 'left') {\n    return false;\n  }\n\n  if (t.isTSPropertySignature(parent) || t.isTSMethodSignature(parent) || t.isTSInterfaceHeritage(parent)) {\n    return false;\n  }\n\n  return true;\n}\n\nexport function collectRuntimeReferencedIdentifiers(node: t.Node): Set<string> {\n  const refs = new Set<string>();\n\n  const visit = (current: t.Node | null | undefined, parent: t.Node | null, key: string | null) => {\n    if (!current) {\n      return;\n    }\n\n    if (current.type.startsWith('TS')) {\n      return;\n    }\n\n    if (t.isIdentifier(current)) {\n      if (shouldCountIdentifierAsReference(parent, key)) {\n        refs.add(current.name);\n      }\n      return;\n    }\n\n    for (const visitorKey of t.VISITOR_KEYS[current.type] ?? []) {\n      const value = (current as unknown as Record<string, unknown>)[visitorKey];\n      if (Array.isArray(value)) {\n        value.forEach(child => {\n          if (t.isNode(child)) {\n            visit(child, current, visitorKey);\n          }\n        });\n        continue;\n      }\n\n      if (t.isNode(value)) {\n        visit(value, current, visitorKey);\n      }\n    }\n  };\n\n  visit(node, null, null);\n  return refs;\n}\n\nexport function pruneUnusedTopLevelBindings(statements: t.Statement[]): t.Statement[] {\n  const bindings = new Map<string, { refs: Set<string>; statementIndex: number }>();\n  const liveStatements = new Set<number>();\n  const queue: number[] = [];\n\n  const markLive = (statementIndex: number) => {\n    if (liveStatements.has(statementIndex)) {\n      return;\n    }\n\n    liveStatements.add(statementIndex);\n    queue.push(statementIndex);\n  };\n\n  statements.forEach((statement, statementIndex) => {\n    if (t.isImportDeclaration(statement)) {\n      for (const specifier of statement.specifiers) {\n        bindings.set(specifier.local.name, { refs: new Set(), statementIndex });\n      }\n      return;\n    }\n\n    if (t.isVariableDeclaration(statement)) {\n      for (const declaration of statement.declarations) {\n        if (t.isIdentifier(declaration.id)) {\n          bindings.set(declaration.id.name, {\n            refs: declaration.init ? collectRuntimeReferencedIdentifiers(declaration.init) : new Set(),\n            statementIndex,\n          });\n        }\n      }\n      return;\n    }\n\n    if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n      for (const declaration of statement.declaration.declarations) {\n        if (t.isIdentifier(declaration.id)) {\n          bindings.set(declaration.id.name, {\n            refs: declaration.init ? collectRuntimeReferencedIdentifiers(declaration.init) : new Set(),\n            statementIndex,\n          });\n        }\n      }\n      markLive(statementIndex);\n      return;\n    }\n\n    markLive(statementIndex);\n  });\n\n  while (queue.length > 0) {\n    const statementIndex = queue.pop()!;\n    const statement = statements[statementIndex];\n    if (!statement) {\n      continue;\n    }\n\n    const refs = new Set<string>();\n\n    if (t.isImportDeclaration(statement)) {\n      continue;\n    }\n\n    if (t.isVariableDeclaration(statement)) {\n      for (const declaration of statement.declarations) {\n        if (declaration.init) {\n          for (const ref of collectRuntimeReferencedIdentifiers(declaration.init)) {\n            refs.add(ref);\n          }\n        }\n      }\n    } else if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n      for (const declaration of statement.declaration.declarations) {\n        if (declaration.init) {\n          for (const ref of collectRuntimeReferencedIdentifiers(declaration.init)) {\n            refs.add(ref);\n          }\n        }\n      }\n    } else {\n      for (const ref of collectRuntimeReferencedIdentifiers(statement)) {\n        refs.add(ref);\n      }\n    }\n\n    for (const ref of refs) {\n      const binding = bindings.get(ref);\n      if (binding) {\n        markLive(binding.statementIndex);\n      }\n    }\n  }\n\n  const prunedStatements: t.Statement[] = [];\n\n  statements.forEach((statement, statementIndex) => {\n    if (!liveStatements.has(statementIndex)) {\n      return;\n    }\n\n    if (t.isImportDeclaration(statement)) {\n      const specifiers = statement.specifiers.filter(specifier =>\n        liveStatements.has(bindings.get(specifier.local.name)?.statementIndex ?? -1),\n      );\n      if (specifiers.length > 0) {\n        prunedStatements.push(t.importDeclaration(specifiers, statement.source));\n      }\n      return;\n    }\n\n    if (t.isVariableDeclaration(statement)) {\n      const declarations = statement.declarations.filter(\n        declaration =>\n          !t.isIdentifier(declaration.id) ||\n          liveStatements.has(bindings.get(declaration.id.name)?.statementIndex ?? -1),\n      );\n      if (declarations.length > 0) {\n        prunedStatements.push(t.variableDeclaration(statement.kind, declarations));\n      }\n      return;\n    }\n\n    if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n      const declarations = statement.declaration.declarations.filter(\n        declaration =>\n          !t.isIdentifier(declaration.id) ||\n          liveStatements.has(bindings.get(declaration.id.name)?.statementIndex ?? -1),\n      );\n      if (declarations.length > 0) {\n        prunedStatements.push(\n          t.exportNamedDeclaration(t.variableDeclaration(statement.declaration.kind, declarations)),\n        );\n      }\n      return;\n    }\n\n    prunedStatements.push(statement);\n  });\n\n  return prunedStatements;\n}\n","import path, { basename, join } from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { rollup } from 'rollup';\nimport type { SourceMapInput } from 'rollup';\nimport {\n  collectCreateStepFactoryBindings,\n  collectImportedNames,\n  collectInlineCreateSteps,\n  createExportedStepStatement,\n  getCreateStepCallFromExpression,\n  getCreateStepId,\n  getStepNameFromCall,\n  hasCreateWorkflowCall,\n  isCreateStepCall,\n  isStrippedExternalModule,\n  isTemporalHelperModule,\n  isWorkflowHelperDestructure,\n  nodeReferencesName,\n  parserPlugins,\n  pruneUnusedTopLevelBindings,\n  walk,\n} from './shared';\n\nexport interface TemporalActivityBinding {\n  exportName: string;\n  stepId: string;\n}\n\nexport interface BuildTemporalActivitiesModuleResult {\n  outputPath: string;\n  activityBindings: TemporalActivityBinding[];\n}\n\nexport function collectTemporalActivityBindings(sourceText: string, filePath: string): TemporalActivityBinding[] {\n  const ast = parse(sourceText, {\n    sourceType: 'module',\n    plugins: parserPlugins,\n    sourceFilename: filePath,\n  });\n\n  const bindings: TemporalActivityBinding[] = [];\n  const seenNames = new Set<string>();\n  const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);\n\n  const addBinding = (call: t.CallExpression, exportName = getStepNameFromCall(call)): void => {\n    const stepId = getCreateStepId(call);\n\n    if (!exportName || !stepId || seenNames.has(exportName)) {\n      return;\n    }\n\n    seenNames.add(exportName);\n    bindings.push({ exportName, stepId });\n  };\n\n  const collectInlineBindings = (node: t.Node): void => {\n    walk(node, current => {\n      if (!isCreateStepCall(current)) {\n        return;\n      }\n\n      addBinding(current);\n      return false;\n    });\n  };\n\n  for (const statement of ast.program.body) {\n    if (\n      t.isVariableDeclaration(statement) ||\n      (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n    ) {\n      const declarationStatement = t.isVariableDeclaration(statement)\n        ? statement\n        : (statement.declaration as t.VariableDeclaration);\n\n      for (const declaration of declarationStatement.declarations) {\n        if (!declaration.init) {\n          continue;\n        }\n\n        const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n        if (createStepCall) {\n          addBinding(createStepCall, t.isIdentifier(declaration.id) ? declaration.id.name : undefined);\n          continue;\n        }\n\n        if (hasCreateWorkflowCall(declaration.init)) {\n          collectInlineBindings(declaration.init);\n        }\n      }\n\n      continue;\n    }\n\n    if (hasCreateWorkflowCall(statement)) {\n      collectInlineBindings(statement);\n    }\n  }\n\n  return bindings;\n}\n\nfunction normalizeImportPath(importPath: string, extension: string): string {\n  const normalizedPath = importPath.split(path.sep).join('/');\n  const pathWithExtension =\n    extension === '.mjs' || extension === '.cjs' ? normalizedPath : normalizedPath.replace(/\\.[cm]?[jt]sx?$/, '');\n\n  return pathWithExtension.startsWith('.') ? pathWithExtension : `./${pathWithExtension}`;\n}\n\nfunction rebaseModulePath(modulePath: string, sourceFilePath: string, outputFilePath: string): string {\n  if (!modulePath.startsWith('.')) {\n    return modulePath;\n  }\n\n  const resolvedPath = path.resolve(path.dirname(sourceFilePath), modulePath);\n  const relativePath = path.relative(path.dirname(outputFilePath), resolvedPath);\n  return normalizeImportPath(relativePath, path.extname(resolvedPath));\n}\n\nfunction collectWorkflowBindingNames(ast: t.File): Set<string> {\n  const workflowNames = new Set<string>();\n\n  for (const statement of ast.program.body) {\n    if (\n      !t.isVariableDeclaration(statement) &&\n      !(t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n    ) {\n      continue;\n    }\n\n    const declarationStatement = t.isVariableDeclaration(statement)\n      ? statement\n      : (statement.declaration as t.VariableDeclaration);\n\n    for (const declaration of declarationStatement.declarations) {\n      if (t.isIdentifier(declaration.id) && declaration.init && hasCreateWorkflowCall(declaration.init)) {\n        workflowNames.add(declaration.id.name);\n      }\n    }\n  }\n\n  return workflowNames;\n}\n\nfunction isMastraDeclaration(declaration: t.VariableDeclarator): boolean {\n  return t.isIdentifier(declaration.id) && declaration.id.name === 'mastra';\n}\n\nfunction removeStrippedReferencesFromMastraInitializer(init: t.Expression, strippedNames: Set<string>): t.Expression {\n  const clonedInit = t.cloneNode(init, true);\n\n  if (!t.isNewExpression(clonedInit) && !t.isCallExpression(clonedInit)) {\n    return clonedInit;\n  }\n\n  const config = clonedInit.arguments[0];\n  if (!t.isObjectExpression(config)) {\n    return clonedInit;\n  }\n\n  config.properties = config.properties.filter(property => !nodeReferencesName(property, strippedNames));\n  return clonedInit;\n}\n\nfunction createPreservedDeclaration(\n  declaration: t.VariableDeclarator,\n  strippedNames: Set<string>,\n): t.VariableDeclarator {\n  if (!isMastraDeclaration(declaration) || !declaration.init) {\n    return t.cloneNode(declaration, true);\n  }\n\n  return t.variableDeclarator(\n    t.cloneNode(declaration.id, true),\n    removeStrippedReferencesFromMastraInitializer(declaration.init, strippedNames),\n  );\n}\n\nfunction hasLocalMastraBinding(ast: t.File): boolean {\n  return ast.program.body.some(statement => {\n    const declaration = t.isExportNamedDeclaration(statement) ? statement.declaration : statement;\n    if (!t.isVariableDeclaration(declaration)) {\n      return false;\n    }\n\n    return declaration.declarations.some(declarator => t.isIdentifier(declarator.id, { name: 'mastra' }));\n  });\n}\n\nfunction createTemporalActivitiesHelperStatements(\n  mastraImportPath: string | null,\n  hasMastraBinding: boolean,\n): t.Statement[] {\n  const helperSource = mastraImportPath\n    ? `\n        function createStep(args) {\n          return async (params) => {\n            const { mastra } = await import(${JSON.stringify(mastraImportPath)});\n            return args.execute({ ...params, mastra });\n          };\n        }\n      `\n    : hasMastraBinding\n      ? `\n        function createStep(args) {\n          return async (params) => {\n            return args.execute({ ...params, mastra });\n          };\n        }\n      `\n      : `\n        function createStep(args) {\n          return async (params) => {\n            return args.execute(params);\n          };\n        }\n      `;\n\n  return parse(helperSource, {\n    sourceType: 'module',\n    plugins: parserPlugins,\n  }).program.body;\n}\n\nexport async function buildTemporalActivitiesModule(\n  entryFile: string,\n  outputDirectory: string,\n  outputFileName: string,\n): Promise<BuildTemporalActivitiesModuleResult> {\n  const activityBindings: TemporalActivityBinding[] = [];\n  const seenActivityBindingNames = new Set<string>();\n  const addActivityBinding = (exportName: string, call: t.CallExpression): void => {\n    const stepId = getCreateStepId(call);\n\n    if (!stepId || seenActivityBindingNames.has(exportName)) {\n      return;\n    }\n\n    seenActivityBindingNames.add(exportName);\n    activityBindings.push({ exportName, stepId });\n  };\n\n  const bundle = await rollup({\n    input: entryFile,\n    treeshake: 'smallest',\n    logLevel: 'silent',\n    plugins: [\n      {\n        name: 'temporal-workflow-transform',\n        transform(code, id) {\n          const ast = parse(code, {\n            sourceType: 'module',\n            plugins: parserPlugins,\n            sourceFilename: id,\n          });\n\n          const statements: t.Statement[] = [];\n          const seenNames = new Set<string>();\n          const strippedNames = new Set<string>();\n          const workflowBindingNames = collectWorkflowBindingNames(ast);\n          const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);\n          const sourceFilePath = id;\n          const hasMastraBinding = hasLocalMastraBinding(ast);\n          let helperInserted = false;\n\n          const ensureHelperInserted = () => {\n            if (helperInserted) {\n              return;\n            }\n\n            statements.push(...createTemporalActivitiesHelperStatements(null, hasMastraBinding));\n            helperInserted = true;\n          };\n\n          for (const statement of ast.program.body) {\n            if (t.isImportDeclaration(statement)) {\n              if (statement.source.value === '@mastra/core/workflows') {\n                const retainedSpecifiers = statement.specifiers.filter(\n                  specifier =>\n                    !(\n                      t.isImportSpecifier(specifier) &&\n                      t.isIdentifier(specifier.imported) &&\n                      (specifier.imported.name === 'createStep' || specifier.imported.name === 'createWorkflow')\n                    ),\n                );\n\n                if (retainedSpecifiers.length > 0) {\n                  statements.push(t.importDeclaration(retainedSpecifiers, t.stringLiteral(statement.source.value)));\n                }\n                continue;\n              }\n\n              if (isTemporalHelperModule(statement.source.value) || isStrippedExternalModule(statement.source.value)) {\n                for (const name of collectImportedNames(statement)) {\n                  strippedNames.add(name);\n                }\n                continue;\n              }\n\n              const rewrittenSource = rebaseModulePath(statement.source.value, sourceFilePath, id);\n              if (rewrittenSource === statement.source.value) {\n                statements.push(statement);\n              } else {\n                statements.push(\n                  t.importDeclaration(\n                    statement.specifiers.map(specifier => t.cloneNode(specifier, true)),\n                    t.stringLiteral(rewrittenSource),\n                  ),\n                );\n              }\n              continue;\n            }\n\n            if (\n              t.isFunctionDeclaration(statement) ||\n              t.isClassDeclaration(statement) ||\n              t.isTSTypeAliasDeclaration(statement) ||\n              t.isTSInterfaceDeclaration(statement) ||\n              t.isTSEnumDeclaration(statement)\n            ) {\n              ensureHelperInserted();\n              statements.push(statement);\n              continue;\n            }\n\n            if (t.isExpressionStatement(statement) && nodeReferencesName(statement, strippedNames)) {\n              continue;\n            }\n\n            ensureHelperInserted();\n\n            if (t.isVariableDeclaration(statement)) {\n              const declarations: t.VariableDeclarator[] = [];\n\n              for (const declaration of statement.declarations) {\n                if (isWorkflowHelperDestructure(declaration)) {\n                  continue;\n                }\n\n                if (\n                  declaration.init &&\n                  nodeReferencesName(declaration.init, strippedNames) &&\n                  !isMastraDeclaration(declaration)\n                ) {\n                  if (t.isIdentifier(declaration.id)) {\n                    strippedNames.add(declaration.id.name);\n                  }\n                  continue;\n                }\n\n                if (!t.isIdentifier(declaration.id) || !declaration.init) {\n                  declarations.push(createPreservedDeclaration(declaration, strippedNames));\n                  continue;\n                }\n\n                const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n                if (createStepCall) {\n                  const isFactoryCall =\n                    t.isCallExpression(declaration.init) &&\n                    t.isIdentifier(declaration.init.callee) &&\n                    stepFactoryBindings.has(declaration.init.callee.name);\n\n                  if (isFactoryCall) {\n                    seenNames.add(declaration.id.name);\n                    addActivityBinding(declaration.id.name, createStepCall);\n                    statements.push(\n                      t.exportNamedDeclaration(t.variableDeclaration(statement.kind, [t.cloneNode(declaration, true)])),\n                    );\n                    continue;\n                  }\n\n                  if (isCreateStepCall(declaration.init)) {\n                    seenNames.add(declaration.id.name);\n                    addActivityBinding(declaration.id.name, createStepCall);\n                    statements.push(createExportedStepStatement(declaration.id.name, createStepCall));\n                    continue;\n                  }\n                }\n\n                if (hasCreateWorkflowCall(declaration.init)) {\n                  workflowBindingNames.add(declaration.id.name);\n                  strippedNames.add(declaration.id.name);\n                  collectInlineCreateSteps(declaration.init, seenNames, statements, addActivityBinding);\n                  continue;\n                }\n\n                declarations.push(createPreservedDeclaration(declaration, strippedNames));\n              }\n\n              if (declarations.length > 0) {\n                statements.push(\n                  t.variableDeclaration(\n                    statement.kind,\n                    declarations.map(declaration => t.cloneNode(declaration, true)),\n                  ),\n                );\n              }\n              continue;\n            }\n\n            if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n              const exportedDeclarations: t.VariableDeclarator[] = [];\n              const localDeclarations: t.VariableDeclarator[] = [];\n\n              for (const declaration of statement.declaration.declarations) {\n                if (isWorkflowHelperDestructure(declaration)) {\n                  continue;\n                }\n\n                if (\n                  declaration.init &&\n                  nodeReferencesName(declaration.init, strippedNames) &&\n                  !isMastraDeclaration(declaration)\n                ) {\n                  if (t.isIdentifier(declaration.id)) {\n                    strippedNames.add(declaration.id.name);\n                  }\n                  continue;\n                }\n\n                if (!t.isIdentifier(declaration.id) || !declaration.init) {\n                  exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n                  continue;\n                }\n\n                const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n                if (createStepCall) {\n                  const isFactoryCall =\n                    t.isCallExpression(declaration.init) &&\n                    t.isIdentifier(declaration.init.callee) &&\n                    stepFactoryBindings.has(declaration.init.callee.name);\n\n                  if (isFactoryCall) {\n                    seenNames.add(declaration.id.name);\n                    addActivityBinding(declaration.id.name, createStepCall);\n                    exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n                    continue;\n                  }\n\n                  if (isCreateStepCall(declaration.init)) {\n                    seenNames.add(declaration.id.name);\n                    addActivityBinding(declaration.id.name, createStepCall);\n                    statements.push(createExportedStepStatement(declaration.id.name, createStepCall));\n                    continue;\n                  }\n                }\n\n                if (hasCreateWorkflowCall(declaration.init)) {\n                  workflowBindingNames.add(declaration.id.name);\n                  strippedNames.add(declaration.id.name);\n                  collectInlineCreateSteps(declaration.init, seenNames, statements, addActivityBinding);\n                  continue;\n                }\n\n                if (declaration.id.name === 'mastra') {\n                  localDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n                  continue;\n                }\n\n                exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n              }\n\n              if (localDeclarations.length > 0) {\n                statements.push(\n                  t.variableDeclaration(\n                    statement.declaration.kind,\n                    localDeclarations.map(declaration => t.cloneNode(declaration, true)),\n                  ),\n                );\n              }\n\n              if (exportedDeclarations.length > 0) {\n                statements.push(\n                  t.exportNamedDeclaration(\n                    t.variableDeclaration(\n                      statement.declaration.kind,\n                      exportedDeclarations.map(declaration => t.cloneNode(declaration, true)),\n                    ),\n                  ),\n                );\n              }\n              continue;\n            }\n\n            if (t.isExpressionStatement(statement)) {\n              if (nodeReferencesName(statement, workflowBindingNames) || nodeReferencesName(statement, strippedNames)) {\n                collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n                continue;\n              }\n\n              collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n              continue;\n            }\n\n            if (t.isExportNamedDeclaration(statement)) {\n              if (\n                t.isFunctionDeclaration(statement.declaration) ||\n                t.isClassDeclaration(statement.declaration) ||\n                t.isTSTypeAliasDeclaration(statement.declaration) ||\n                t.isTSInterfaceDeclaration(statement.declaration) ||\n                t.isTSEnumDeclaration(statement.declaration)\n              ) {\n                ensureHelperInserted();\n                statements.push(statement);\n                continue;\n              }\n\n              if (statement.declaration == null && statement.source == null) {\n                const retainedSpecifiers = statement.specifiers.filter(\n                  specifier =>\n                    t.isExportSpecifier(specifier) &&\n                    t.isIdentifier(specifier.local) &&\n                    specifier.local.name !== 'mastra' &&\n                    !workflowBindingNames.has(specifier.local.name) &&\n                    !seenNames.has(specifier.local.name),\n                );\n\n                if (retainedSpecifiers.length > 0) {\n                  statements.push(t.exportNamedDeclaration(null, retainedSpecifiers));\n                }\n                continue;\n              }\n\n              if (statement.declaration == null && statement.source) {\n                const mastraSpecifiers = statement.specifiers.filter(\n                  specifier =>\n                    t.isExportSpecifier(specifier) &&\n                    t.isIdentifier(specifier.exported, { name: 'mastra' }) &&\n                    t.isIdentifier(specifier.local, { name: 'mastra' }),\n                );\n\n                if (mastraSpecifiers.length > 0) {\n                  statements.push(\n                    t.importDeclaration(\n                      [t.importSpecifier(t.identifier('mastra'), t.identifier('mastra'))],\n                      t.stringLiteral(rebaseModulePath(statement.source.value, sourceFilePath, id)),\n                    ),\n                  );\n                }\n                continue;\n              }\n\n              collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n              continue;\n            }\n\n            if (t.isExportDefaultDeclaration(statement)) {\n              if (t.isIdentifier(statement.declaration) && workflowBindingNames.has(statement.declaration.name)) {\n                continue;\n              }\n\n              collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n              continue;\n            }\n\n            statements.push(statement);\n          }\n\n          ensureHelperInserted();\n\n          const transformedSource = generate(t.file(t.program(pruneUnusedTopLevelBindings(statements), [], 'module')), {\n            sourceMaps: true,\n          });\n\n          return {\n            code: transformedSource.code,\n            map: transformedSource.map\n              ? ({ ...transformedSource.map, file: transformedSource.map.file ?? undefined } as SourceMapInput)\n              : undefined,\n          };\n        },\n      },\n    ],\n  });\n\n  try {\n    const baseName = basename(outputFileName);\n    const { output } = await bundle.write({\n      dir: outputDirectory,\n      entryFileNames: outputFileName,\n      chunkFileNames: `${baseName}-[hash].mjs`,\n      format: 'esm',\n      sourcemap: 'inline',\n    });\n\n    return {\n      outputPath: join(outputDirectory, output.find(chunk => chunk.type === 'chunk' && chunk.isEntry)!.fileName),\n      activityBindings,\n    };\n  } finally {\n    await bundle.close();\n  }\n}\n","import { readFileSync } from 'node:fs';\nimport { basename, join } from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { rollup } from 'rollup';\nimport { toWorkflowType } from '../utils';\nimport {\n  collectCreateStepFactoryBindings,\n  collectImportedNames,\n  getCreateStepCallFromExpression,\n  getCreateStepId,\n  getObjectPropertyName,\n  isCreateWorkflowCall,\n  isIdentifierNamed,\n  isStrippedExternalModule,\n  isTemporalHelperModule,\n  isWorkflowHelperDestructure,\n  nodeReferencesName,\n  parseModule,\n  parserPlugins,\n  pruneUnusedTopLevelBindings,\n} from './shared';\n\n/**\n * Temporal workflow types must be static so the loader can deterministically map\n * a source workflow to the runtime export name used by the worker.\n */\nfunction getWorkflowIdMetadata(\n  workflowConfig: t.ObjectExpression,\n  workflowName: string,\n  filePath: string,\n): { expression: t.Expression; workflowId: string } {\n  for (const property of workflowConfig.properties) {\n    if (!t.isObjectProperty(property) || getObjectPropertyName(property) !== 'id') {\n      continue;\n    }\n\n    if (!t.isExpression(property.value)) {\n      break;\n    }\n\n    if (t.isStringLiteral(property.value)) {\n      return {\n        expression: t.cloneNode(property.value, true),\n        workflowId: property.value.value,\n      };\n    }\n\n    if (t.isTemplateLiteral(property.value) && property.value.expressions.length === 0) {\n      return {\n        expression: t.cloneNode(property.value, true),\n        workflowId: property.value.quasis[0]?.value.cooked ?? '',\n      };\n    }\n\n    throw new Error(`Workflow id must be a static string for ${workflowName} in ${filePath}`);\n  }\n\n  throw new Error(`Unable to determine workflow id for ${workflowName} in ${filePath}`);\n}\n\n/**\n * The helper runtime lives in its own `.mjs` module so it can be linted and unit-tested\n * like normal code. We parse that file directly here instead of using `Function#toString()`,\n * which keeps fixture output stable under Vitest/Vite instrumentation.\n */\nfunction createTemporalWorkflowHelperStatements(): t.Statement[] {\n  const temporalWorkflowRuntimeSource = readFileSync(\n    new URL('./temporal-workflow-runtime.mjs', import.meta.url),\n    'utf8',\n  );\n\n  const helperProgram = parse(temporalWorkflowRuntimeSource, {\n    sourceType: 'module',\n    plugins: parserPlugins,\n  }).program.body;\n\n  return helperProgram.flatMap(statement => {\n    if (t.isExportNamedDeclaration(statement) && statement.declaration) {\n      return [statement.declaration];\n    }\n\n    return [statement];\n  });\n}\n\nfunction getTemporalWorkflowRuntimeOptions(program: t.Program): t.ObjectExpression | undefined {\n  for (const statement of program.body) {\n    const declarationStatement = t.isVariableDeclaration(statement)\n      ? statement\n      : t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)\n        ? statement.declaration\n        : null;\n\n    if (!declarationStatement) {\n      continue;\n    }\n\n    for (const declaration of declarationStatement.declarations) {\n      if (!isWorkflowHelperDestructure(declaration) || !t.isCallExpression(declaration.init)) {\n        continue;\n      }\n\n      const [temporalParams] = declaration.init.arguments;\n      if (!temporalParams || !t.isObjectExpression(temporalParams)) {\n        continue;\n      }\n\n      for (const property of temporalParams.properties) {\n        if (\n          t.isObjectProperty(property) &&\n          getObjectPropertyName(property) === 'startToCloseTimeout' &&\n          t.isExpression(property.value)\n        ) {\n          return t.objectExpression([\n            t.objectProperty(t.identifier('startToCloseTimeout'), t.cloneNode(property.value, true)),\n          ]);\n        }\n      }\n    }\n  }\n}\n\n/**\n * Walks a chained workflow expression like `createWorkflow(...).then(...).commit()`\n * back to its root `createWorkflow(...)` call while preserving method order.\n */\nfunction parseWorkflowChain(\n  node: t.Node,\n): { createWorkflowCall: t.CallExpression; methods: { name: string; args: t.Node[] }[] } | null {\n  const methods: { name: string; args: t.Node[] }[] = [];\n  let current: t.Node = node;\n\n  // Example:\n  //   createWorkflow(...).then(stepA).sleep(1000).commit()\n  // is peeled from the outside in, producing:\n  //   [then(stepA), sleep(1000), commit()]\n  while (t.isCallExpression(current) && t.isMemberExpression(current.callee) && !current.callee.computed) {\n    if (!t.isIdentifier(current.callee.property)) {\n      return null;\n    }\n\n    methods.unshift({\n      name: current.callee.property.name,\n      args: current.arguments as t.Node[],\n    });\n    current = current.callee.object;\n  }\n\n  if (!isCreateWorkflowCall(current)) {\n    return null;\n  }\n\n  return {\n    createWorkflowCall: current,\n    methods,\n  };\n}\n\n/**\n * Maps local `const someStep = createStep({ id: 'some-step' })` bindings to their\n * runtime ids so later chain rewriting can replace identifier references with ids.\n */\nfunction collectStepBindings(program: t.Program): Map<string, string> {\n  const stepBindings = new Map<string, string>();\n  const stepFactoryBindings = collectCreateStepFactoryBindings(program);\n\n  for (const [factoryName, createStepCall] of stepFactoryBindings) {\n    const stepId = getCreateStepId(createStepCall);\n    if (stepId) {\n      stepBindings.set(factoryName, stepId);\n    }\n  }\n\n  for (const statement of program.body) {\n    if (\n      !t.isVariableDeclaration(statement) &&\n      !(t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n    ) {\n      continue;\n    }\n\n    const declarationStatement = t.isVariableDeclaration(statement)\n      ? statement\n      : (statement.declaration as t.VariableDeclaration);\n\n    for (const declaration of declarationStatement.declarations) {\n      if (!t.isIdentifier(declaration.id) || !declaration.init) {\n        continue;\n      }\n\n      const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n      const stepId = getCreateStepId(createStepCall);\n      if (stepId) {\n        stepBindings.set(declaration.id.name, stepId);\n      }\n    }\n  }\n\n  return stepBindings;\n}\n\nfunction collectWorkflowBindings(program: t.Program, filePath: string): Map<string, string> {\n  const workflowBindings = new Map<string, string>();\n\n  for (const statement of program.body) {\n    if (\n      !t.isVariableDeclaration(statement) &&\n      !(t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n    ) {\n      continue;\n    }\n\n    const declarationStatement = t.isVariableDeclaration(statement)\n      ? statement\n      : (statement.declaration as t.VariableDeclaration);\n\n    for (const declaration of declarationStatement.declarations) {\n      if (!t.isIdentifier(declaration.id) || !declaration.init) {\n        continue;\n      }\n\n      const workflowChain = parseWorkflowChain(declaration.init);\n      const [workflowConfig] = workflowChain?.createWorkflowCall.arguments ?? [];\n      if (!workflowChain || !workflowConfig || !t.isObjectExpression(workflowConfig)) {\n        continue;\n      }\n\n      const { workflowId } = getWorkflowIdMetadata(workflowConfig, declaration.id.name, filePath);\n      workflowBindings.set(declaration.id.name, toWorkflowType(workflowId));\n    }\n  }\n\n  return workflowBindings;\n}\n\n/**\n * Accepts the few AST node shapes we allow as \"step references\" in workflow chains\n * and normalizes them to a single step id string.\n */\nfunction getWorkflowStepName(node: t.Node | null | undefined, stepBindings: Map<string, string>): string | null {\n  if (!node) {\n    return null;\n  }\n\n  if (t.isIdentifier(node)) {\n    return stepBindings.get(node.name) ?? node.name;\n  }\n\n  if (t.isStringLiteral(node)) {\n    return node.value;\n  }\n\n  if (t.isCallExpression(node) && t.isIdentifier(node.callee)) {\n    return stepBindings.get(node.callee.name) ?? getCreateStepId(node);\n  }\n\n  return getCreateStepId(node);\n}\n\n/**\n * Normalizes fluent workflow builder calls into the simpler Temporal runtime shape.\n *\n * Most step references collapse down to step ids so the generated workflow can call\n * activities by id instead of keeping the original `createStep` definitions around.\n */\nfunction rewriteChainMethod(\n  method: { name: string; args: t.Node[] },\n  filePath: string,\n  workflowName: string,\n  stepBindings: Map<string, string>,\n  workflowBindings: Map<string, string>,\n): { name: string; args: t.Expression[] } {\n  const argNode = (index: number): t.Node | undefined => method.args[index];\n  const rewritten = (args: t.Expression[], name = method.name) => ({ name, args });\n\n  // Each case translates an AST representation of a builder call into the exact\n  // argument list expected by our lightweight runtime helper.\n  switch (method.name) {\n    case 'then': {\n      const arg = argNode(0);\n      if (t.isIdentifier(arg)) {\n        const workflowType = workflowBindings.get(arg.name);\n        if (workflowType) {\n          return rewritten([t.stringLiteral(workflowType)], 'thenWorkflow');\n        }\n      }\n\n      const name = getWorkflowStepName(arg, stepBindings);\n      if (!name) {\n        throw new Error(\n          `.then() in ${workflowName} (${filePath}) must take a step or workflow identifier (inline createStep calls are not supported)`,\n        );\n      }\n      return rewritten([t.stringLiteral(name)]);\n    }\n\n    case 'sleep': {\n      const arg = argNode(0);\n      if (t.isNumericLiteral(arg)) {\n        return rewritten([t.cloneNode(arg, true)]);\n      }\n      const name = getWorkflowStepName(arg, stepBindings);\n      if (!name) {\n        throw new Error(`.sleep() in ${workflowName} (${filePath}) must be a numeric literal or an identifier`);\n      }\n      return rewritten([t.stringLiteral(name)]);\n    }\n\n    case 'sleepUntil': {\n      const arg = argNode(0);\n      if (t.isNewExpression(arg) && t.isIdentifier(arg.callee) && arg.callee.name === 'Date') {\n        return rewritten([t.cloneNode(arg, true)]);\n      }\n      if (t.isStringLiteral(arg) || t.isNumericLiteral(arg)) {\n        return rewritten([t.cloneNode(arg, true)]);\n      }\n      const name = getWorkflowStepName(arg, stepBindings);\n      if (!name) {\n        throw new Error(\n          `.sleepUntil() in ${workflowName} (${filePath}) must be a Date, string/number literal, or an identifier`,\n        );\n      }\n      return rewritten([t.stringLiteral(name)]);\n    }\n\n    case 'parallel': {\n      const arg = argNode(0);\n      if (!t.isArrayExpression(arg)) {\n        throw new Error(`.parallel() in ${workflowName} (${filePath}) requires an array literal argument`);\n      }\n      const names = arg.elements.map(el => getWorkflowStepName(el, stepBindings));\n      if (names.some(n => !n)) {\n        throw new Error(`Unable to determine step names inside .parallel() in ${workflowName} (${filePath})`);\n      }\n      return rewritten([t.arrayExpression(names.map(n => t.stringLiteral(n!)))]);\n    }\n\n    case 'branch': {\n      const arg = argNode(0);\n      if (!t.isArrayExpression(arg)) {\n        throw new Error(\n          `.branch() in ${workflowName} (${filePath}) requires an array literal of [condition, step] pairs`,\n        );\n      }\n      const pairs = arg.elements.map(pair => {\n        if (!t.isArrayExpression(pair) || pair.elements.length !== 2) {\n          throw new Error(\n            `.branch() pair in ${workflowName} (${filePath}) must be a 2-element array [condition, step]`,\n          );\n        }\n        const condName = getWorkflowStepName(pair.elements[0], stepBindings);\n        const stepName = getWorkflowStepName(pair.elements[1], stepBindings);\n        if (!condName || !stepName) {\n          throw new Error(`.branch() condition and step in ${workflowName} (${filePath}) must be identifiers`);\n        }\n        return t.arrayExpression([t.stringLiteral(condName), t.stringLiteral(stepName)]);\n      });\n      return rewritten([t.arrayExpression(pairs)]);\n    }\n\n    case 'dowhile':\n    case 'dountil': {\n      const stepName = getWorkflowStepName(argNode(0), stepBindings);\n      const condName = getWorkflowStepName(argNode(1), stepBindings);\n      if (!stepName || !condName) {\n        throw new Error(`.${method.name}() in ${workflowName} (${filePath}) must take (step, condition) identifiers`);\n      }\n      return rewritten([t.stringLiteral(stepName), t.stringLiteral(condName)]);\n    }\n\n    case 'foreach': {\n      const stepName = getWorkflowStepName(argNode(0), stepBindings);\n      if (!stepName) {\n        throw new Error(`.foreach() in ${workflowName} (${filePath}) must take a step identifier`);\n      }\n      const args: t.Expression[] = [t.stringLiteral(stepName)];\n      const optsArg = method.args[1];\n      if (optsArg && t.isExpression(optsArg)) {\n        args.push(t.cloneNode(optsArg, true));\n      }\n      return rewritten(args);\n    }\n\n    case 'commit':\n      return rewritten([]);\n\n    default:\n      throw new Error(`Unsupported workflow chain method .${method.name}() in ${workflowName} (${filePath})`);\n  }\n}\n\nfunction getExportedName(node: t.Identifier | t.StringLiteral): string {\n  return t.isIdentifier(node) ? node.name : node.value;\n}\n\n/**\n * Materializes one transformed workflow export.\n *\n * Instead of preserving the original `const workflow = createWorkflow(...)` shape,\n * we emit a deterministic exported function whose name matches Temporal's runtime\n * lookup and whose body delegates into the injected helper runtime.\n */\nfunction createTemporalWorkflowStatements(\n  exportName: string,\n  workflowId: t.Expression,\n  methods: { name: string; args: t.Node[] }[],\n  filePath: string,\n  includeCommit: boolean,\n  stepBindings: Map<string, string>,\n  workflowBindings: Map<string, string>,\n  runtimeOptions?: t.ObjectExpression,\n): t.Statement[] {\n  // Start from `createWorkflow(<static id>)` and rebuild the chain one call at a time\n  // using normalized arguments from `rewriteChainMethod`.\n  const createWorkflowArgs = [t.cloneNode(workflowId, true)];\n  if (runtimeOptions) {\n    createWorkflowArgs.push(t.cloneNode(runtimeOptions, true));\n  }\n\n  let expression: t.Expression = t.callExpression(t.identifier('createWorkflow'), createWorkflowArgs);\n\n  for (const method of methods) {\n    const rewrittenMethod = rewriteChainMethod(method, filePath, exportName, stepBindings, workflowBindings);\n    expression = t.callExpression(\n      t.memberExpression(expression, t.identifier(rewrittenMethod.name)),\n      rewrittenMethod.args,\n    );\n  }\n\n  if (includeCommit && !methods.some(m => m.name === 'commit')) {\n    expression = t.callExpression(t.memberExpression(expression, t.identifier('commit')), []);\n  }\n\n  const argsParam = t.identifier('args');\n  // Temporal loads workflows by exported symbol name, so we wrap the rebuilt graph\n  // in a named exported function instead of leaving the original builder object.\n  const lambda = t.arrowFunctionExpression(\n    [argsParam],\n    t.blockStatement([t.returnStatement(t.callExpression(expression, [t.identifier('args')]))]),\n  );\n\n  const declaration = t.variableDeclaration('const', [t.variableDeclarator(t.identifier(exportName), lambda)]);\n\n  return [t.exportNamedDeclaration(declaration)];\n}\n\nexport interface BuildTemporalWorkflowOptions {\n  /** Reserved for future loader options. */\n}\n\nexport interface TemporalWorkflowExport {\n  exportName: string;\n  workflowId: string;\n}\n\nexport interface BuildTemporalWorkflowModuleResult {\n  code: string;\n  workflows: TemporalWorkflowExport[];\n}\n\nfunction getTemporalWorkflowExportFromDeclaration(\n  declaration: t.VariableDeclarator,\n  filePath: string,\n): TemporalWorkflowExport | null {\n  if (!t.isIdentifier(declaration.id) || !declaration.init) {\n    return null;\n  }\n\n  const workflowChain = parseWorkflowChain(declaration.init);\n  if (!workflowChain) {\n    return null;\n  }\n\n  const [workflowConfig] = workflowChain.createWorkflowCall.arguments;\n  if (!workflowConfig || !t.isObjectExpression(workflowConfig)) {\n    throw new Error(`Unable to determine workflow config for ${declaration.id.name} in ${filePath}`);\n  }\n\n  const { workflowId } = getWorkflowIdMetadata(workflowConfig, declaration.id.name, filePath);\n  return {\n    exportName: toWorkflowType(workflowId),\n    workflowId,\n  };\n}\n\nfunction getVariableDeclarationFromStatement(statement: t.Statement): t.VariableDeclaration | null {\n  if (t.isVariableDeclaration(statement)) {\n    return statement;\n  }\n\n  if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n    return statement.declaration;\n  }\n\n  return null;\n}\n\nfunction getCommittedWorkflowName(statement: t.Statement): string | null {\n  if (!t.isExpressionStatement(statement)) {\n    return null;\n  }\n\n  const { expression } = statement;\n  if (\n    !t.isCallExpression(expression) ||\n    !t.isMemberExpression(expression.callee) ||\n    expression.callee.computed ||\n    !isIdentifierNamed(expression.callee.property, 'commit') ||\n    !t.isIdentifier(expression.callee.object)\n  ) {\n    return null;\n  }\n\n  return expression.callee.object.name;\n}\n\ninterface WorkflowTransformState {\n  statements: t.Statement[];\n  workflowNames: Set<string>;\n  committedWorkflowNames: Set<string>;\n  inlineExportedWorkflowNames: Set<string>;\n  strippedNames: Set<string>;\n  stepBindings: Map<string, string>;\n  workflowBindings: Map<string, string>;\n  workflowExports: TemporalWorkflowExport[];\n  runtimeOptions?: t.ObjectExpression;\n}\n\nfunction createWorkflowTransformState(program: t.Program, filePath: string): WorkflowTransformState {\n  return {\n    statements: [...createTemporalWorkflowHelperStatements()],\n    workflowNames: new Set<string>(),\n    committedWorkflowNames: new Set<string>(),\n    inlineExportedWorkflowNames: new Set<string>(),\n    strippedNames: new Set<string>(),\n    stepBindings: collectStepBindings(program),\n    workflowBindings: collectWorkflowBindings(program, filePath),\n    workflowExports: [],\n    runtimeOptions: getTemporalWorkflowRuntimeOptions(program),\n  };\n}\n\nfunction collectWorkflowDeclarationMetadata(statement: t.Statement, state: WorkflowTransformState): void {\n  const declarationStatement = getVariableDeclarationFromStatement(statement);\n  if (!declarationStatement) {\n    return;\n  }\n\n  for (const declaration of declarationStatement.declarations) {\n    if (!t.isIdentifier(declaration.id) || !declaration.init) {\n      continue;\n    }\n\n    if (!parseWorkflowChain(declaration.init)) {\n      continue;\n    }\n\n    state.workflowNames.add(declaration.id.name);\n    if (t.isExportNamedDeclaration(statement)) {\n      state.inlineExportedWorkflowNames.add(declaration.id.name);\n    }\n  }\n}\n\nfunction collectWorkflowExportMetadata(statement: t.Statement, state: WorkflowTransformState): void {\n  if (t.isExportNamedDeclaration(statement) && statement.declaration == null && statement.source == null) {\n    for (const specifier of statement.specifiers) {\n      if (!t.isExportSpecifier(specifier) || !t.isIdentifier(specifier.local)) {\n        continue;\n      }\n\n      if (!state.workflowNames.has(specifier.local.name)) {\n        continue;\n      }\n\n      if (getExportedName(specifier.exported) === specifier.local.name) {\n        state.inlineExportedWorkflowNames.add(specifier.local.name);\n      }\n    }\n  }\n}\n\nfunction collectWorkflowTransformMetadata(program: t.Program, state: WorkflowTransformState): void {\n  for (const statement of program.body) {\n    collectWorkflowDeclarationMetadata(statement, state);\n\n    const committedWorkflowName = getCommittedWorkflowName(statement);\n    if (committedWorkflowName) {\n      state.committedWorkflowNames.add(committedWorkflowName);\n    }\n\n    collectWorkflowExportMetadata(statement, state);\n  }\n}\n\nfunction rewriteWorkflowImportDeclaration(statement: t.ImportDeclaration, state: WorkflowTransformState): void {\n  if (statement.source.value === '@mastra/core/workflows') {\n    const retainedSpecifiers = statement.specifiers.filter(\n      specifier =>\n        !(\n          t.isImportSpecifier(specifier) &&\n          t.isIdentifier(specifier.imported) &&\n          (specifier.imported.name === 'createWorkflow' || specifier.imported.name === 'createStep')\n        ),\n    );\n\n    if (retainedSpecifiers.length > 0) {\n      state.statements.push(t.importDeclaration(retainedSpecifiers, t.stringLiteral(statement.source.value)));\n    }\n    return;\n  }\n\n  if (isTemporalHelperModule(statement.source.value) || isStrippedExternalModule(statement.source.value)) {\n    for (const name of collectImportedNames(statement)) {\n      state.strippedNames.add(name);\n    }\n    return;\n  }\n\n  state.statements.push(statement);\n}\n\nfunction getNormalizedWorkflowBindingName(name: string, state: WorkflowTransformState): string | null {\n  if (!state.workflowNames.has(name)) {\n    return null;\n  }\n\n  return state.workflowBindings.get(name) ?? name;\n}\n\nfunction rewriteWorkflowNamedExport(statement: t.ExportNamedDeclaration, state: WorkflowTransformState): void {\n  if (statement.source != null) {\n    return;\n  }\n\n  const retainedSpecifiers = statement.specifiers.flatMap(specifier => {\n    if (!t.isExportSpecifier(specifier) || !t.isIdentifier(specifier.local)) {\n      return [];\n    }\n\n    const normalizedLocalName = getNormalizedWorkflowBindingName(specifier.local.name, state);\n    if (!normalizedLocalName || getExportedName(specifier.exported) === specifier.local.name) {\n      return [];\n    }\n\n    return [t.exportSpecifier(t.identifier(normalizedLocalName), t.cloneNode(specifier.exported))];\n  });\n\n  if (retainedSpecifiers.length > 0) {\n    state.statements.push(t.exportNamedDeclaration(null, retainedSpecifiers));\n  }\n}\n\nfunction rewriteWorkflowVariableDeclaration(\n  statement: t.Statement,\n  filePath: string,\n  state: WorkflowTransformState,\n): void {\n  const declarationStatement = getVariableDeclarationFromStatement(statement);\n  if (!declarationStatement) {\n    return;\n  }\n\n  const declarations: t.VariableDeclarator[] = [];\n\n  for (const declaration of declarationStatement.declarations) {\n    if (isWorkflowHelperDestructure(declaration)) {\n      continue;\n    }\n\n    if (t.isIdentifier(declaration.id) && state.stepBindings.has(declaration.id.name)) {\n      state.strippedNames.add(declaration.id.name);\n      continue;\n    }\n\n    if (!t.isIdentifier(declaration.id) || !declaration.init) {\n      declarations.push(declaration);\n      continue;\n    }\n\n    // If this initializer is a workflow builder chain, convert it into a new\n    // exported runtime function. Otherwise keep it as-is unless it only exists\n    // to support stripped `createStep` code.\n    const workflowChain = parseWorkflowChain(declaration.init);\n    if (!workflowChain && nodeReferencesName(declaration.init, state.strippedNames)) {\n      state.strippedNames.add(declaration.id.name);\n      continue;\n    }\n\n    if (!workflowChain) {\n      declarations.push(declaration);\n      continue;\n    }\n\n    const [workflowConfig] = workflowChain.createWorkflowCall.arguments;\n    if (!workflowConfig || !t.isObjectExpression(workflowConfig)) {\n      throw new Error(`Unable to determine workflow config for ${declaration.id.name} in ${filePath}`);\n    }\n\n    const { expression: workflowId } = getWorkflowIdMetadata(workflowConfig, declaration.id.name, filePath);\n    const workflowExport = getTemporalWorkflowExportFromDeclaration(declaration, filePath);\n    if (!workflowExport) {\n      throw new Error(`Unable to determine workflow export for ${declaration.id.name} in ${filePath}`);\n    }\n\n    // The source binding name is irrelevant at runtime. Temporal looks up the\n    // workflow by type, so we derive the exported symbol from the static id.\n    const { exportName } = workflowExport;\n\n    state.workflowExports.push(workflowExport);\n    state.statements.push(\n      ...createTemporalWorkflowStatements(\n        exportName,\n        workflowId,\n        workflowChain.methods,\n        filePath,\n        state.committedWorkflowNames.has(declaration.id.name),\n        state.stepBindings,\n        state.workflowBindings,\n        state.runtimeOptions,\n      ),\n    );\n  }\n\n  if (declarations.length > 0) {\n    const cloned = declarations.map(declaration => t.cloneNode(declaration, true));\n    state.statements.push(t.variableDeclaration(declarationStatement.kind, cloned));\n  }\n}\n\nfunction rewriteWorkflowStatement(statement: t.Statement, filePath: string, state: WorkflowTransformState): void {\n  if (t.isImportDeclaration(statement)) {\n    rewriteWorkflowImportDeclaration(statement, state);\n    return;\n  }\n\n  if (getCommittedWorkflowName(statement)) {\n    return;\n  }\n\n  if (t.isExportNamedDeclaration(statement)) {\n    if (statement.declaration == null) {\n      rewriteWorkflowNamedExport(statement, state);\n      return;\n    }\n\n    if (t.isVariableDeclaration(statement.declaration)) {\n      rewriteWorkflowVariableDeclaration(statement, filePath, state);\n      return;\n    }\n\n    state.statements.push(statement.declaration);\n    return;\n  }\n\n  if (t.isExportDefaultDeclaration(statement) && t.isIdentifier(statement.declaration)) {\n    const normalizedLocalName = getNormalizedWorkflowBindingName(statement.declaration.name, state);\n    if (normalizedLocalName) {\n      state.statements.push(t.exportDefaultDeclaration(t.identifier(normalizedLocalName)));\n    }\n    return;\n  }\n\n  if (getVariableDeclarationFromStatement(statement)) {\n    rewriteWorkflowVariableDeclaration(statement, filePath, state);\n    return;\n  }\n\n  state.statements.push(statement);\n}\n\nasync function finalizeWorkflowModule(state: WorkflowTransformState): Promise<BuildTemporalWorkflowModuleResult> {\n  const transformedSource = generate(t.file(t.program(pruneUnusedTopLevelBindings(state.statements), [], 'module')), {\n    sourceMaps: true,\n  });\n\n  return {\n    ...transformedSource,\n    workflows: state.workflowExports,\n  };\n}\n\n/**\n * Transforms a user-authored workflow module into a Temporal-friendly module:\n * - strips Mastra/Temporal setup that cannot run in the workflow sandbox\n * - rewrites fluent workflow chains into deterministic exported functions\n * - returns registry metadata so the entry module can re-export the right names\n */\nexport async function buildTemporalWorkflowModule(\n  entryFile: string,\n  outputDirectory: string,\n  outputFileName: string,\n): Promise<{ outputPath: string }> {\n  const bundle = await rollup({\n    input: entryFile,\n    treeshake: 'smallest',\n    logLevel: 'silent',\n    plugins: [\n      {\n        name: 'temporal-workflow-transform',\n        transform(code, id) {\n          const ast = parseModule(id, code);\n          const state = createWorkflowTransformState(ast.program, id);\n          collectWorkflowTransformMetadata(ast.program, state);\n          for (const statement of ast.program.body) {\n            // We rewrite only the top-level workflow declarations/exports and keep unrelated\n            // module code intact unless it becomes dead after step/workflow stripping.\n            rewriteWorkflowStatement(statement, id, state);\n          }\n\n          return finalizeWorkflowModule(state);\n        },\n      },\n    ],\n  });\n\n  try {\n    const baseName = basename(outputFileName);\n    const { output } = await bundle.write({\n      dir: outputDirectory,\n      entryFileNames: outputFileName,\n      chunkFileNames: `${baseName}-[hash].mjs`,\n      format: 'esm',\n      sourcemap: 'inline',\n    });\n\n    return {\n      outputPath: join(outputDirectory, output.find(chunk => chunk.type === 'chunk' && chunk.isEntry)!.fileName),\n    };\n  } finally {\n    await bundle.close();\n  }\n}\n","import { readFileSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport type { WorkerOptions, WorkerPlugin } from '@temporalio/worker';\nimport type { TemporalActivityBinding } from './transforms/activities';\nimport { buildTemporalActivitiesModule } from './transforms/activities';\nimport { buildTemporalWorkflowModule } from './transforms/workflows';\n\nconst CACHE_PATH = 'node_modules/.mastra';\nconst WORKFLOW_FILE_NAME = 'workflow.mjs';\nconst ACTIVITIES_FILE_NAME = 'activities.mjs';\nconst ACTIVITY_BINDINGS_FILE_NAME = 'activity-bindings.json';\n\nfunction getGeneratedWorkflowModulePath(outputDir: string): string {\n  return path.join(outputDir, WORKFLOW_FILE_NAME);\n}\n\nfunction getGeneratedActivitiesModulePath(outputDir: string): string {\n  return path.join(outputDir, ACTIVITIES_FILE_NAME);\n}\n\nfunction getActivityBindingsPath(outputDir: string): string {\n  return path.join(outputDir, ACTIVITY_BINDINGS_FILE_NAME);\n}\n\nexport class MastraPlugin implements WorkerPlugin {\n  #prebuildPath: string | null = null;\n  #compiledActivitiesModules = new Map<string, Promise<Record<string, unknown>>>();\n  name = 'Mastra';\n\n  constructor() {}\n\n  async #bundleMastra(entryFile: string, projectRoot: string, outputDirectory: string): Promise<string> {\n    const { BuildBundler } = await import('./mastra-deployer');\n    const normalizedEntryFile = entryFile.startsWith('file:/') ? fileURLToPath(entryFile) : entryFile;\n    const mastraBundler = new BuildBundler();\n    await mastraBundler.prepare(outputDirectory);\n    await mastraBundler.bundle(normalizedEntryFile, outputDirectory, {\n      toolsPaths: [],\n      projectRoot,\n    });\n\n    return path.join(outputDirectory, 'output', 'index.mjs');\n  }\n\n  async prebuild({\n    entryFile,\n    projectRoot = process.cwd(),\n  }: {\n    entryFile: string;\n    projectRoot?: string;\n  }): Promise<ReturnType<typeof this.getTemporalWorkerOptions>> {\n    const temporalOutputDir = path.resolve(projectRoot, CACHE_PATH);\n    const compiledEntryPath = await this.#bundleMastra(entryFile, projectRoot, temporalOutputDir);\n\n    await buildTemporalWorkflowModule(compiledEntryPath, temporalOutputDir, WORKFLOW_FILE_NAME);\n\n    const { activityBindings } = await buildTemporalActivitiesModule(\n      compiledEntryPath,\n      temporalOutputDir,\n      ACTIVITIES_FILE_NAME,\n    );\n\n    await writeFile(getActivityBindingsPath(temporalOutputDir), JSON.stringify(activityBindings, null, 2), 'utf8');\n\n    this.#prebuildPath = temporalOutputDir;\n    return this.getTemporalWorkerOptions(temporalOutputDir);\n  }\n\n  #loadActivityBindings(activityBindingsPath: string): TemporalActivityBinding[] {\n    try {\n      const bindings = JSON.parse(readFileSync(activityBindingsPath, 'utf8')) as TemporalActivityBinding[];\n      return bindings;\n    } catch (error) {\n      throw new Error(`MastraPlugin.prebuild() must be called before use, or ${activityBindingsPath} must exist`, {\n        cause: error,\n      });\n    }\n  }\n\n  #loadCompiledActivitiesModule(activitiesModulePath: string): Promise<Record<string, unknown>> {\n    const cachedModule = this.#compiledActivitiesModules.get(activitiesModulePath);\n    if (cachedModule) {\n      return cachedModule;\n    }\n\n    const modulePromise = import(`${pathToFileURL(activitiesModulePath).href}?t=${Date.now()}`) as Promise<\n      Record<string, unknown>\n    >;\n\n    this.#compiledActivitiesModules.set(activitiesModulePath, modulePromise);\n    return modulePromise;\n  }\n\n  #generateActivityBindings(\n    activityBindings: TemporalActivityBinding[],\n    compiledActivitiesPath: string,\n  ): Record<string, (...args: unknown[]) => Promise<unknown>> {\n    const generatedActivities: Record<string, (...args: unknown[]) => Promise<unknown>> = {};\n    for (const binding of activityBindings) {\n      if (generatedActivities[binding.stepId]) {\n        continue;\n      }\n\n      generatedActivities[binding.stepId] = async (...args: unknown[]) => {\n        const activityModule = await this.#loadCompiledActivitiesModule(compiledActivitiesPath);\n        const activity = activityModule[binding.exportName];\n\n        if (typeof activity !== 'function') {\n          throw new Error(`Unable to load activity '${binding.exportName}' from ${compiledActivitiesPath}`);\n        }\n\n        return activity(...args);\n      };\n    }\n\n    return generatedActivities;\n  }\n\n  getTemporalWorkerOptions(temporalOutputDir: string): {\n    // workflowBundle: WorkerOptions['workflowBundle'];\n    workflowsPath: WorkerOptions['workflowsPath'];\n    activities: WorkerOptions['activities'];\n  } {\n    const workflowOutputPath = getGeneratedWorkflowModulePath(temporalOutputDir);\n    const activitiesOutputPath = getGeneratedActivitiesModulePath(temporalOutputDir);\n    const activityBindings = this.#loadActivityBindings(getActivityBindingsPath(temporalOutputDir));\n\n    return {\n      workflowsPath: workflowOutputPath,\n      // workflowBundle: {\n      //   codePath: workflowOutputPath,\n      //   sourceMapPath: `${workflowOutputPath}.map`,\n      // },\n      activities: this.#generateActivityBindings(activityBindings, activitiesOutputPath),\n    };\n  }\n\n  configureWorker(options: WorkerOptions): WorkerOptions {\n    const augmentedOptions = Object.assign({}, options);\n    if (this.#prebuildPath) {\n      Object.assign(augmentedOptions, this.getTemporalWorkerOptions(this.#prebuildPath));\n    } else {\n      if (!options.workflowsPath || !options.activities) {\n        throw new Error('MastraPlugin.prebuild() must be called before use');\n      }\n    }\n\n    return augmentedOptions;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,gBAAgB;CAAC;CAAc;CAAO;AAAmB;AACtE,SAAgB,YAAY,UAAkB,YAA6B;CACzE,IAAI,CAAC,YACH,cAAA,GAAA,GAAA,aAAA,CAA0B,UAAU,MAAM;CAG5C,QAAA,GAAA,cAAA,MAAA,CAAa,YAAY;EACvB,YAAY;EACZ,SAAS;EACT,gBAAgB;CAClB,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