@mastra/temporal 0.0.0 → 0.1.0-alpha.0

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 (55) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +104 -2
  4. package/dist/chunk-BF6TR7JX.js +9 -0
  5. package/dist/chunk-BF6TR7JX.js.map +1 -0
  6. package/dist/chunk-DYBSPLCJ.cjs +11 -0
  7. package/dist/chunk-DYBSPLCJ.cjs.map +1 -0
  8. package/dist/index.cjs +3 -946
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +2 -920
  13. package/dist/index.js.map +1 -1
  14. package/dist/mastra-deployer-UCBGECM5.js +39 -0
  15. package/dist/mastra-deployer-UCBGECM5.js.map +1 -0
  16. package/dist/mastra-deployer-YVT5GB5G.cjs +41 -0
  17. package/dist/mastra-deployer-YVT5GB5G.cjs.map +1 -0
  18. package/dist/mastra-deployer.d.ts +16 -0
  19. package/dist/mastra-deployer.d.ts.map +1 -0
  20. package/dist/plugin.d.ts +13 -15
  21. package/dist/plugin.d.ts.map +1 -1
  22. package/dist/temporal-workflow-runtime.mjs +295 -0
  23. package/dist/transforms/activities.d.ts +4 -3
  24. package/dist/transforms/activities.d.ts.map +1 -1
  25. package/dist/transforms/shared.d.ts +2 -7
  26. package/dist/transforms/shared.d.ts.map +1 -1
  27. package/dist/transforms/temporal-workflow-runtime.d.mts +7 -0
  28. package/dist/transforms/temporal-workflow-runtime.d.mts.map +1 -1
  29. package/dist/transforms/workflows.d.ts +3 -11
  30. package/dist/transforms/workflows.d.ts.map +1 -1
  31. package/dist/worker.cjs +1336 -0
  32. package/dist/worker.cjs.map +1 -0
  33. package/dist/worker.d.ts +2 -0
  34. package/dist/worker.d.ts.map +1 -0
  35. package/dist/worker.js +1310 -0
  36. package/dist/worker.js.map +1 -0
  37. package/package.json +30 -24
  38. package/dist/__tests__/__fixtures__/before/index.d.ts +0 -11
  39. package/dist/__tests__/__fixtures__/before/index.d.ts.map +0 -1
  40. package/dist/__tests__/__fixtures__/before/weather-workflow.d.ts +0 -8
  41. package/dist/__tests__/__fixtures__/before/weather-workflow.d.ts.map +0 -1
  42. package/dist/transforms/__fixtures__/activities/weather-workflow/input.d.ts +0 -8
  43. package/dist/transforms/__fixtures__/activities/weather-workflow/input.d.ts.map +0 -1
  44. package/dist/transforms/__fixtures__/activities/weather-workflow/output.d.ts +0 -3
  45. package/dist/transforms/__fixtures__/activities/weather-workflow/output.d.ts.map +0 -1
  46. package/dist/transforms/__fixtures__/workflow/weather-workflow/input.d.ts +0 -8
  47. package/dist/transforms/__fixtures__/workflow/weather-workflow/input.d.ts.map +0 -1
  48. package/dist/transforms/__fixtures__/workflow/weather-workflow/output.d.ts +0 -2
  49. package/dist/transforms/__fixtures__/workflow/weather-workflow/output.d.ts.map +0 -1
  50. package/dist/webpack-loader.cjs +0 -856
  51. package/dist/webpack-loader.cjs.map +0 -1
  52. package/dist/webpack-loader.d.ts +0 -8
  53. package/dist/webpack-loader.d.ts.map +0 -1
  54. package/dist/webpack-plugin.d.ts +0 -18
  55. package/dist/webpack-plugin.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/transforms/shared.ts","../src/transforms/activities.ts","../src/transforms/workflows.ts","../src/plugin.ts"],"names":["t","t2","parse","readFileSync","program","generate","rollup","basename","join","path"],"mappings":";;;;;;;;;;AAIO,IAAM,aAAA,GAAgB;AAAA,EAC3B,YAAA;AAAA,EACA,KAAA;AAAA,EACA,iBAAA;AAAA,EACA,wBAAA;AAAA,EACA,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA;AACO,SAAS,WAAA,CAAY,UAAkB,UAAA,EAA6B;AACzE,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA,UAAA,GAAa,YAAA,CAAa,UA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A,OAAA,EAAU,sBAAsB,CAAA,CAAE,CAAA;AAAA,QAClG;AAEA,QAAA,OAAO,QAAA,CAAS,GAAG,IAAI,CAAA;AAAA,MACzB,CAAA;AAAA,IACF;AAEA,IAAA,OAAO,mBAAA;AAAA,EACT;AAAA,EAEA,yBAAyB,iBAAA,EAIvB;AACA,IAAA,MAAM,kBAAA,GAAqB,+BAA+B,iBAAiB,CAAA;AAC3E,IAAA,MAAM,oBAAA,GAAuB,iCAAiC,iBAAiB,CAAA;AAC/E,IAAA,MAAM,gBAAA,GAAmB,IAAA,CAAK,qBAAA,CAAsB,uBAAA,CAAwB,iBAAiB,CAAC,CAAA;AAE9F,IAAA,OAAO;AAAA,MACL,aAAA,EAAe,kBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAKf,UAAA,EAAY,IAAA,CAAK,yBAAA,CAA0B,gBAAA,EAAkB,oBAAoB;AAAA,KACnF;AAAA,EACF;AAAA,EAEA,gBAAgB,OAAA,EAAuC;AACrD,IAAA,MAAM,gBAAA,GAAmB,MAAA,CAAO,MAAA,CAAO,IAAI,OAAO,CAAA;AAClD,IAAA,IAAI,KAAK,aAAA,EAAe;AACtB,MAAA,MAAA,CAAO,OAAO,gBAAA,EAAkB,IAAA,CAAK,wBAAA,CAAyB,IAAA,CAAK,aAAa,CAAC,CAAA;AAAA,IACnF,CAAA,MAAO;AACL,MAAA,IAAI,CAAC,OAAA,CAAQ,aAAA,IAAiB,CAAC,QAAQ,UAAA,EAAY;AACjD,QAAA,MAAM,IAAI,MAAM,mDAAmD,CAAA;AAAA,MACrE;AAAA,IACF;AAEA,IAAA,OAAO,gBAAA;AAAA,EACT;AACF","file":"worker.js","sourcesContent":["import { readFileSync } from 'node:fs';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\n\nexport const parserPlugins = [\n 'typescript',\n 'jsx',\n 'classProperties',\n 'classPrivateProperties',\n 'classPrivateMethods',\n 'topLevelAwait',\n 'importAttributes',\n 'decorators-legacy',\n] as const;\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 as any,\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 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.isTSExpressionWithTypeArguments(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 {\n collectImportedNames,\n collectInlineCreateSteps,\n createExportedStepStatement,\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 as any,\n sourceFilename: filePath,\n });\n\n const bindings: TemporalActivityBinding[] = [];\n const seenNames = new Set<string>();\n\n const addBinding = (call: t.CallExpression): void => {\n const exportName = getStepNameFromCall(call);\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 if (isCreateStepCall(declaration.init)) {\n addBinding(declaration.init);\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 as any,\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 as any,\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 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 if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, declaration.init);\n statements.push(createExportedStepStatement(declaration.id.name, declaration.init));\n continue;\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 if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, declaration.init);\n statements.push(createExportedStepStatement(declaration.id.name, declaration.init));\n continue;\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 (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 transformedSource;\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 collectImportedNames,\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 as any,\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\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\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 stepId = getCreateStepId(declaration.init);\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 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): t.Statement[] {\n // Start from `createWorkflow(<static id>)` and rebuild the chain one call at a time\n // using normalized arguments from `rewriteChainMethod`.\n let expression: t.Expression = t.callExpression(t.identifier('createWorkflow'), [t.cloneNode(workflowId, true)]);\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}\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 };\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 ),\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/temporal",
3
- "version": "0.0.0",
3
+ "version": "0.1.0-alpha.0",
4
4
  "description": "Mastra Temporal workflows integration - run Mastra workflows on the Temporal durable execution platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,6 +9,7 @@
9
9
  "dist",
10
10
  "CHANGELOG.md"
11
11
  ],
12
+ "sideEffects": false,
12
13
  "exports": {
13
14
  ".": {
14
15
  "import": {
@@ -16,28 +17,22 @@
16
17
  "default": "./dist/index.js"
17
18
  },
18
19
  "require": {
19
- "types": "./dist/index.d.cts",
20
+ "types": "./dist/index.d.ts",
20
21
  "default": "./dist/index.cjs"
21
22
  }
22
23
  },
23
- "./webpack-loader": {
24
+ "./worker": {
25
+ "import": {
26
+ "types": "./dist/worker.d.ts",
27
+ "default": "./dist/worker.js"
28
+ },
24
29
  "require": {
25
- "types": "./dist/webpack-loader.d.cts",
26
- "default": "./dist/webpack-loader.cjs"
30
+ "types": "./dist/worker.d.ts",
31
+ "default": "./dist/worker.cjs"
27
32
  }
28
33
  },
29
34
  "./package.json": "./package.json"
30
35
  },
31
- "scripts": {
32
- "build": "tsup --silent --config tsup.config.ts",
33
- "build:watch": "pnpm build --watch",
34
- "test": "vitest run --no-isolate --retry=1",
35
- "test:unit": "vitest run --no-isolate --retry=1 --exclude='src/index.test.ts'",
36
- "test:integration": "vitest run --no-isolate --retry=1 src/index.test.ts",
37
- "lint": "eslint .",
38
- "lint:fix": "eslint . --fix",
39
- "typecheck": "tsc --noEmit"
40
- },
41
36
  "keywords": [
42
37
  "mastra",
43
38
  "temporal",
@@ -55,24 +50,25 @@
55
50
  "@temporalio/plugin": "^1.16.1",
56
51
  "@temporalio/worker": "^1.11.7",
57
52
  "@temporalio/workflow": "^1.11.7",
58
- "esbuild": "^0.25.9"
53
+ "rollup": "^4.60.2",
54
+ "@mastra/deployer": "1.32.0-alpha.1"
59
55
  },
60
56
  "peerDependencies": {
61
57
  "@mastra/core": ">=1.1.0-0 <2.0.0-0",
62
58
  "zod": "^3.25.0 || ^4.0.0"
63
59
  },
64
60
  "devDependencies": {
65
- "@internal/lint": "workspace:*",
66
- "@internal/types-builder": "workspace:*",
67
- "@internal/workflow-test-utils": "workspace:*",
68
- "@mastra/core": "workspace:*",
69
61
  "@types/babel__generator": "^7.6.8",
70
62
  "@types/node": "22.19.15",
71
63
  "tsup": "^8.5.1",
72
- "typescript": "catalog:",
73
- "vitest": "catalog:",
64
+ "typescript": "^6.0.3",
65
+ "vitest": "4.1.5",
74
66
  "webpack": "^5.104.1",
75
- "zod": "catalog:"
67
+ "zod": "^4.3.6",
68
+ "@internal/lint": "0.0.90",
69
+ "@mastra/core": "1.32.0-alpha.1",
70
+ "@internal/workflow-test-utils": "0.0.17",
71
+ "@internal/types-builder": "0.0.65"
76
72
  },
77
73
  "homepage": "https://mastra.ai",
78
74
  "repository": {
@@ -85,5 +81,15 @@
85
81
  },
86
82
  "engines": {
87
83
  "node": ">=22.13.0"
84
+ },
85
+ "scripts": {
86
+ "build": "tsup --silent --config tsup.config.ts",
87
+ "build:watch": "pnpm build --watch",
88
+ "test": "vitest run --no-isolate --retry=1",
89
+ "test:unit": "vitest run --no-isolate --retry=1 --exclude='src/index.test.ts'",
90
+ "test:integration": "vitest run --no-isolate --retry=1 src/index.test.ts",
91
+ "lint": "eslint .",
92
+ "lint:fix": "eslint . --fix",
93
+ "typecheck": "tsc --noEmit"
88
94
  }
89
- }
95
+ }
@@ -1,11 +0,0 @@
1
- import { Mastra } from '@mastra/core/mastra';
2
- export declare const mastra: Mastra<Record<string, import("@mastra/core/agent").Agent<any, import("@mastra/core/agent").ToolsInput, undefined, unknown>>, {
3
- weatherWorkflow: import("@mastra/core/workflows").Workflow<import("@mastra/core/workflows").DefaultEngineType, import("@mastra/core/workflows").Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "weather-workflow", unknown, {
4
- city: string;
5
- }, {
6
- city: string;
7
- }, {
8
- city: string;
9
- }, unknown>;
10
- }, Record<string, import("@mastra/core/vector").MastraVector<any>>, Record<string, import("@mastra/core/tts").MastraTTS>, import("@mastra/core/logger").IMastraLogger, Record<string, import("@mastra/core/mcp").MCPServerBase<any>>, Record<string, import("@mastra/core/evals").MastraScorer<any, any, any, any>>, Record<string, import("@mastra/core/tools").ToolAction<any, any, any, any, any, any, unknown>>, Record<string, import("@mastra/core/processors").Processor<any, unknown>>, Record<string, import("@mastra/core/memory").MastraMemory>>;
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/__fixtures__/before/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,eAAO,MAAM,MAAM;;;;;;;;2hBAIjB,CAAC"}
@@ -1,8 +0,0 @@
1
- export declare const weatherWorkflow: import("@mastra/core/workflows").Workflow<import("@mastra/core/workflows").DefaultEngineType, import("@mastra/core/workflows").Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "weather-workflow", unknown, {
2
- city: string;
3
- }, {
4
- city: string;
5
- }, {
6
- city: string;
7
- }, unknown>;
8
- //# sourceMappingURL=weather-workflow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"weather-workflow.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/__fixtures__/before/weather-workflow.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,eAAe;;;;;;WAYL,CAAC"}
@@ -1,8 +0,0 @@
1
- export declare const weatherWorkflow: import("@mastra/core/workflows").Workflow<import("@mastra/core/workflows").DefaultEngineType, import("@mastra/core/workflows").Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "weather-workflow", unknown, {
2
- city: string;
3
- }, {
4
- city: string;
5
- }, {
6
- city: string;
7
- }, unknown>;
8
- //# sourceMappingURL=input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../../src/transforms/__fixtures__/activities/weather-workflow/input.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,eAAe;;;;;;WAYL,CAAC"}
@@ -1,3 +0,0 @@
1
- export function fetchWeather(params: any): Promise<any>;
2
- export function planActivities(params: any): Promise<any>;
3
- //# sourceMappingURL=output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../../src/transforms/__fixtures__/activities/weather-workflow/output.js"],"names":[],"mappings":"AAES,wDAMN;AANM,0DAMN"}
@@ -1,8 +0,0 @@
1
- export declare const workflow: import("@mastra/core/workflows").Workflow<import("@mastra/core/workflows").DefaultEngineType, import("@mastra/core/workflows").Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "weather-workflow", unknown, {
2
- city: string;
3
- }, {
4
- city: string;
5
- }, {
6
- city: string;
7
- }, unknown>;
8
- //# sourceMappingURL=input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../../src/transforms/__fixtures__/workflow/weather-workflow/input.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,QAAQ;;;;;;WAYE,CAAC"}
@@ -1,2 +0,0 @@
1
- export function weatherWorkflow(args: any): any;
2
- //# sourceMappingURL=output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../../src/transforms/__fixtures__/workflow/weather-workflow/output.js"],"names":[],"mappings":"AAoTA,gDAMC"}