@mastra/temporal 0.0.0 → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +41 -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
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/run.ts","../src/workflow.ts","../src/transforms/shared.ts","../src/transforms/activities.ts","../src/transforms/workflows.ts","../src/webpack-plugin.ts","../src/plugin.ts"],"names":["path","esbuildTransform","t2","program","t3","parse","generate","mkdir","writeFile","readFileSync","require"],"mappings":";;;;;;;;;;;;;;;AAAO,SAAS,eAAe,EAAA,EAAY;AACzC,EAAA,MAAM,UAAA,GAAa,GAAG,OAAA,CAAQ,qBAAA,EAAuB,CAAC,CAAA,EAAG,IAAA,KAAiB,IAAA,CAAK,WAAA,EAAa,CAAA;AAC5F,EAAA,OAAO,WAAW,QAAA,CAAS,UAAU,CAAA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ACF;AACF","file":"index.js","sourcesContent":["export function toWorkflowType(id: string) {\n const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char: string) => char.toUpperCase());\n return camelCased.endsWith('Workflow') ? camelCased : `${camelCased}Workflow`;\n}\n","import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n const result = await handle.result();\n\n return {\n status: 'success',\n input: input as TInput,\n result: result as TOutput,\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n","import path from 'node:path';\nimport * as t from '@babel/types';\nimport { transform as esbuildTransform } from 'esbuild';\n\nexport const parserPlugins = [\n 'typescript',\n 'jsx',\n 'classProperties',\n 'classPrivateProperties',\n 'classPrivateMethods',\n 'topLevelAwait',\n 'importAttributes',\n 'decorators-legacy',\n] as const;\n\nexport interface WorkflowImportBinding {\n exportName: string;\n importedName: string | 'default';\n source: string;\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(node: t.Node, seenNames: Set<string>, statements: t.Statement[]): 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 statements.push(createExportedStepStatement(stepName, current));\n return false;\n });\n}\n\nexport async function transpileModule(sourceText: string, filePath: string): Promise<string> {\n const loader = path.extname(filePath).slice(1) || 'js';\n const { code } = await esbuildTransform(sourceText, {\n loader: loader as any,\n format: 'esm',\n platform: 'node',\n target: 'node22',\n sourcemap: false,\n sourcefile: filePath,\n });\n\n return code ?? '';\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 { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\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 transpileModule,\n walk,\n} from './shared';\n\nexport interface TemporalActivityBinding {\n exportName: string;\n stepId: string;\n}\n\nexport interface BuildTemporalActivitiesOptions {\n mastraImportPath?: string;\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 createTemporalActivitiesHelperStatements(mastraImportPath = './index'): t.Statement[] {\n const helperSource = `\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\n return parse(helperSource, {\n sourceType: 'module',\n plugins: parserPlugins as any,\n }).program.body;\n}\n\nexport async function buildTemporalActivitiesModule(\n sourceText: string,\n filePath: string,\n options: BuildTemporalActivitiesOptions = {},\n): Promise<string> {\n const ast = parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins as any,\n sourceFilename: filePath,\n });\n\n const statements: t.Statement[] = [];\n const seenNames = new Set<string>();\n const strippedNames = new Set<string>();\n let helperInserted = false;\n\n const ensureHelperInserted = () => {\n if (helperInserted) {\n return;\n }\n\n statements.push(...createTemporalActivitiesHelperStatements(options.mastraImportPath));\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 statements.push(statement);\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 (declaration.init && nodeReferencesName(declaration.init, strippedNames)) {\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(declaration);\n continue;\n }\n\n if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n statements.push(createExportedStepStatement(declaration.id.name, declaration.init));\n continue;\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n collectInlineCreateSteps(declaration.init, seenNames, statements);\n continue;\n }\n\n declarations.push(declaration);\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 declarations: t.VariableDeclarator[] = [];\n\n for (const declaration of statement.declaration.declarations) {\n if (isWorkflowHelperDestructure(declaration)) {\n continue;\n }\n\n if (declaration.init && nodeReferencesName(declaration.init, strippedNames)) {\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(declaration);\n continue;\n }\n\n if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n statements.push(createExportedStepStatement(declaration.id.name, declaration.init));\n continue;\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n collectInlineCreateSteps(declaration.init, seenNames, statements);\n continue;\n }\n\n declarations.push(declaration);\n }\n\n if (declarations.length > 0) {\n statements.push(\n t.exportNamedDeclaration(\n t.variableDeclaration(\n statement.declaration.kind,\n declarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n ),\n );\n }\n continue;\n }\n\n if (\n t.isExpressionStatement(statement) ||\n t.isExportNamedDeclaration(statement) ||\n t.isExportDefaultDeclaration(statement)\n ) {\n collectInlineCreateSteps(statement, seenNames, statements);\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: false,\n }).code;\n\n return transpileModule(transformedSource, filePath);\n}\n","import { readFileSync, statSync } from 'node:fs';\nimport path from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { toWorkflowType } from '../utils';\nimport type { WorkflowImportBinding } from './shared';\nimport {\n collectImportedNames,\n getCreateStepId,\n getObjectPropertyName,\n isCreateWorkflowCall,\n isIdentifierNamed,\n isStrippedExternalModule,\n isTemporalHelperModule,\n isWorkflowHelperDestructure,\n nodeReferencesName,\n parserPlugins,\n pruneUnusedTopLevelBindings,\n transpileModule,\n walk,\n} from './shared';\n\n/**\n * Builds a lookup table for imports in the entry module so we can connect a workflow\n * identifier used inside `new Mastra({ workflows })` back to its import source.\n */\nfunction getWorkflowImportBindings(program: t.Program): Map<string, WorkflowImportBinding> {\n const bindings = new Map<string, WorkflowImportBinding>();\n\n for (const statement of program.body) {\n if (!t.isImportDeclaration(statement)) {\n continue;\n }\n\n for (const specifier of statement.specifiers) {\n if (t.isImportSpecifier(specifier)) {\n bindings.set(specifier.local.name, {\n exportName: specifier.local.name,\n importedName: t.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value,\n source: statement.source.value,\n });\n continue;\n }\n\n if (t.isImportDefaultSpecifier(specifier)) {\n bindings.set(specifier.local.name, {\n exportName: specifier.local.name,\n importedName: 'default',\n source: statement.source.value,\n });\n }\n }\n }\n\n return bindings;\n}\n\n/**\n * Finds the workflow bindings referenced from `new Mastra({ workflows })`.\n *\n * We only care about the local identifiers here. The actual exported workflow names\n * are resolved later from the transformed workflow modules via the shared registry.\n */\nfunction getWorkflowEntryBindings(program: t.Program): Set<string> {\n const workflowBindings = new Set<string>();\n\n walk(program, node => {\n if (!t.isNewExpression(node) || !isIdentifierNamed(node.callee, 'Mastra')) {\n return;\n }\n\n const [config] = node.arguments;\n if (!t.isObjectExpression(config)) {\n return;\n }\n\n const workflowsProperty = config.properties.find(\n (property): property is t.ObjectProperty =>\n t.isObjectProperty(property) && getObjectPropertyName(property) === 'workflows',\n );\n\n if (!workflowsProperty || !t.isObjectExpression(workflowsProperty.value)) {\n return;\n }\n\n for (const property of workflowsProperty.value.properties) {\n if (!t.isObjectProperty(property)) {\n continue;\n }\n\n if (property.shorthand && t.isIdentifier(property.key)) {\n workflowBindings.add(property.key.name);\n continue;\n }\n\n if (t.isIdentifier(property.value)) {\n workflowBindings.add(property.value.name);\n }\n }\n });\n\n return workflowBindings;\n}\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\nconst temporalWorkflowRuntimeSource = readFileSync(new URL('./temporal-workflow-runtime.mjs', import.meta.url), 'utf8');\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 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\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): t.Expression[] {\n const argNode = (index: number): t.Node | undefined => method.args[index];\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 name = getWorkflowStepName(argNode(0), stepBindings);\n if (!name) {\n throw new Error(\n `.then() in ${workflowName} (${filePath}) must take a step identifier (inline createStep calls are not supported)`,\n );\n }\n return [t.stringLiteral(name)];\n }\n\n case 'sleep': {\n const arg = argNode(0);\n if (t.isNumericLiteral(arg)) {\n return [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 [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 [t.cloneNode(arg, true)];\n }\n if (t.isStringLiteral(arg) || t.isNumericLiteral(arg)) {\n return [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 [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 [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 [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 [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 args;\n }\n\n case 'commit':\n return [];\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 exportInline: boolean,\n stepBindings: 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 newArgs = rewriteChainMethod(method, filePath, exportName, stepBindings);\n expression = t.callExpression(t.memberExpression(expression, t.identifier(method.name)), newArgs);\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 [exportInline ? t.exportNamedDeclaration(declaration) : 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\n/**\n * Rewrites the Mastra entry file into pure re-exports after every workflow module has\n * been transformed and registered. This is why the entry rewrite lives outside the\n * loader's per-file transform path.\n */\nexport async function buildWorkflowEntryModuleFromRegistry(\n sourceText: string,\n filePath: string,\n registry: Map<string, string[]>,\n): Promise<string> {\n const ast = parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins as any,\n sourceFilename: filePath,\n });\n\n const workflowBindings = getWorkflowEntryBindings(ast.program);\n const importBindings = getWorkflowImportBindings(ast.program);\n const exportStatements: t.ExportNamedDeclaration[] = [];\n const seenExports = new Set<string>();\n\n for (const workflowBinding of workflowBindings) {\n const importedBinding = importBindings.get(workflowBinding);\n if (!importedBinding) {\n throw new Error(`Unable to find an import for workflow '${workflowBinding}' in ${filePath}`);\n }\n\n const workflowPath = resolveWorkflowPathSync(importedBinding.source, filePath);\n const exportNames = registry.get(workflowPath);\n if (!exportNames || exportNames.length === 0) {\n throw new Error(`Unable to find registered workflow exports for ${workflowPath}`);\n }\n\n for (const exportName of exportNames) {\n const exportKey = `${importedBinding.source}:${exportName}`;\n if (seenExports.has(exportKey)) {\n continue;\n }\n\n seenExports.add(exportKey);\n exportStatements.push(\n t.exportNamedDeclaration(\n null,\n [t.exportSpecifier(t.identifier(exportName), t.identifier(exportName))],\n t.stringLiteral(importedBinding.source),\n ),\n );\n }\n }\n\n return generate(t.file(t.program(exportStatements, [], 'module')), {\n sourceMaps: false,\n }).code;\n}\n\nfunction parseWorkflowModuleAst(sourceText: string, filePath: string): t.File {\n return parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins as any,\n sourceFilename: filePath,\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 generatedWorkflowNames: Set<string>;\n committedWorkflowNames: Set<string>;\n committedGeneratedWorkflowNames: Set<string>;\n inlineExportedWorkflowNames: Set<string>;\n strippedNames: Set<string>;\n stepBindings: Map<string, string>;\n workflowExports: TemporalWorkflowExport[];\n}\n\nfunction createWorkflowTransformState(program: t.Program): WorkflowTransformState {\n return {\n statements: [...createTemporalWorkflowHelperStatements()],\n workflowNames: new Set<string>(),\n generatedWorkflowNames: new Set<string>(),\n committedWorkflowNames: new Set<string>(),\n committedGeneratedWorkflowNames: new Set<string>(),\n inlineExportedWorkflowNames: new Set<string>(),\n strippedNames: new Set<string>(),\n stepBindings: collectStepBindings(program),\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 rewriteWorkflowNamedExport(statement: t.ExportNamedDeclaration, state: WorkflowTransformState): void {\n if (statement.source != null) {\n state.statements.push(statement);\n return;\n }\n\n const retainedSpecifiers = statement.specifiers.filter(specifier => {\n if (!t.isExportSpecifier(specifier) || !t.isIdentifier(specifier.local)) {\n return true;\n }\n\n if (!state.workflowNames.has(specifier.local.name)) {\n return true;\n }\n\n return getExportedName(specifier.exported) !== specifier.local.name;\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, workflowId: workflowIdValue } = getWorkflowIdMetadata(\n workflowConfig,\n declaration.id.name,\n filePath,\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 = toWorkflowType(workflowIdValue);\n\n state.generatedWorkflowNames.add(exportName);\n if (state.committedWorkflowNames.has(declaration.id.name)) {\n state.committedGeneratedWorkflowNames.add(exportName);\n }\n state.workflowExports.push({\n exportName,\n workflowId: workflowIdValue,\n });\n state.statements.push(\n ...createTemporalWorkflowStatements(\n exportName,\n workflowId,\n workflowChain.methods,\n filePath,\n state.committedWorkflowNames.has(declaration.id.name),\n t.isExportNamedDeclaration(statement) || state.inlineExportedWorkflowNames.has(declaration.id.name),\n state.stepBindings,\n ),\n );\n }\n\n if (declarations.length > 0) {\n const cloned = declarations.map(declaration => t.cloneNode(declaration, true));\n state.statements.push(\n t.isVariableDeclaration(statement)\n ? t.variableDeclaration(statement.kind, cloned)\n : t.exportNamedDeclaration(t.variableDeclaration(declarationStatement.kind, cloned)),\n );\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) && statement.declaration == null) {\n rewriteWorkflowNamedExport(statement, state);\n return;\n }\n\n if (t.isExportDefaultDeclaration(statement) && t.isIdentifier(statement.declaration)) {\n if (state.workflowNames.has(statement.declaration.name)) {\n state.statements.push(statement);\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\nfunction appendMissingWorkflowCommits(state: WorkflowTransformState): void {\n for (const workflowName of state.generatedWorkflowNames) {\n if (state.committedGeneratedWorkflowNames.has(workflowName)) {\n continue;\n }\n\n state.statements.push(\n t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(workflowName), t.identifier('commit')), []),\n ),\n );\n }\n}\n\nasync function finalizeWorkflowModule(\n filePath: string,\n state: WorkflowTransformState,\n): Promise<BuildTemporalWorkflowModuleResult> {\n const transformedSource = generate(t.file(t.program(pruneUnusedTopLevelBindings(state.statements), [], 'module')), {\n sourceMaps: false,\n }).code;\n\n return {\n code: await transpileModule(transformedSource, filePath),\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 sourceText: string,\n filePath: string,\n _options: BuildTemporalWorkflowOptions = {},\n): Promise<BuildTemporalWorkflowModuleResult> {\n const ast = parseWorkflowModuleAst(sourceText, filePath);\n const state = createWorkflowTransformState(ast.program);\n\n collectWorkflowTransformMetadata(ast.program, state);\n\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, filePath, state);\n }\n\n appendMissingWorkflowCommits(state);\n return finalizeWorkflowModule(filePath, state);\n}\n\n/**\n * Reads only the workflow imports that are referenced from the Mastra entry's\n * `workflows` config. Plain imports in the file are not enough on their own.\n */\nfunction getWorkflowImportSpecifiers(sourceText: string, filePath: string): string[] {\n const ast = parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins as any,\n sourceFilename: filePath,\n });\n\n // First find which local bindings the Mastra config actually registers as workflows,\n // then resolve those bindings back to their import sources.\n const workflowBindings = getWorkflowEntryBindings(ast.program);\n const importBindings = getWorkflowImportBindings(ast.program);\n const workflowSpecifiers: string[] = [];\n\n for (const workflowBinding of workflowBindings) {\n const importedBinding = importBindings.get(workflowBinding);\n if (!importedBinding) {\n throw new Error(`Unable to find an import for workflow '${workflowBinding}' in ${filePath}`);\n }\n\n workflowSpecifiers.push(importedBinding.source);\n }\n\n return [...new Set(workflowSpecifiers)];\n}\n\nfunction getWorkflowPathCandidates(specifier: string, importerPath: string): string[] {\n const basePath = path.resolve(path.dirname(importerPath), specifier);\n\n return [\n basePath,\n `${basePath}.ts`,\n `${basePath}.tsx`,\n `${basePath}.js`,\n `${basePath}.jsx`,\n `${basePath}.mts`,\n `${basePath}.mjs`,\n path.join(basePath, 'index.ts'),\n path.join(basePath, 'index.tsx'),\n path.join(basePath, 'index.js'),\n path.join(basePath, 'index.jsx'),\n path.join(basePath, 'index.mts'),\n path.join(basePath, 'index.mjs'),\n ];\n}\n\nexport function resolveWorkflowPathSync(specifier: string, importerPath: string): string {\n for (const candidate of getWorkflowPathCandidates(specifier, importerPath)) {\n try {\n if (statSync(candidate).isFile()) {\n return candidate;\n }\n } catch {\n // try next candidate\n }\n }\n\n throw new Error(`Unable to resolve workflow import '${specifier}' from ${importerPath}`);\n}\n\nexport async function resolveWorkflowPath(specifier: string, importerPath: string): Promise<string> {\n const { stat } = await import('node:fs/promises');\n\n for (const candidate of getWorkflowPathCandidates(specifier, importerPath)) {\n try {\n const stats = await stat(candidate);\n if (stats.isFile()) {\n return candidate;\n }\n } catch {\n // try next candidate\n }\n }\n\n throw new Error(`Unable to resolve workflow import '${specifier}' from ${importerPath}`);\n}\n\nexport function resolveWorkflowEntriesSync(sourceText: string, filePath: string): string[] {\n return getWorkflowImportSpecifiers(sourceText, filePath).map(specifier =>\n resolveWorkflowPathSync(specifier, filePath),\n );\n}\n\nexport async function resolveWorkflowEntries(sourceText: string, filePath: string): Promise<string[]> {\n return Promise.all(\n getWorkflowImportSpecifiers(sourceText, filePath).map(specifier => resolveWorkflowPath(specifier, filePath)),\n );\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport type { Compiler, Module } from 'webpack';\nimport { buildWorkflowEntryModuleFromRegistry } from './transforms/workflows';\n\nfunction getModuleSource(\n module: Module & {\n originalSource?: () => { source(): string | Buffer } | null;\n _source?: { source(): string | Buffer } | null;\n },\n): string | null {\n const source = module.originalSource?.() ?? module._source;\n if (!source) {\n return null;\n }\n\n return source.source().toString();\n}\n\nasync function writeDebugEntryModule(\n entryFile: string,\n code: string,\n debugOutputDir: string | null | undefined,\n): Promise<void> {\n if (!debugOutputDir) {\n return;\n }\n\n const baseDir = path.dirname(entryFile);\n const relativePath = path.relative(baseDir, entryFile);\n const safeRelativePath = relativePath.startsWith('..') ? path.basename(entryFile) : relativePath;\n const outputPath = path.join(debugOutputDir, 'modules', safeRelativePath);\n\n await mkdir(path.dirname(outputPath), { recursive: true });\n await writeFile(outputPath, code, 'utf-8');\n}\n\nexport class WorkflowExportRegistry {\n private readonly exportsByFile = new Map<string, string[]>();\n\n register(filePath: string, exportNames: string[]): void {\n if (exportNames.length === 0) {\n return;\n }\n\n this.exportsByFile.set(filePath, [...new Set(exportNames)]);\n }\n\n get(filePath: string): string[] | undefined {\n return this.exportsByFile.get(filePath);\n }\n\n asMap(): Map<string, string[]> {\n return this.exportsByFile;\n }\n}\n\nexport interface MastraWorkflowEntryPluginOptions {\n entryFile: string;\n registry: WorkflowExportRegistry;\n debugOutputDir?: string | null;\n}\n\nexport class MastraWorkflowEntryPlugin {\n constructor(private readonly options: MastraWorkflowEntryPluginOptions) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.compilation.tap('MastraWorkflowEntryPlugin', compilation => {\n compilation.hooks.finishModules.tapPromise('MastraWorkflowEntryPlugin', async modules => {\n const entryModule = [...modules].find(\n (\n module,\n ): module is Module & {\n resource: string;\n originalSource?: () => { source(): string | Buffer } | null;\n _source?: { source(): string | Buffer } | null;\n _ast?: unknown;\n _sourceSizes?: Map<unknown, unknown>;\n } => 'resource' in module && module.resource === this.options.entryFile,\n );\n\n if (!entryModule) {\n return;\n }\n\n const source = getModuleSource(entryModule);\n if (!source) {\n return;\n }\n\n const code = await buildWorkflowEntryModuleFromRegistry(\n source,\n this.options.entryFile,\n this.options.registry.asMap(),\n );\n\n entryModule._source = new compiler.webpack.sources.RawSource(code);\n entryModule._ast = null;\n entryModule._sourceSizes?.clear?.();\n\n await writeDebugEntryModule(this.options.entryFile, code, this.options.debugOutputDir);\n });\n });\n }\n}\n","import { readFileSync } from 'node:fs';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { SimplePlugin } from '@temporalio/plugin';\nimport type { BundleOptions, WorkerOptions } from '@temporalio/worker';\nimport type { Compiler, Configuration } from 'webpack';\nimport { buildTemporalActivitiesModule, collectTemporalActivityBindings } from './transforms/activities';\nimport { resolveWorkflowEntriesSync } from './transforms/workflows';\nimport { MastraWorkflowEntryPlugin, WorkflowExportRegistry } from './webpack-plugin';\n\nfunction getDebugOutputDir(): string {\n return path.resolve(process.cwd(), '.mastra/temporal');\n}\n\nfunction getGeneratedActivitiesModulePath(workflowPath: string): string {\n const extension = path.extname(workflowPath);\n const baseName = path.basename(workflowPath, extension);\n return path.join(path.dirname(workflowPath), `.${baseName}.temporal.activities.mjs`);\n}\n\nfunction getMastraImportPath(workflowPath: string, entryFile: string): string {\n const relativePath = path.relative(path.dirname(workflowPath), entryFile);\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;\n}\n\nclass WriteWebpackBundleDebugPlugin {\n constructor(private readonly outputDir: string) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.assetEmitted.tapPromise(\n 'MastraTemporalWriteWebpackBundleDebugPlugin',\n async (filename, { content }) => {\n const bundleDir = path.join(this.outputDir, 'bundle');\n const targetPath = path.join(bundleDir, filename);\n\n await mkdir(path.dirname(targetPath), { recursive: true });\n await writeFile(targetPath, content);\n },\n );\n }\n}\n\nexport interface MastraPluginOptions {\n /** Path to the Mastra entry file that imports workflow modules. */\n src: string;\n /** Persist transformed modules and emitted workflow bundles for debugging. */\n debug?: boolean;\n}\n\nexport class MastraPlugin extends SimplePlugin {\n private readonly src: string;\n private readonly debugOutputDir: string | null;\n private readonly compiledActivities = new Map<string, Promise<Record<string, unknown>>>();\n\n constructor({ src, debug = false }: MastraPluginOptions) {\n super({\n name: 'Mastra',\n });\n\n this.src = src.startsWith('file://') ? fileURLToPath(src) : src;\n this.debugOutputDir = debug ? getDebugOutputDir() : null;\n }\n\n private loadWorkflowActivitiesModule(workflowPath: string): Promise<Record<string, unknown>> {\n const cachedModule = this.compiledActivities.get(workflowPath);\n if (cachedModule) {\n return cachedModule;\n }\n\n const modulePromise = (async () => {\n const sourceText = await readFile(workflowPath, 'utf8');\n const generatedModulePath = getGeneratedActivitiesModulePath(workflowPath);\n const transformedModule = await buildTemporalActivitiesModule(sourceText, workflowPath, {\n mastraImportPath: getMastraImportPath(workflowPath, this.src),\n });\n\n await writeFile(generatedModulePath, transformedModule);\n\n const importedModule = (await import(pathToFileURL(generatedModulePath).href)) as Record<string, unknown>;\n return importedModule;\n })();\n\n this.compiledActivities.set(workflowPath, modulePromise);\n return modulePromise;\n }\n\n configureWorker(options: WorkerOptions): WorkerOptions {\n const entrySource = readFileSync(this.src, 'utf8');\n const workflowPaths = resolveWorkflowEntriesSync(entrySource, this.src);\n const generatedActivities = Object.assign({}, options.activities) as Record<string, unknown>;\n\n for (const workflowPath of workflowPaths) {\n const workflowSource = readFileSync(workflowPath, 'utf8');\n const activityBindings = collectTemporalActivityBindings(workflowSource, workflowPath);\n\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.loadWorkflowActivitiesModule(workflowPath);\n const activity = activityModule[binding.exportName];\n\n if (typeof activity !== 'function') {\n throw new Error(`Unable to load activity '${binding.exportName}' from ${workflowPath}`);\n }\n\n return activity(...args);\n };\n }\n }\n\n return {\n ...options,\n workflowsPath: this.src,\n activities: generatedActivities,\n };\n }\n\n configureBundler(options: BundleOptions): BundleOptions {\n const require = createRequire(import.meta.url);\n const loader = require.resolve('@mastra/temporal/webpack-loader');\n const existingWebpackConfigHook = options.webpackConfigHook;\n const registry = new WorkflowExportRegistry();\n\n const webpackConfigHook = (config: Configuration): Configuration => {\n const nextConfig = existingWebpackConfigHook ? existingWebpackConfigHook(config) : config;\n const rules = nextConfig.module?.rules ?? [];\n const plugins = [\n ...(nextConfig.plugins ?? []),\n new MastraWorkflowEntryPlugin({\n entryFile: this.src,\n registry,\n debugOutputDir: this.debugOutputDir,\n }),\n ];\n\n if (this.debugOutputDir) {\n plugins.push(new WriteWebpackBundleDebugPlugin(this.debugOutputDir));\n }\n\n return {\n ...nextConfig,\n module: {\n ...nextConfig.module,\n rules: [\n ...rules,\n {\n test: /\\.(ts|tsx|js|jsx)$/,\n exclude: /node_modules/,\n use: {\n loader,\n options: {\n entryFile: this.src,\n debugOutputDir: this.debugOutputDir,\n registry,\n },\n },\n },\n ],\n },\n plugins,\n };\n };\n\n return {\n ...options,\n webpackConfigHook,\n };\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/run.ts","../src/workflow.ts"],"names":[],"mappings":";;;AAaO,IAAM,WAAA,GAAN,cAcG,GAAA,CAA0E;AAAA,EACjE,MAAA;AAAA,EACA,SAAA;AAAA,EAEjB,WAAA,CACE,QACA,cAAA,EAIA;AACA,IAAA,KAAA,CAAM,MAAM,CAAA;AAEZ,IAAA,IAAA,CAAK,SAAS,cAAA,CAAe,MAAA;AAC7B,IAAA,IAAA,CAAK,YAAY,cAAA,CAAe,SAAA;AAAA,EAClC;AAAA,EAEA,MAAM,KAAA,CAAM,IAAA,GAA8D,EAAC,EAAG;AAC5E,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,cAAA,CAAe,KAAK,SAAS,CAAA;AACtD,IAAA,MAAM,YAAA,GAAe,MAAM,IAAA,CAAK,qBAAA,CAAsB,KAAK,YAAY,CAAA;AACvE,IAAA,MAAM,IAAA,CAAK,uBAAA,CAAwB,IAAA,CAAK,cAAqD,CAAA;AAE7F,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,MAAA,CAAO,SAAS,KAAA,CAAM,cAAA,CAAe,IAAA,CAAK,UAAU,CAAA,EAAG;AAAA,QAC/E,WAAW,IAAA,CAAK,SAAA;AAAA,QAChB,YAAY,IAAA,CAAK,KAAA;AAAA,QACjB,IAAA,EAAM;AAAA,UACJ;AAAA,YACE,SAAA,EAAW,KAAA;AAAA,YACX,YAAA;AAAA,YACA,cAAA,EAAgB,IAAA,CAAK,cAAA,GAAiB,MAAA,CAAO,WAAA,CAAY,KAAK,cAAA,CAAe,OAAA,EAAS,CAAA,GAAI,EAAC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A;AAAA,QACrB,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,aAAa,IAAA,CAAK,WAAA;AAAA,QAClB,qBAAqB,IAAA,CAAK,mBAAA;AAAA,QAC1B,gBAAgB,OAAA,EAAS,cAAA;AAAA,QACzB,aAAA,EAAe,KAAK,OAAA,CAAQ,aAAA;AAAA,QAC5B,eAAe,IAAA,CAAK,KAAA;AAAA,QACpB,cAAA,EAAgB,KAAK,OAAA,CAAQ,cAAA;AAAA,QAC7B,oBAAoB,IAAA,CAAK,UAAA;AAAA,QACzB,OAAA,EAAS;AAAA,OACX;AAAA,MACA;AAAA,QACE,QAAQ,IAAA,CAAK,cAAA;AAAA,QACb,WAAW,IAAA,CAAK;AAAA;AAClB,KACF;AAEA,IAAA,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AACxB,IAAA,OAAO,GAAA;AAAA,EACT;AACF,CAAA;AAEO,SAAS,cAAA,CAgBd,QACA,QAAA,EACA;AACA,EAAA,OAAO,IAAI,gBAAA,CAAwF,MAAA,EAAQ,QAAQ,CAAA;AACrH;AAEO,SAAS,KAAK,cAAA,EAAwC;AAC3D,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,CAQd,MAAA,KACG,cAAA,CAA8E,QAAQ,cAAc,CAAA;AAAA,IACzG;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n const result = await handle.result();\n\n return {\n status: 'success',\n input: input as TInput,\n result: result as TOutput,\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { Bundler } from '@mastra/deployer/bundler';
2
+
3
+ // src/mastra-deployer.ts
4
+ var BuildBundler = class extends Bundler {
5
+ constructor() {
6
+ super("Temporal");
7
+ this.platform = process.versions?.bun ? "neutral" : "node";
8
+ }
9
+ async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
10
+ const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);
11
+ return {
12
+ ...bundlerOptions,
13
+ externals: true,
14
+ sourcemap: true
15
+ };
16
+ }
17
+ getEnvFiles() {
18
+ return Promise.resolve([]);
19
+ }
20
+ installDependencies() {
21
+ return Promise.resolve();
22
+ }
23
+ copyPublic() {
24
+ return Promise.resolve();
25
+ }
26
+ writePackageJson() {
27
+ return Promise.resolve();
28
+ }
29
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
30
+ return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);
31
+ }
32
+ async lint(entryFile, outputDirectory, toolsPaths) {
33
+ await super.lint(entryFile, outputDirectory, toolsPaths);
34
+ }
35
+ };
36
+
37
+ export { BuildBundler };
38
+ //# sourceMappingURL=mastra-deployer-UCBGECM5.js.map
39
+ //# sourceMappingURL=mastra-deployer-UCBGECM5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mastra-deployer.ts"],"names":[],"mappings":";;;AAGO,IAAM,YAAA,GAAN,cAA2B,OAAA,CAAQ;AAAA,EACxC,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,UAAU,CAAA;AAChB,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA,CAAQ,QAAA,EAAU,GAAA,GAAM,SAAA,GAAY,MAAA;AAAA,EACtD;AAAA,EAEA,MAAgB,qBAAA,CACd,eAAA,EACA,eAAA,EACyC;AACzC,IAAA,MAAM,cAAA,GAAiB,MAAM,KAAA,CAAM,qBAAA,CAAsB,iBAAiB,eAAe,CAAA;AAEzF,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,SAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW;AAAA,KACb;AAAA,EACF;AAAA,EAEA,WAAA,GAAiC;AAC/B,IAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,CAAA;AAAA,EAC3B;AAAA,EAEU,mBAAA,GAAqC;AAC7C,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEU,UAAA,GAA4B;AACpC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,gBAAA,GAAkC;AAChC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,MAAM,MAAA,CACJ,SAAA,EACA,iBACA,EAAE,UAAA,EAAY,aAAY,EACX;AACf,IAAA,OAAO,IAAA,CAAK,QAAQ,SAAA,EAAW,SAAA,EAAW,EAAE,eAAA,EAAiB,WAAA,IAAe,UAAU,CAAA;AAAA,EACxF;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAAA,EACzD;AACF","file":"mastra-deployer-UCBGECM5.js","sourcesContent":["import type { Config } from '@mastra/core/mastra';\nimport { Bundler } from '@mastra/deployer/bundler';\n\nexport class BuildBundler extends Bundler {\n constructor() {\n super('Temporal');\n this.platform = process.versions?.bun ? 'neutral' : 'node';\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n\n return {\n ...bundlerOptions,\n externals: true,\n sourcemap: true,\n };\n }\n\n getEnvFiles(): Promise<string[]> {\n return Promise.resolve([]);\n }\n\n protected installDependencies(): Promise<void> {\n return Promise.resolve();\n }\n\n protected copyPublic(): Promise<void> {\n return Promise.resolve();\n }\n\n writePackageJson(): Promise<void> {\n return Promise.resolve();\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var bundler = require('@mastra/deployer/bundler');
4
+
5
+ // src/mastra-deployer.ts
6
+ var BuildBundler = class extends bundler.Bundler {
7
+ constructor() {
8
+ super("Temporal");
9
+ this.platform = process.versions?.bun ? "neutral" : "node";
10
+ }
11
+ async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
12
+ const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);
13
+ return {
14
+ ...bundlerOptions,
15
+ externals: true,
16
+ sourcemap: true
17
+ };
18
+ }
19
+ getEnvFiles() {
20
+ return Promise.resolve([]);
21
+ }
22
+ installDependencies() {
23
+ return Promise.resolve();
24
+ }
25
+ copyPublic() {
26
+ return Promise.resolve();
27
+ }
28
+ writePackageJson() {
29
+ return Promise.resolve();
30
+ }
31
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
32
+ return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);
33
+ }
34
+ async lint(entryFile, outputDirectory, toolsPaths) {
35
+ await super.lint(entryFile, outputDirectory, toolsPaths);
36
+ }
37
+ };
38
+
39
+ exports.BuildBundler = BuildBundler;
40
+ //# sourceMappingURL=mastra-deployer-YVT5GB5G.cjs.map
41
+ //# sourceMappingURL=mastra-deployer-YVT5GB5G.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mastra-deployer.ts"],"names":["Bundler"],"mappings":";;;;;AAGO,IAAM,YAAA,GAAN,cAA2BA,eAAA,CAAQ;AAAA,EACxC,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,UAAU,CAAA;AAChB,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA,CAAQ,QAAA,EAAU,GAAA,GAAM,SAAA,GAAY,MAAA;AAAA,EACtD;AAAA,EAEA,MAAgB,qBAAA,CACd,eAAA,EACA,eAAA,EACyC;AACzC,IAAA,MAAM,cAAA,GAAiB,MAAM,KAAA,CAAM,qBAAA,CAAsB,iBAAiB,eAAe,CAAA;AAEzF,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,SAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW;AAAA,KACb;AAAA,EACF;AAAA,EAEA,WAAA,GAAiC;AAC/B,IAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,CAAA;AAAA,EAC3B;AAAA,EAEU,mBAAA,GAAqC;AAC7C,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEU,UAAA,GAA4B;AACpC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,gBAAA,GAAkC;AAChC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,MAAM,MAAA,CACJ,SAAA,EACA,iBACA,EAAE,UAAA,EAAY,aAAY,EACX;AACf,IAAA,OAAO,IAAA,CAAK,QAAQ,SAAA,EAAW,SAAA,EAAW,EAAE,eAAA,EAAiB,WAAA,IAAe,UAAU,CAAA;AAAA,EACxF;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAAA,EACzD;AACF","file":"mastra-deployer-YVT5GB5G.cjs","sourcesContent":["import type { Config } from '@mastra/core/mastra';\nimport { Bundler } from '@mastra/deployer/bundler';\n\nexport class BuildBundler extends Bundler {\n constructor() {\n super('Temporal');\n this.platform = process.versions?.bun ? 'neutral' : 'node';\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n\n return {\n ...bundlerOptions,\n externals: true,\n sourcemap: true,\n };\n }\n\n getEnvFiles(): Promise<string[]> {\n return Promise.resolve([]);\n }\n\n protected installDependencies(): Promise<void> {\n return Promise.resolve();\n }\n\n protected copyPublic(): Promise<void> {\n return Promise.resolve();\n }\n\n writePackageJson(): Promise<void> {\n return Promise.resolve();\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { Config } from '@mastra/core/mastra';
2
+ import { Bundler } from '@mastra/deployer/bundler';
3
+ export declare class BuildBundler extends Bundler {
4
+ constructor();
5
+ protected getUserBundlerOptions(mastraEntryFile: string, outputDirectory: string): Promise<NonNullable<Config['bundler']>>;
6
+ getEnvFiles(): Promise<string[]>;
7
+ protected installDependencies(): Promise<void>;
8
+ protected copyPublic(): Promise<void>;
9
+ writePackageJson(): Promise<void>;
10
+ bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
11
+ toolsPaths: (string | string[])[];
12
+ projectRoot: string;
13
+ }): Promise<void>;
14
+ lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=mastra-deployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra-deployer.d.ts","sourceRoot":"","sources":["../src/mastra-deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,qBAAa,YAAa,SAAQ,OAAO;;cAMvB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAU1C,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIhC,SAAS,CAAC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9C,SAAS,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAIV,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzG"}
package/dist/plugin.d.ts CHANGED
@@ -1,18 +1,16 @@
1
- import { SimplePlugin } from '@temporalio/plugin';
2
- import type { BundleOptions, WorkerOptions } from '@temporalio/worker';
3
- export interface MastraPluginOptions {
4
- /** Path to the Mastra entry file that imports workflow modules. */
5
- src: string;
6
- /** Persist transformed modules and emitted workflow bundles for debugging. */
7
- debug?: boolean;
8
- }
9
- export declare class MastraPlugin extends SimplePlugin {
10
- private readonly src;
11
- private readonly debugOutputDir;
12
- private readonly compiledActivities;
13
- constructor({ src, debug }: MastraPluginOptions);
14
- private loadWorkflowActivitiesModule;
1
+ import type { WorkerOptions, WorkerPlugin } from '@temporalio/worker';
2
+ export declare class MastraPlugin implements WorkerPlugin {
3
+ #private;
4
+ name: string;
5
+ constructor();
6
+ prebuild({ entryFile, projectRoot, }: {
7
+ entryFile: string;
8
+ projectRoot?: string;
9
+ }): Promise<ReturnType<typeof this.getTemporalWorkerOptions>>;
10
+ getTemporalWorkerOptions(temporalOutputDir: string): {
11
+ workflowsPath: WorkerOptions['workflowsPath'];
12
+ activities: WorkerOptions['activities'];
13
+ };
15
14
  configureWorker(options: WorkerOptions): WorkerOptions;
16
- configureBundler(options: BundleOptions): BundleOptions;
17
15
  }
18
16
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAsCvE,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAuD;gBAE9E,EAAE,GAAG,EAAE,KAAa,EAAE,EAAE,mBAAmB;IASvD,OAAO,CAAC,4BAA4B;IAuBpC,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa;IAkCtD,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa;CAmDxD"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAsBtE,qBAAa,YAAa,YAAW,YAAY;;IAG/C,IAAI,SAAY;;IAiBV,QAAQ,CAAC,EACb,SAAS,EACT,WAA2B,GAC5B,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAoE7D,wBAAwB,CAAC,i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