@mastra/temporal 0.6.3-alpha.5 → 0.6.3-alpha.6

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.
package/dist/index.cjs CHANGED
@@ -343,5 +343,3 @@ function init(temporalParams) {
343
343
  };
344
344
  }
345
345
  exports.init = init;
346
-
347
- //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -342,5 +342,3 @@ function init(temporalParams) {
342
342
  };
343
343
  }
344
344
  export { init };
345
-
346
- //# sourceMappingURL=index.js.map
@@ -35,5 +35,3 @@ var BuildBundler = class extends Bundler {
35
35
  }
36
36
  };
37
37
  export { BuildBundler };
38
-
39
- //# sourceMappingURL=mastra-deployer-BtoNM1bq.js.map
@@ -35,5 +35,3 @@ var BuildBundler = class extends _mastra_deployer_bundler.Bundler {
35
35
  }
36
36
  };
37
37
  exports.BuildBundler = BuildBundler;
38
-
39
- //# sourceMappingURL=mastra-deployer-CxXfbT3P.cjs.map
@@ -9,5 +9,3 @@ Object.defineProperty(exports, "toWorkflowType", {
9
9
  return toWorkflowType;
10
10
  }
11
11
  });
12
-
13
- //# sourceMappingURL=utils-BVE1AkTt.cjs.map
@@ -4,5 +4,3 @@ function toWorkflowType(id) {
4
4
  return camelCased.endsWith("Workflow") ? camelCased : `${camelCased}Workflow`;
5
5
  }
6
6
  export { toWorkflowType as t };
7
-
8
- //# sourceMappingURL=utils-R6cB86BM.js.map
package/dist/worker.cjs CHANGED
@@ -1372,5 +1372,3 @@ var MastraPlugin = class {
1372
1372
  }
1373
1373
  };
1374
1374
  exports.MastraPlugin = MastraPlugin;
1375
-
1376
- //# sourceMappingURL=worker.cjs.map
package/dist/worker.js CHANGED
@@ -1348,5 +1348,3 @@ var MastraPlugin = class {
1348
1348
  }
1349
1349
  };
1350
1350
  export { MastraPlugin };
1351
-
1352
- //# sourceMappingURL=worker.js.map
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@mastra/temporal",
3
- "version": "0.6.3-alpha.5",
3
+ "version": "0.6.3-alpha.6",
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",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "!dist/**/*.d.*ts.map"
10
11
  ],
11
12
  "sideEffects": false,
12
13
  "exports": {
@@ -50,7 +51,7 @@
50
51
  "@temporalio/worker": "^1.24.0",
51
52
  "@temporalio/workflow": "^1.24.0",
52
53
  "rollup": "^4.65.0",
53
- "@mastra/deployer": "1.86.0-alpha.5"
54
+ "@mastra/deployer": "1.86.0-alpha.6"
54
55
  },
55
56
  "peerDependencies": {
56
57
  "@mastra/core": ">=1.85.1-0 <2.0.0-0",
@@ -66,7 +67,7 @@
66
67
  "@internal/lint": "0.0.151",
67
68
  "@internal/types-builder": "0.0.126",
68
69
  "@internal/workflow-test-utils": "0.0.31",
69
- "@mastra/core": "1.86.0-alpha.5"
70
+ "@mastra/core": "1.86.0-alpha.6"
70
71
  },
71
72
  "homepage": "https://mastra.ai",
72
73
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["WorkflowFailedError","ApplicationFailure","getErrorFromUnknown","Run","RequestContext","WorkflowExecutionAlreadyStartedError","toWorkflowType","delay","CancelledFailure","Workflow"],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import { setTimeout as delay } from 'node:timers/promises';\nimport { RequestContext } from '@mastra/core/di';\nimport { getErrorFromUnknown } from '@mastra/core/error';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport {\n ApplicationFailure,\n CancelledFailure,\n WorkflowExecutionAlreadyStartedError,\n WorkflowFailedError,\n} from '@temporalio/client';\nimport type { Client, WorkflowHandle } from '@temporalio/client';\nimport type { WorkflowFailureDetails } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Runs failed by a Worker that predates these details return undefined.\nfunction toFailureDetails(error: unknown): WorkflowFailureDetails | undefined {\n if (!(error instanceof WorkflowFailedError) || !(error.cause instanceof ApplicationFailure)) {\n return undefined;\n }\n\n const details = error.cause.details?.[0] as Partial<WorkflowFailureDetails> | undefined;\n return details?.error && details.steps ? (details as WorkflowFailureDetails) : undefined;\n}\n\nfunction toError(error: WorkflowFailureDetails['error']): Error {\n return getErrorFromUnknown(error, { serializeStack: false });\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalWorkflowStatusUnknownError extends Error {\n constructor(runId: string, cause: unknown, afterResumeSignal = false) {\n super(\n afterResumeSignal\n ? `Unable to determine Temporal workflow status for run \"${runId}\" after sending a resume signal. The signal may have been delivered; do not retry resume() blindly.`\n : `Unable to determine Temporal workflow status for run \"${runId}\".`,\n { cause },\n );\n this.name = 'TemporalWorkflowStatusUnknownError';\n }\n}\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 const requestContext = (args.requestContext ?? new RequestContext()) as RequestContext;\n await this.invokeStartCallback(input, initialState, requestContext);\n\n let handle: WorkflowHandle;\n try {\n handle = await this.dispatch(args, input, initialState, requestContext);\n } catch (error) {\n const result = this.failedResult(input, initialState, error);\n if (!(error instanceof WorkflowExecutionAlreadyStartedError)) {\n await this.invokeLifecycleCallbacks(result, requestContext);\n }\n return result;\n }\n\n return this.awaitResultOrSuspended(handle, input, initialState, requestContext);\n }\n\n private dispatch(\n args: TemporalRunStartArgs<TState, TInput, TRequestContext>,\n input: unknown,\n initialState: unknown,\n requestContext: RequestContext,\n ): Promise<WorkflowHandle> {\n return 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: Object.fromEntries(requestContext.entries()),\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n validateInputs: this.validateInputs,\n },\n ],\n });\n }\n\n private async awaitResult(\n handle: WorkflowHandle,\n input: unknown,\n initialState: unknown,\n requestContext: RequestContext,\n ): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>> {\n const result = await this.resolveResult(handle, input, initialState);\n await this.invokeLifecycleCallbacks(result, requestContext);\n return result;\n }\n\n private async queryStatus(handle: WorkflowHandle, afterResumeSignal = false): Promise<unknown> {\n if (typeof handle.query !== 'function') {\n return undefined;\n }\n\n try {\n return await handle.query('mastra.status');\n } catch (error) {\n throw new TemporalWorkflowStatusUnknownError(this.runId, error, afterResumeSignal);\n }\n }\n\n private async awaitResultOrSuspended(\n handle: WorkflowHandle,\n input: unknown,\n initialState: unknown,\n requestContext: RequestContext,\n previousSuspension?: { stepId: string; suspendedAt?: number },\n afterResumeSignal = false,\n ): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>> {\n const terminal = this.resolveResult(handle, input, initialState);\n\n while (true) {\n const result = await Promise.race([\n terminal.then(result => ({ type: 'terminal' as const, result })),\n delay(100).then(() => ({ type: 'poll' as const })),\n ]);\n\n if (result.type === 'terminal') {\n await this.invokeLifecycleCallbacks(result.result, requestContext);\n return result.result;\n }\n\n const status = await this.queryStatus(handle, afterResumeSignal);\n if (isSuspendedWorkflowResult(status)) {\n const previousStep = previousSuspension ? status.steps[previousSuspension.stepId] : undefined;\n const isPreviousSuspension =\n previousSuspension !== undefined &&\n isSuspendedStepResult(previousStep) &&\n previousStep.suspendedAt === previousSuspension.suspendedAt;\n if (isPreviousSuspension) {\n continue;\n }\n\n const suspended = {\n ...status,\n steps: toStepResults(status.input, status.steps),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n await this.invokeLifecycleCallbacks(suspended, requestContext);\n return suspended;\n }\n }\n }\n\n private async resolveResult(handle: WorkflowHandle, input: unknown, initialState: unknown) {\n try {\n // The generated Temporal workflow returns the execution result ({ status, result, state, steps }).\n const output = (await handle.result()) as WorkflowResult<TState, TInput, TOutput, TSteps>;\n return {\n ...output,\n ...(input !== undefined && { input: input as TInput }),\n steps: toStepResults(input !== undefined ? input : output.input, output.steps),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n if (error instanceof WorkflowFailedError && error.cause instanceof CancelledFailure) {\n return {\n status: 'canceled',\n input: input as TInput,\n state: initialState,\n steps: {},\n } as unknown as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n\n const failure = toFailureDetails(error);\n\n if (failure) {\n const steps = toStepResults(input, failure.steps);\n return (\n failure.tripwire\n ? { status: 'tripwire', input, tripwire: failure.tripwire, state: initialState, steps }\n : { status: 'failed', input, error: toError(failure.error), state: initialState, steps }\n ) as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n\n return this.failedResult(input, initialState, error);\n }\n }\n\n private failedResult(input: unknown, initialState: unknown, error: unknown) {\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: toStepResults(input, {}),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n\n // Lifecycle hooks are closures that cannot run inside the deterministic Temporal workflow\n // sandbox, so they run here in the process that started the run, using core hook semantics.\n private invokeStartCallback(input: unknown, initialState: unknown, requestContext: RequestContext) {\n return this.executionEngine.invokeStartCallback({\n runId: this.runId,\n workflowId: this.workflowId,\n resourceId: this.resourceId,\n getInitData: () => input,\n requestContext,\n state: (initialState ?? {}) as Record<string, any>,\n });\n }\n\n private invokeLifecycleCallbacks(\n result: WorkflowResult<TState, TInput, TOutput, TSteps>,\n requestContext: RequestContext,\n ) {\n return this.executionEngine.invokeLifecycleCallbacks({\n status: result.status,\n result: result.status === 'success' ? result.result : undefined,\n error: result.status === 'failed' ? result.error : undefined,\n tripwire: result.status === 'tripwire' ? result.tripwire : undefined,\n steps: result.steps,\n runId: this.runId,\n workflowId: this.workflowId,\n resourceId: this.resourceId,\n input: result.input,\n requestContext,\n state: (result.state ?? {}) as Record<string, any>,\n });\n }\n\n private async resumePayload(params: {\n step?:\n | Step<string, any, any, any, any, any, TemporalEngineType, any>\n | Step<string, any, any, any, any, any, TemporalEngineType, any>[]\n | string\n | string[];\n label?: string;\n resumeData?: unknown;\n }) {\n const step = Array.isArray(params.step) ? params.step.at(-1) : params.step;\n const stepId = typeof step === 'string' ? step : step?.id;\n const resumeData = await this._validateResumeData(\n params.resumeData,\n stepId ? this.workflowSteps[stepId] : undefined,\n );\n\n return {\n ...(stepId !== undefined && { step: stepId }),\n ...(params.label !== undefined && { label: params.label }),\n resumeData,\n };\n }\n\n async cancel() {\n await this.client.workflow.getHandle(this.runId).cancel();\n await super.cancel();\n }\n\n private unsupported(method: string): never {\n throw new Error(`@mastra/temporal does not support ${method}() yet. Use start() or startAsync() instead.`);\n }\n\n override stream(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['stream']>\n ): never {\n return this.unsupported('stream');\n }\n\n override streamLegacy(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['streamLegacy']>\n ): never {\n return this.unsupported('streamLegacy');\n }\n\n override resumeStream(..._args: unknown[]): never {\n return this.unsupported('resumeStream');\n }\n\n override async resume<TResume>(params: {\n resumeData?: TResume;\n step?:\n | Step<string, any, any, any, TResume, any, TemporalEngineType, any>\n | [\n ...Step<string, any, any, any, any, any, TemporalEngineType, any>[],\n Step<string, any, any, any, TResume, any, TemporalEngineType, any>,\n ]\n | string\n | string[];\n label?: string;\n requestContext?: RequestContext<TRequestContext>;\n retryCount?: number;\n tracingOptions?: any;\n outputWriter?: any;\n outputOptions?: {\n includeState?: boolean;\n includeResumeLabels?: boolean;\n };\n forEachIndex?: number;\n perStep?: boolean;\n actor?: any;\n }) {\n await this._validateRequestContext(params.requestContext as RequestContext<unknown> | undefined);\n const requestContext = (params.requestContext ?? new RequestContext()) as RequestContext;\n const handle = this.client.workflow.getHandle(this.runId);\n const payload = await this.resumePayload(params);\n const status = await this.queryStatus(handle);\n const stepId = isSuspendedWorkflowResult(status)\n ? (payload.step ??\n (payload.label ? status.resumeLabels?.[payload.label]?.stepId : undefined) ??\n (status.suspended?.length === 1 && status.suspended[0]?.length === 1 ? status.suspended[0][0] : undefined))\n : undefined;\n const previousStep = stepId && isSuspendedWorkflowResult(status) ? status.steps[stepId] : undefined;\n const previousSuspension =\n stepId && isSuspendedStepResult(previousStep) ? { stepId, suspendedAt: previousStep.suspendedAt } : undefined;\n await handle.signal('mastra.resume', payload);\n return this.awaitResultOrSuspended(handle, undefined, undefined, requestContext, previousSuspension, true);\n }\n\n override async resumeAsync<TResume>(params: {\n resumeData?: TResume;\n step?:\n | Step<string, any, any, any, TResume, any, TemporalEngineType, any>\n | [\n ...Step<string, any, any, any, any, any, TemporalEngineType, any>[],\n Step<string, any, any, any, TResume, any, TemporalEngineType, any>,\n ]\n | string\n | string[];\n label?: string;\n requestContext?: RequestContext<TRequestContext>;\n retryCount?: number;\n tracingOptions?: any;\n outputWriter?: any;\n outputOptions?: {\n includeState?: boolean;\n includeResumeLabels?: boolean;\n };\n forEachIndex?: number;\n perStep?: boolean;\n actor?: any;\n }) {\n const handle = this.client.workflow.getHandle(this.runId);\n await handle.signal('mastra.resume', await this.resumePayload(params));\n return { runId: this.runId };\n }\n\n override restart(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['restart']>\n ): never {\n return this.unsupported('restart');\n }\n\n override timeTravel(..._args: unknown[]): never {\n return this.unsupported('timeTravel');\n }\n\n override timeTravelStream(..._args: unknown[]): never {\n return this.unsupported('timeTravelStream');\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 const requestContext = (args.requestContext ?? new RequestContext()) as RequestContext;\n await this.invokeStartCallback(input, initialState, requestContext);\n\n let handle: WorkflowHandle;\n try {\n handle = await this.dispatch(args, input, initialState, requestContext);\n } catch (error) {\n if (!(error instanceof WorkflowExecutionAlreadyStartedError)) {\n await this.invokeLifecycleCallbacks(this.failedResult(input, initialState, error), requestContext);\n }\n throw error;\n }\n\n const { onFinish, onError } = this.executionEngine.options;\n if (onFinish || onError) {\n // Like core startAsync(), terminal hooks fire in the background from this process.\n // They are best-effort: if this process exits before the run ends, they do not fire.\n void this.awaitResult(handle, input, initialState, requestContext);\n }\n\n return { runId: this.runId };\n }\n}\n\nfunction isSuspendedWorkflowResult(value: unknown): value is {\n status: 'suspended';\n input?: unknown;\n steps: Record<string, unknown>;\n suspended?: string[][];\n resumeLabels?: Record<string, { stepId: string }>;\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { status?: unknown }).status === 'suspended' &&\n typeof (value as { steps?: unknown }).steps === 'object' &&\n (value as { steps?: unknown }).steps !== null\n );\n}\n\nfunction isSuspendedStepResult(value: unknown): value is { status: 'suspended'; suspendedAt?: number } {\n return typeof value === 'object' && value !== null && (value as { status?: unknown }).status === 'suspended';\n}\n\n// Failed step records arrive in the failure details of a failed run, not in handle.result().\nfunction normalizeStepResult(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return { status: 'success', output: value, startedAt: 0, endedAt: 0 };\n }\n\n const record = value as Record<string, unknown>;\n if (record.__temporalStepResult === true && record.status === 'failed') {\n return {\n status: 'failed',\n payload: record.payload,\n error: toError(record.error as WorkflowFailureDetails['error']),\n ...(record.tripwire !== undefined && { tripwire: record.tripwire }),\n startedAt: record.startedAt,\n endedAt: record.endedAt,\n };\n }\n\n if (record.__temporalStepResult === true && record.status === 'suspended' && typeof record.suspendedAt === 'number') {\n return {\n status: 'suspended',\n payload: record.payload,\n suspendPayload: record.suspendPayload,\n suspendedAt: record.suspendedAt,\n };\n }\n\n if (\n record.__temporalStepResult === true &&\n record.status === 'success' &&\n typeof record.startedAt === 'number' &&\n typeof record.endedAt === 'number'\n ) {\n return {\n status: 'success',\n payload: record.payload,\n output: record.output,\n ...(record.suspendPayload !== undefined && { suspendPayload: record.suspendPayload }),\n ...(record.resumeData !== undefined && { resumeData: record.resumeData }),\n startedAt: record.startedAt,\n endedAt: record.endedAt,\n };\n }\n\n return { status: 'success', output: value, startedAt: 0, endedAt: 0 };\n}\n\n// Like a local run, the step records start with the workflow input under `input`.\nfunction toStepResults<T>(input: unknown, steps: T): T {\n return { input, ...normalizeStepResults(steps) } as T;\n}\n\n// Workers built before step results used the core StepResult shape return raw step outputs.\nfunction normalizeStepResults<T>(steps: T): T {\n if (!steps || typeof steps !== 'object') {\n return {} as T;\n }\n return Object.fromEntries(Object.entries(steps).map(([id, value]) => [id, normalizeStepResult(value)])) as T;\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { ActivityOptions } from '@temporalio/workflow';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n retry?: ActivityOptions['retry'];\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"],"mappings":";;;;;;;;AAiBA,SAAS,iBAAiB,OAAoD;CAC5E,IAAI,EAAE,iBAAiBA,mBAAAA,wBAAwB,EAAE,MAAM,iBAAiBC,mBAAAA,qBACtE;CAGF,MAAM,UAAU,MAAM,MAAM,UAAU;CACtC,OAAO,SAAS,SAAS,QAAQ,QAAS,UAAqC,KAAA;AACjF;AAEA,SAAS,QAAQ,OAA+C;CAC9D,QAAA,GAAOC,mBAAAA,oBAAAA,CAAoB,OAAO,EAAE,gBAAgB,MAAM,CAAC;AAC7D;AAQA,IAAa,qCAAb,cAAwD,MAAM;CAC5D,YAAY,OAAe,OAAgB,oBAAoB,OAAO;EACpE,MACE,oBACI,yDAAyD,MAAM,uGAC/D,yDAAyD,MAAM,KACnE,EAAE,MAAM,CACV;EACA,KAAK,OAAO;CACd;AACF;AAEA,IAAa,cAAb,cAcUC,uBAAAA,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA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MAAM,YAAY,CAAC;AAClC,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["delay"],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import { setTimeout as delay } from 'node:timers/promises';\nimport { RequestContext } from '@mastra/core/di';\nimport { getErrorFromUnknown } from '@mastra/core/error';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport {\n ApplicationFailure,\n CancelledFailure,\n WorkflowExecutionAlreadyStartedError,\n WorkflowFailedError,\n} from '@temporalio/client';\nimport type { Client, WorkflowHandle } from '@temporalio/client';\nimport type { WorkflowFailureDetails } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Runs failed by a Worker that predates these details return undefined.\nfunction toFailureDetails(error: unknown): WorkflowFailureDetails | undefined {\n if (!(error instanceof WorkflowFailedError) || !(error.cause instanceof ApplicationFailure)) {\n return undefined;\n }\n\n const details = error.cause.details?.[0] as Partial<WorkflowFailureDetails> | undefined;\n return details?.error && details.steps ? (details as WorkflowFailureDetails) : undefined;\n}\n\nfunction toError(error: WorkflowFailureDetails['error']): Error {\n return getErrorFromUnknown(error, { serializeStack: false });\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalWorkflowStatusUnknownError extends Error {\n constructor(runId: string, cause: unknown, afterResumeSignal = false) {\n super(\n afterResumeSignal\n ? `Unable to determine Temporal workflow status for run \"${runId}\" after sending a resume signal. The signal may have been delivered; do not retry resume() blindly.`\n : `Unable to determine Temporal workflow status for run \"${runId}\".`,\n { cause },\n );\n this.name = 'TemporalWorkflowStatusUnknownError';\n }\n}\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 const requestContext = (args.requestContext ?? new RequestContext()) as RequestContext;\n await this.invokeStartCallback(input, initialState, requestContext);\n\n let handle: WorkflowHandle;\n try {\n handle = await this.dispatch(args, input, initialState, requestContext);\n } catch (error) {\n const result = this.failedResult(input, initialState, error);\n if (!(error instanceof WorkflowExecutionAlreadyStartedError)) {\n await this.invokeLifecycleCallbacks(result, requestContext);\n }\n return result;\n }\n\n return this.awaitResultOrSuspended(handle, input, initialState, requestContext);\n }\n\n private dispatch(\n args: TemporalRunStartArgs<TState, TInput, TRequestContext>,\n input: unknown,\n initialState: unknown,\n requestContext: RequestContext,\n ): Promise<WorkflowHandle> {\n return 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: Object.fromEntries(requestContext.entries()),\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n validateInputs: this.validateInputs,\n },\n ],\n });\n }\n\n private async awaitResult(\n handle: WorkflowHandle,\n input: unknown,\n initialState: unknown,\n requestContext: RequestContext,\n ): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>> {\n const result = await this.resolveResult(handle, input, initialState);\n await this.invokeLifecycleCallbacks(result, requestContext);\n return result;\n }\n\n private async queryStatus(handle: WorkflowHandle, afterResumeSignal = false): Promise<unknown> {\n if (typeof handle.query !== 'function') {\n return undefined;\n }\n\n try {\n return await handle.query('mastra.status');\n } catch (error) {\n throw new TemporalWorkflowStatusUnknownError(this.runId, error, afterResumeSignal);\n }\n }\n\n private async awaitResultOrSuspended(\n handle: WorkflowHandle,\n input: unknown,\n initialState: unknown,\n requestContext: RequestContext,\n previousSuspension?: { stepId: string; suspendedAt?: number },\n afterResumeSignal = false,\n ): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>> {\n const terminal = this.resolveResult(handle, input, initialState);\n\n while (true) {\n const result = await Promise.race([\n terminal.then(result => ({ type: 'terminal' as const, result })),\n delay(100).then(() => ({ type: 'poll' as const })),\n ]);\n\n if (result.type === 'terminal') {\n await this.invokeLifecycleCallbacks(result.result, requestContext);\n return result.result;\n }\n\n const status = await this.queryStatus(handle, afterResumeSignal);\n if (isSuspendedWorkflowResult(status)) {\n const previousStep = previousSuspension ? status.steps[previousSuspension.stepId] : undefined;\n const isPreviousSuspension =\n previousSuspension !== undefined &&\n isSuspendedStepResult(previousStep) &&\n previousStep.suspendedAt === previousSuspension.suspendedAt;\n if (isPreviousSuspension) {\n continue;\n }\n\n const suspended = {\n ...status,\n steps: toStepResults(status.input, status.steps),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n await this.invokeLifecycleCallbacks(suspended, requestContext);\n return suspended;\n }\n }\n }\n\n private async resolveResult(handle: WorkflowHandle, input: unknown, initialState: unknown) {\n try {\n // The generated Temporal workflow returns the execution result ({ status, result, state, steps }).\n const output = (await handle.result()) as WorkflowResult<TState, TInput, TOutput, TSteps>;\n return {\n ...output,\n ...(input !== undefined && { input: input as TInput }),\n steps: toStepResults(input !== undefined ? input : output.input, output.steps),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n if (error instanceof WorkflowFailedError && error.cause instanceof CancelledFailure) {\n return {\n status: 'canceled',\n input: input as TInput,\n state: initialState,\n steps: {},\n } as unknown as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n\n const failure = toFailureDetails(error);\n\n if (failure) {\n const steps = toStepResults(input, failure.steps);\n return (\n failure.tripwire\n ? { status: 'tripwire', input, tripwire: failure.tripwire, state: initialState, steps }\n : { status: 'failed', input, error: toError(failure.error), state: initialState, steps }\n ) as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n\n return this.failedResult(input, initialState, error);\n }\n }\n\n private failedResult(input: unknown, initialState: unknown, error: unknown) {\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: toStepResults(input, {}),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n\n // Lifecycle hooks are closures that cannot run inside the deterministic Temporal workflow\n // sandbox, so they run here in the process that started the run, using core hook semantics.\n private invokeStartCallback(input: unknown, initialState: unknown, requestContext: RequestContext) {\n return this.executionEngine.invokeStartCallback({\n runId: this.runId,\n workflowId: this.workflowId,\n resourceId: this.resourceId,\n getInitData: () => input,\n requestContext,\n state: (initialState ?? {}) as Record<string, any>,\n });\n }\n\n private invokeLifecycleCallbacks(\n result: WorkflowResult<TState, TInput, TOutput, TSteps>,\n requestContext: RequestContext,\n ) {\n return this.executionEngine.invokeLifecycleCallbacks({\n status: result.status,\n result: result.status === 'success' ? result.result : undefined,\n error: result.status === 'failed' ? result.error : undefined,\n tripwire: result.status === 'tripwire' ? result.tripwire : undefined,\n steps: result.steps,\n runId: this.runId,\n workflowId: this.workflowId,\n resourceId: this.resourceId,\n input: result.input,\n requestContext,\n state: (result.state ?? {}) as Record<string, any>,\n });\n }\n\n private async resumePayload(params: {\n step?:\n | Step<string, any, any, any, any, any, TemporalEngineType, any>\n | Step<string, any, any, any, any, any, TemporalEngineType, any>[]\n | string\n | string[];\n label?: string;\n resumeData?: unknown;\n }) {\n const step = Array.isArray(params.step) ? params.step.at(-1) : params.step;\n const stepId = typeof step === 'string' ? step : step?.id;\n const resumeData = await this._validateResumeData(\n params.resumeData,\n stepId ? this.workflowSteps[stepId] : undefined,\n );\n\n return {\n ...(stepId !== undefined && { step: stepId }),\n ...(params.label !== undefined && { label: params.label }),\n resumeData,\n };\n }\n\n async cancel() {\n await this.client.workflow.getHandle(this.runId).cancel();\n await super.cancel();\n }\n\n private unsupported(method: string): never {\n throw new Error(`@mastra/temporal does not support ${method}() yet. Use start() or startAsync() instead.`);\n }\n\n override stream(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['stream']>\n ): never {\n return this.unsupported('stream');\n }\n\n override streamLegacy(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['streamLegacy']>\n ): never {\n return this.unsupported('streamLegacy');\n }\n\n override resumeStream(..._args: unknown[]): never {\n return this.unsupported('resumeStream');\n }\n\n override async resume<TResume>(params: {\n resumeData?: TResume;\n step?:\n | Step<string, any, any, any, TResume, any, TemporalEngineType, any>\n | [\n ...Step<string, any, any, any, any, any, TemporalEngineType, any>[],\n Step<string, any, any, any, TResume, any, TemporalEngineType, any>,\n ]\n | string\n | string[];\n label?: string;\n requestContext?: RequestContext<TRequestContext>;\n retryCount?: number;\n tracingOptions?: any;\n outputWriter?: any;\n outputOptions?: {\n includeState?: boolean;\n includeResumeLabels?: boolean;\n };\n forEachIndex?: number;\n perStep?: boolean;\n actor?: any;\n }) {\n await this._validateRequestContext(params.requestContext as RequestContext<unknown> | undefined);\n const requestContext = (params.requestContext ?? new RequestContext()) as RequestContext;\n const handle = this.client.workflow.getHandle(this.runId);\n const payload = await this.resumePayload(params);\n const status = await this.queryStatus(handle);\n const stepId = isSuspendedWorkflowResult(status)\n ? (payload.step ??\n (payload.label ? status.resumeLabels?.[payload.label]?.stepId : undefined) ??\n (status.suspended?.length === 1 && status.suspended[0]?.length === 1 ? status.suspended[0][0] : undefined))\n : undefined;\n const previousStep = stepId && isSuspendedWorkflowResult(status) ? status.steps[stepId] : undefined;\n const previousSuspension =\n stepId && isSuspendedStepResult(previousStep) ? { stepId, suspendedAt: previousStep.suspendedAt } : undefined;\n await handle.signal('mastra.resume', payload);\n return this.awaitResultOrSuspended(handle, undefined, undefined, requestContext, previousSuspension, true);\n }\n\n override async resumeAsync<TResume>(params: {\n resumeData?: TResume;\n step?:\n | Step<string, any, any, any, TResume, any, TemporalEngineType, any>\n | [\n ...Step<string, any, any, any, any, any, TemporalEngineType, any>[],\n Step<string, any, any, any, TResume, any, TemporalEngineType, any>,\n ]\n | string\n | string[];\n label?: string;\n requestContext?: RequestContext<TRequestContext>;\n retryCount?: number;\n tracingOptions?: any;\n outputWriter?: any;\n outputOptions?: {\n includeState?: boolean;\n includeResumeLabels?: boolean;\n };\n forEachIndex?: number;\n perStep?: boolean;\n actor?: any;\n }) {\n const handle = this.client.workflow.getHandle(this.runId);\n await handle.signal('mastra.resume', await this.resumePayload(params));\n return { runId: this.runId };\n }\n\n override restart(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['restart']>\n ): never {\n return this.unsupported('restart');\n }\n\n override timeTravel(..._args: unknown[]): never {\n return this.unsupported('timeTravel');\n }\n\n override timeTravelStream(..._args: unknown[]): never {\n return this.unsupported('timeTravelStream');\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 const requestContext = (args.requestContext ?? new RequestContext()) as RequestContext;\n await this.invokeStartCallback(input, initialState, requestContext);\n\n let handle: WorkflowHandle;\n try {\n handle = await this.dispatch(args, input, initialState, requestContext);\n } catch (error) {\n if (!(error instanceof WorkflowExecutionAlreadyStartedError)) {\n await this.invokeLifecycleCallbacks(this.failedResult(input, initialState, error), requestContext);\n }\n throw error;\n }\n\n const { onFinish, onError } = this.executionEngine.options;\n if (onFinish || onError) {\n // Like core startAsync(), terminal hooks fire in the background from this process.\n // They are best-effort: if this process exits before the run ends, they do not fire.\n void this.awaitResult(handle, input, initialState, requestContext);\n }\n\n return { runId: this.runId };\n }\n}\n\nfunction isSuspendedWorkflowResult(value: unknown): value is {\n status: 'suspended';\n input?: unknown;\n steps: Record<string, unknown>;\n suspended?: string[][];\n resumeLabels?: Record<string, { stepId: string }>;\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { status?: unknown }).status === 'suspended' &&\n typeof (value as { steps?: unknown }).steps === 'object' &&\n (value as { steps?: unknown }).steps !== null\n );\n}\n\nfunction isSuspendedStepResult(value: unknown): value is { status: 'suspended'; suspendedAt?: number } {\n return typeof value === 'object' && value !== null && (value as { status?: unknown }).status === 'suspended';\n}\n\n// Failed step records arrive in the failure details of a failed run, not in handle.result().\nfunction normalizeStepResult(value: unknown): unknown {\n if (typeof value !== 'object' || value === null) {\n return { status: 'success', output: value, startedAt: 0, endedAt: 0 };\n }\n\n const record = value as Record<string, unknown>;\n if (record.__temporalStepResult === true && record.status === 'failed') {\n return {\n status: 'failed',\n payload: record.payload,\n error: toError(record.error as WorkflowFailureDetails['error']),\n ...(record.tripwire !== undefined && { tripwire: record.tripwire }),\n startedAt: record.startedAt,\n endedAt: record.endedAt,\n };\n }\n\n if (record.__temporalStepResult === true && record.status === 'suspended' && typeof record.suspendedAt === 'number') {\n return {\n status: 'suspended',\n payload: record.payload,\n suspendPayload: record.suspendPayload,\n suspendedAt: record.suspendedAt,\n };\n }\n\n if (\n record.__temporalStepResult === true &&\n record.status === 'success' &&\n typeof record.startedAt === 'number' &&\n typeof record.endedAt === 'number'\n ) {\n return {\n status: 'success',\n payload: record.payload,\n output: record.output,\n ...(record.suspendPayload !== undefined && { suspendPayload: record.suspendPayload }),\n ...(record.resumeData !== undefined && { resumeData: record.resumeData }),\n startedAt: record.startedAt,\n endedAt: record.endedAt,\n };\n }\n\n return { status: 'success', output: value, startedAt: 0, endedAt: 0 };\n}\n\n// Like a local run, the step records start with the workflow input under `input`.\nfunction toStepResults<T>(input: unknown, steps: T): T {\n return { input, ...normalizeStepResults(steps) } as T;\n}\n\n// Workers built before step results used the core StepResult shape return raw step outputs.\nfunction normalizeStepResults<T>(steps: T): T {\n if (!steps || typeof steps !== 'object') {\n return {} as T;\n }\n return Object.fromEntries(Object.entries(steps).map(([id, value]) => [id, normalizeStepResult(value)])) as T;\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { ActivityOptions } from '@temporalio/workflow';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n retry?: ActivityOptions['retry'];\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"],"mappings":";;;;;;;AAiBA,SAAS,iBAAiB,OAAoD;CAC5E,IAAI,EAAE,i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,CACF;EAEA,KAAK,KAAK,IAAI,OAAO,GAAG;EACxB,OAAO;CACT;AACF;AAEA,SAAgB,eAgBd,QACA,UACA;CACA,OAAO,IAAI,iBAAwF,QAAQ,QAAQ;AACrH;AAEA,SAAgB,KAAK,gBAAwC;CAC3D,OAAO;EACL,iBAQE,WACG,eAA8E,QAAQ,cAAc;EACzG;CACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mastra-deployer-BtoNM1bq.js","names":[],"sources":["../src/mastra-deployer.ts"],"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"],"mappings":";;AAGA,IAAa,eAAb,cAAkC,QAAQ;CACxC,cAAc;EACZ,MAAM,UAAU;EAChB,KAAK,WAAW,QAAQ,UAAU,MAAM,YAAY;CACtD;CAEA,MAAgB,sBACd,iBACA,iBACyC;EAGzC,OAAO;GACL,GAAG,MAHwB,MAAM,sBAAsB,iBAAiB,eAAe;GAIvF,WAAW;GACX,WAAW;EACb;CACF;CAEA,cAAiC;EAC/B,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;CAEA,sBAA+C;EAC7C,OAAO,QAAQ,QAAQ;CACzB;CAEA,aAAsC;EACpC,OAAO,QAAQ,QAAQ;CACzB;CAEA,mBAAkC;EAChC,OAAO,QAAQ,QAAQ;CACzB;CAEA,MAAM,OACJ,WACA,iBACA,EAAE,YAAY,eACC;EACf,OAAO,KAAK,QAAQ,WAAW,WAAW;GAAE;GAAiB;EAAY,GAAG,UAAU;CACxF;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;CACzD;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mastra-deployer-CxXfbT3P.cjs","names":["Bundler"],"sources":["../src/mastra-deployer.ts"],"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"],"mappings":";;AAGA,IAAa,eAAb,cAAkCA,yBAAAA,QAAQ;CACxC,cAAc;EACZ,MAAM,UAAU;EAChB,KAAK,WAAW,QAAQ,UAAU,MAAM,YAAY;CACtD;CAEA,MAAgB,sBACd,iBACA,iBACyC;EAGzC,OAAO;GACL,GAAG,MAHwB,MAAM,sBAAsB,iBAAiB,eAAe;GAIvF,WAAW;GACX,WAAW;EACb;CACF;CAEA,cAAiC;EAC/B,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;CAEA,sBAA+C;EAC7C,OAAO,QAAQ,QAAQ;CACzB;CAEA,aAAsC;EACpC,OAAO,QAAQ,QAAQ;CACzB;CAEA,mBAAkC;EAChC,OAAO,QAAQ,QAAQ;CACzB;CAEA,MAAM,OACJ,WACA,iBACA,EAAE,YAAY,eACC;EACf,OAAO,KAAK,QAAQ,WAAW,WAAW;GAAE;GAAiB;EAAY,GAAG,UAAU;CACxF;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;CACzD;AACF"}
@@ -1 +0,0 @@
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;IACvC,cAGC;IAED,UAAgB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAQzC;IAED,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAE/B;IAED,SAAS,CAA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K,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,EAAE,KAAK,KAAA,gBAgMtD;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;EAuJjD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/transforms/workflows.ts"],"names":[],"mappings":"AA6lBA,MAAM,WAAW,4BAA4B;CAE5C;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC;AAgVD;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAsDjC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,GAAG,CAAC;CACX,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-BVE1AkTt.cjs","names":[],"sources":["../src/utils.ts"],"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"],"mappings":";AAAA,SAAgB,eAAe,IAAY;CACzC,MAAM,aAAa,GAAG,QAAQ,wBAAwB,GAAG,SAAiB,KAAK,YAAY,CAAC;CAC5F,OAAO,WAAW,SAAS,UAAU,IAAI,aAAa,GAAG,WAAW;AACtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-R6cB86BM.js","names":[],"sources":["../src/utils.ts"],"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"],"mappings":";AAAA,SAAgB,eAAe,IAAY;CACzC,MAAM,aAAa,GAAG,QAAQ,wBAAwB,GAAG,SAAiB,KAAK,YAAY,CAAC;CAC5F,OAAO,WAAW,SAAS,UAAU,IAAI,aAAa,GAAG,WAAW;AACtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,UAGxC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.cjs","names":["readFileSync","parse","t","parseWorkflowChain","t","parse","generate","basename","join","t","readFileSync","parse","toWorkflowType","builtinModules","generate","basename","join","getErrorFromUnknown","ApplicationFailure","CancelledFailure","validateStepInput","toStandardSchema","validateStepRequestContext","RequestContext","MastraError","fileURLToPath","writeFile","readFileSync","pathToFileURL"],"sources":["../src/transforms/shared.ts","../src/transforms/activities.ts","../src/transforms/workflows.ts","../src/plugin.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { parse } from '@babel/parser';\nimport type { ParserPlugin } from '@babel/parser';\nimport * as t from '@babel/types';\n\nexport const parserPlugins = ['typescript', 'jsx', 'decorators-legacy'] satisfies ParserPlugin[];\nexport function parseModule(filePath: string, sourceText?: string): t.File {\n if (!sourceText) {\n sourceText = readFileSync(filePath, 'utf8');\n }\n\n return parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins,\n sourceFilename: filePath,\n });\n}\n\nexport function isIdentifierNamed(node: t.Node, name: string): boolean {\n return t.isIdentifier(node) && node.name === name;\n}\n\nexport function isTemporalHelperModule(source: string): boolean {\n return typeof source === 'string' && /(^|\\/)temporal\\.(ts|tsx|js|jsx|mts|mjs)$/.test(source);\n}\n\nexport const strippedExternalModules = new Set(['@temporalio/client', '@temporalio/envconfig']);\n\nexport function isStrippedExternalModule(source: string): boolean {\n return typeof source === 'string' && strippedExternalModules.has(source);\n}\n\nexport function collectImportedNames(statement: t.ImportDeclaration): Set<string> {\n const names = new Set<string>();\n\n for (const specifier of statement.specifiers) {\n if (\n t.isImportDefaultSpecifier(specifier) ||\n t.isImportNamespaceSpecifier(specifier) ||\n t.isImportSpecifier(specifier)\n ) {\n if (t.isIdentifier(specifier.local)) {\n names.add(specifier.local.name);\n }\n }\n }\n\n return names;\n}\n\nexport function nodeReferencesName(node: t.Node, names: Set<string>): boolean {\n let found = false;\n\n walk(node, current => {\n if (t.isIdentifier(current) && names.has(current.name)) {\n found = true;\n return false;\n }\n });\n\n return found;\n}\n\nexport function isWorkflowHelperDestructure(declaration: t.VariableDeclarator): boolean {\n if (!t.isObjectPattern(declaration.id)) {\n return false;\n }\n\n return declaration.id.properties.some(\n property =>\n t.isObjectProperty(property) &&\n !property.computed &&\n t.isIdentifier(property.value) &&\n (property.value.name === 'createStep' || property.value.name === 'createWorkflow'),\n );\n}\n\nexport function isCreateWorkflowCall(node: t.Node): node is t.CallExpression {\n return t.isCallExpression(node) && isIdentifierNamed(node.callee, 'createWorkflow');\n}\n\nexport function isCreateStepCall(node: t.Node): node is t.CallExpression {\n return t.isCallExpression(node) && isIdentifierNamed(node.callee, 'createStep');\n}\n\nexport function getObjectPropertyName(property: t.ObjectProperty | t.ObjectMethod): string | null {\n if (property.computed) {\n return null;\n }\n\n if (t.isIdentifier(property.key)) {\n return property.key.name;\n }\n\n if (t.isStringLiteral(property.key)) {\n return property.key.value;\n }\n\n return null;\n}\n\nexport function walk(node: t.Node | null | undefined, visitor: (node: t.Node) => false | void): void {\n if (!node) {\n return;\n }\n\n const result = visitor(node);\n if (result === false) {\n return;\n }\n\n const keys = (t.VISITOR_KEYS as Record<string, string[]>)[node.type] ?? [];\n for (const key of keys) {\n const value = (node as unknown as Record<string, unknown>)[key];\n\n if (Array.isArray(value)) {\n for (const child of value) {\n if (child && typeof (child as t.Node).type === 'string') {\n walk(child as t.Node, visitor);\n }\n }\n continue;\n }\n\n if (value && typeof (value as t.Node).type === 'string') {\n walk(value as t.Node, visitor);\n }\n }\n}\n\nexport function hasCreateWorkflowCall(node: t.Node): boolean {\n let found = false;\n\n walk(node, current => {\n if (isCreateWorkflowCall(current)) {\n found = true;\n return false;\n }\n });\n\n return found;\n}\n\nexport function getStepNameFromCall(node: t.CallExpression): string | null {\n const stepId = getCreateStepId(node);\n if (!stepId) {\n return null;\n }\n\n return stepId\n .replace(/[^a-zA-Z0-9]+(.)/g, (_match, char: string) => char.toUpperCase())\n .replace(/^[^a-zA-Z_$]+/, '')\n .replace(/^(.)/, (char: string) => char.toLowerCase());\n}\n\nexport function createExportedStepStatement(name: string, initializer: t.Expression): t.ExportNamedDeclaration {\n return t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(name), t.cloneNode(initializer, true))]),\n );\n}\n\nexport function collectInlineCreateSteps(\n node: t.Node,\n seenNames: Set<string>,\n statements: t.Statement[],\n onStep?: (exportName: string, call: t.CallExpression) => void,\n): void {\n walk(node, current => {\n if (!isCreateStepCall(current)) {\n return;\n }\n\n const stepName = getStepNameFromCall(current);\n if (!stepName || seenNames.has(stepName)) {\n return false;\n }\n\n seenNames.add(stepName);\n onStep?.(stepName, current);\n statements.push(createExportedStepStatement(stepName, current));\n return false;\n });\n}\n\nexport function getReturnedCreateStepCall(node: t.Node | null | undefined): t.CallExpression | null {\n if (!node) {\n return null;\n }\n\n if (t.isArrowFunctionExpression(node) && !t.isBlockStatement(node.body)) {\n return t.isCallExpression(node.body) && isIdentifierNamed(node.body.callee, 'createStep') ? node.body : null;\n }\n\n if (!t.isFunctionDeclaration(node) && !t.isFunctionExpression(node) && !t.isArrowFunctionExpression(node)) {\n return null;\n }\n\n if (!t.isBlockStatement(node.body)) {\n return null;\n }\n\n for (const statement of node.body.body) {\n if (\n t.isReturnStatement(statement) &&\n t.isCallExpression(statement.argument) &&\n isIdentifierNamed(statement.argument.callee, 'createStep')\n ) {\n return statement.argument;\n }\n }\n\n return null;\n}\n\nexport function collectCreateStepFactoryBindings(program: t.Program): Map<string, t.CallExpression> {\n const factories = new Map<string, t.CallExpression>();\n\n for (const statement of program.body) {\n const declaration = t.isExportNamedDeclaration(statement) ? statement.declaration : statement;\n\n if (t.isFunctionDeclaration(declaration) && declaration.id) {\n const createStepCall = getReturnedCreateStepCall(declaration);\n if (createStepCall) {\n factories.set(declaration.id.name, createStepCall);\n }\n continue;\n }\n\n if (!t.isVariableDeclaration(declaration)) {\n continue;\n }\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) {\n continue;\n }\n\n const createStepCall = getReturnedCreateStepCall(declarator.init);\n if (createStepCall) {\n factories.set(declarator.id.name, createStepCall);\n }\n }\n }\n\n return factories;\n}\n\nexport function getCreateStepCallFromExpression(\n node: t.Node | null | undefined,\n factoryBindings: Map<string, t.CallExpression>,\n): t.CallExpression | null {\n if (!node) {\n return null;\n }\n\n if (t.isCallExpression(node)) {\n if (isIdentifierNamed(node.callee, 'createStep')) {\n return node;\n }\n\n if (t.isIdentifier(node.callee)) {\n return factoryBindings.get(node.callee.name) ?? null;\n }\n }\n\n const returnedCreateStepCall = getReturnedCreateStepCall(node);\n if (returnedCreateStepCall) {\n return returnedCreateStepCall;\n }\n\n return null;\n}\n\nexport function getCreateStepId(node: t.Node | null | undefined): string | null {\n if (!node || !isCreateStepCall(node)) {\n return null;\n }\n\n const [config] = node.arguments;\n if (!t.isObjectExpression(config)) {\n return null;\n }\n\n for (const property of config.properties) {\n if (!t.isObjectProperty(property) && !t.isObjectMethod(property)) {\n continue;\n }\n\n if (getObjectPropertyName(property) !== 'id') {\n continue;\n }\n\n const value = t.isObjectMethod(property) ? null : property.value;\n return t.isStringLiteral(value) ? value.value : null;\n }\n\n return null;\n}\n\nexport function shouldCountIdentifierAsReference(parent: t.Node | null, key: string | null): boolean {\n if (!parent) {\n return true;\n }\n\n if ((t.isObjectProperty(parent) || t.isObjectMethod(parent)) && key === 'key' && !parent.computed) {\n return false;\n }\n\n if (t.isMemberExpression(parent) && key === 'property' && !parent.computed) {\n return false;\n }\n\n if (t.isVariableDeclarator(parent) && key === 'id') {\n return false;\n }\n\n if (\n (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent) || t.isArrowFunctionExpression(parent)) &&\n key === 'params'\n ) {\n return false;\n }\n\n if (\n (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent) || t.isClassDeclaration(parent)) &&\n key === 'id'\n ) {\n return false;\n }\n\n if (\n (t.isImportSpecifier(parent) || t.isImportDefaultSpecifier(parent) || t.isImportNamespaceSpecifier(parent)) &&\n (key === 'local' || key === 'imported')\n ) {\n return false;\n }\n\n if (t.isExportSpecifier(parent) && key === 'exported') {\n return false;\n }\n\n if (t.isLabeledStatement(parent) && key === 'label') {\n return false;\n }\n\n if (t.isCatchClause(parent) && key === 'param') {\n return false;\n }\n\n if (t.isRestElement(parent) && key === 'argument') {\n return false;\n }\n\n if (t.isAssignmentPattern(parent) && key === 'left') {\n return false;\n }\n\n if (t.isTSPropertySignature(parent) || t.isTSMethodSignature(parent) || t.isTSInterfaceHeritage(parent)) {\n return false;\n }\n\n return true;\n}\n\nexport function collectRuntimeReferencedIdentifiers(node: t.Node): Set<string> {\n const refs = new Set<string>();\n\n const visit = (current: t.Node | null | undefined, parent: t.Node | null, key: string | null) => {\n if (!current) {\n return;\n }\n\n if (current.type.startsWith('TS')) {\n return;\n }\n\n if (t.isIdentifier(current)) {\n if (shouldCountIdentifierAsReference(parent, key)) {\n refs.add(current.name);\n }\n return;\n }\n\n for (const visitorKey of t.VISITOR_KEYS[current.type] ?? []) {\n const value = (current as unknown as Record<string, unknown>)[visitorKey];\n if (Array.isArray(value)) {\n value.forEach(child => {\n if (t.isNode(child)) {\n visit(child, current, visitorKey);\n }\n });\n continue;\n }\n\n if (t.isNode(value)) {\n visit(value, current, visitorKey);\n }\n }\n };\n\n visit(node, null, null);\n return refs;\n}\n\nexport function pruneUnusedTopLevelBindings(statements: t.Statement[]): t.Statement[] {\n const bindings = new Map<string, { refs: Set<string>; statementIndex: number }>();\n const liveStatements = new Set<number>();\n const queue: number[] = [];\n\n const markLive = (statementIndex: number) => {\n if (liveStatements.has(statementIndex)) {\n return;\n }\n\n liveStatements.add(statementIndex);\n queue.push(statementIndex);\n };\n\n statements.forEach((statement, statementIndex) => {\n if (t.isImportDeclaration(statement)) {\n for (const specifier of statement.specifiers) {\n bindings.set(specifier.local.name, { refs: new Set(), statementIndex });\n }\n return;\n }\n\n if (t.isVariableDeclaration(statement)) {\n for (const declaration of statement.declarations) {\n if (t.isIdentifier(declaration.id)) {\n bindings.set(declaration.id.name, {\n refs: declaration.init ? collectRuntimeReferencedIdentifiers(declaration.init) : new Set(),\n statementIndex,\n });\n }\n }\n return;\n }\n\n if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n for (const declaration of statement.declaration.declarations) {\n if (t.isIdentifier(declaration.id)) {\n bindings.set(declaration.id.name, {\n refs: declaration.init ? collectRuntimeReferencedIdentifiers(declaration.init) : new Set(),\n statementIndex,\n });\n }\n }\n markLive(statementIndex);\n return;\n }\n\n markLive(statementIndex);\n });\n\n while (queue.length > 0) {\n const statementIndex = queue.pop()!;\n const statement = statements[statementIndex];\n if (!statement) {\n continue;\n }\n\n const refs = new Set<string>();\n\n if (t.isImportDeclaration(statement)) {\n continue;\n }\n\n if (t.isVariableDeclaration(statement)) {\n for (const declaration of statement.declarations) {\n if (declaration.init) {\n for (const ref of collectRuntimeReferencedIdentifiers(declaration.init)) {\n refs.add(ref);\n }\n }\n }\n } else if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n for (const declaration of statement.declaration.declarations) {\n if (declaration.init) {\n for (const ref of collectRuntimeReferencedIdentifiers(declaration.init)) {\n refs.add(ref);\n }\n }\n }\n } else {\n for (const ref of collectRuntimeReferencedIdentifiers(statement)) {\n refs.add(ref);\n }\n }\n\n for (const ref of refs) {\n const binding = bindings.get(ref);\n if (binding) {\n markLive(binding.statementIndex);\n }\n }\n }\n\n const prunedStatements: t.Statement[] = [];\n\n statements.forEach((statement, statementIndex) => {\n if (!liveStatements.has(statementIndex)) {\n return;\n }\n\n if (t.isImportDeclaration(statement)) {\n const specifiers = statement.specifiers.filter(specifier =>\n liveStatements.has(bindings.get(specifier.local.name)?.statementIndex ?? -1),\n );\n if (specifiers.length > 0) {\n prunedStatements.push(t.importDeclaration(specifiers, statement.source));\n }\n return;\n }\n\n if (t.isVariableDeclaration(statement)) {\n const declarations = statement.declarations.filter(\n declaration =>\n !t.isIdentifier(declaration.id) ||\n liveStatements.has(bindings.get(declaration.id.name)?.statementIndex ?? -1),\n );\n if (declarations.length > 0) {\n prunedStatements.push(t.variableDeclaration(statement.kind, declarations));\n }\n return;\n }\n\n if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n const declarations = statement.declaration.declarations.filter(\n declaration =>\n !t.isIdentifier(declaration.id) ||\n liveStatements.has(bindings.get(declaration.id.name)?.statementIndex ?? -1),\n );\n if (declarations.length > 0) {\n prunedStatements.push(\n t.exportNamedDeclaration(t.variableDeclaration(statement.declaration.kind, declarations)),\n );\n }\n return;\n }\n\n prunedStatements.push(statement);\n });\n\n return prunedStatements;\n}\n","import path, { basename, join } from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { rollup } from 'rollup';\nimport type { SourceMapInput } from 'rollup';\nimport {\n collectCreateStepFactoryBindings,\n collectImportedNames,\n collectInlineCreateSteps,\n createExportedStepStatement,\n getCreateStepCallFromExpression,\n getCreateStepId,\n getObjectPropertyName,\n getStepNameFromCall,\n hasCreateWorkflowCall,\n isCreateStepCall,\n isStrippedExternalModule,\n isTemporalHelperModule,\n isWorkflowHelperDestructure,\n nodeReferencesName,\n parserPlugins,\n pruneUnusedTopLevelBindings,\n walk,\n} from './shared';\n\nexport interface TemporalActivityBinding {\n exportName: string;\n stepId: string;\n}\n\nexport interface BuildTemporalActivitiesModuleResult {\n outputPath: string;\n activityBindings: TemporalActivityBinding[];\n}\n\nexport function collectTemporalActivityBindings(sourceText: string, filePath: string): TemporalActivityBinding[] {\n const ast = parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins,\n sourceFilename: filePath,\n });\n\n const bindings: TemporalActivityBinding[] = [];\n const seenNames = new Set<string>();\n const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);\n\n const addBinding = (call: t.CallExpression, exportName = getStepNameFromCall(call)): void => {\n const stepId = getCreateStepId(call);\n\n if (!exportName || !stepId || seenNames.has(exportName)) {\n return;\n }\n\n seenNames.add(exportName);\n bindings.push({ exportName, stepId });\n };\n\n const collectInlineBindings = (node: t.Node): void => {\n walk(node, current => {\n if (!isCreateStepCall(current)) {\n return;\n }\n\n addBinding(current);\n return false;\n });\n };\n\n for (const statement of ast.program.body) {\n if (\n t.isVariableDeclaration(statement) ||\n (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n ) {\n const declarationStatement = t.isVariableDeclaration(statement)\n ? statement\n : (statement.declaration as t.VariableDeclaration);\n\n for (const declaration of declarationStatement.declarations) {\n if (!declaration.init) {\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n if (createStepCall) {\n addBinding(createStepCall, t.isIdentifier(declaration.id) ? declaration.id.name : undefined);\n continue;\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n collectInlineBindings(declaration.init);\n }\n }\n\n continue;\n }\n\n if (hasCreateWorkflowCall(statement)) {\n collectInlineBindings(statement);\n }\n }\n\n return bindings;\n}\n\nfunction normalizeImportPath(importPath: string, extension: string): string {\n const normalizedPath = importPath.split(path.sep).join('/');\n const pathWithExtension =\n extension === '.mjs' || extension === '.cjs' ? normalizedPath : normalizedPath.replace(/\\.[cm]?[jt]sx?$/, '');\n\n return pathWithExtension.startsWith('.') ? pathWithExtension : `./${pathWithExtension}`;\n}\n\nfunction rebaseModulePath(modulePath: string, sourceFilePath: string, outputFilePath: string): string {\n if (!modulePath.startsWith('.')) {\n return modulePath;\n }\n\n const resolvedPath = path.resolve(path.dirname(sourceFilePath), modulePath);\n const relativePath = path.relative(path.dirname(outputFilePath), resolvedPath);\n return normalizeImportPath(relativePath, path.extname(resolvedPath));\n}\n\nfunction 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 = node;\n\n while (t.isCallExpression(current) && t.isMemberExpression(current.callee) && !current.callee.computed) {\n if (!t.isIdentifier(current.callee.property)) {\n return null;\n }\n methods.unshift({ name: current.callee.property.name, args: current.arguments as t.Node[] });\n current = current.callee.object;\n }\n\n if (!t.isCallExpression(current) || !t.isIdentifier(current.callee, { name: 'createWorkflow' })) {\n return null;\n }\n\n return { createWorkflowCall: current, methods };\n}\n\nfunction getStaticWorkflowId(call: t.CallExpression, filePath: string): string {\n const [config] = call.arguments;\n if (!t.isObjectExpression(config)) {\n throw new Error(`Unable to determine workflow config in ${filePath}`);\n }\n\n for (const property of config.properties) {\n if (!t.isObjectProperty(property) || getObjectPropertyName(property) !== 'id') {\n continue;\n }\n if (t.isStringLiteral(property.value)) {\n return property.value.value;\n }\n if (t.isTemplateLiteral(property.value) && property.value.expressions.length === 0) {\n return property.value.quasis[0]?.value.cooked ?? '';\n }\n }\n\n throw new Error(`Workflow id must be a static string in ${filePath}`);\n}\n\nfunction toExportName(id: string): string {\n return id\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\nfunction collectStaticFunctionBindings(program: t.Program): Set<string> {\n const bindings = new Set<string>();\n for (const statement of program.body) {\n const declaration = t.isExportNamedDeclaration(statement) ? statement.declaration : statement;\n if (t.isFunctionDeclaration(declaration) && declaration.id) {\n bindings.add(declaration.id.name);\n continue;\n }\n if (!t.isVariableDeclaration(declaration) || declaration.kind !== 'const') {\n continue;\n }\n for (const declarator of declaration.declarations) {\n if (\n t.isIdentifier(declarator.id) &&\n (t.isArrowFunctionExpression(declarator.init) || t.isFunctionExpression(declarator.init))\n ) {\n bindings.add(declarator.id.name);\n }\n }\n }\n return bindings;\n}\n\nfunction collectTopLevelBindingNames(program: t.Program): Set<string> {\n const bindings = new Set<string>();\n for (const statement of program.body) {\n for (const name of Object.keys(t.getBindingIdentifiers(statement))) {\n bindings.add(name);\n }\n }\n return bindings;\n}\n\nfunction createMappingActivityStatements(\n workflowExpression: t.Expression,\n filePath: string,\n staticFunctionBindings: Set<string>,\n usedExportNames: Set<string>,\n requestContextClassName: string,\n addBinding: (exportName: string, stepId: string) => void,\n): t.Statement[] {\n const chain = parseWorkflowChain(workflowExpression);\n if (!chain) {\n return [];\n }\n\n const workflowId = getStaticWorkflowId(chain.createWorkflowCall, filePath);\n const statements: t.Statement[] = [];\n let mappingOrdinal = 0;\n\n for (const method of chain.methods) {\n if (method.name !== 'map') {\n continue;\n }\n\n const [callback] = method.args;\n if (t.isObjectExpression(callback)) {\n throw new Error(\n `.map() in workflow ${workflowId} (${filePath}) does not yet support declarative object mappings`,\n );\n }\n if (\n !t.isArrowFunctionExpression(callback) &&\n !t.isFunctionExpression(callback) &&\n !(t.isIdentifier(callback) && staticFunctionBindings.has(callback.name))\n ) {\n throw new Error(\n `.map() in workflow ${workflowId} (${filePath}) requires an inline function or a statically declared function identifier`,\n );\n }\n\n const mappingId = `mapping_${workflowId}_${mappingOrdinal++}`;\n const baseExportName = toExportName(mappingId);\n let exportName = baseExportName;\n let exportSuffix = 1;\n while (usedExportNames.has(exportName)) {\n exportName = `${baseExportName}${exportSuffix++}`;\n }\n usedExportNames.add(exportName);\n const contextNames = ['requestContext', 'runId', 'resourceId', 'workflowId'];\n const params = t.objectPattern([\n t.objectProperty(t.identifier('inputData'), t.identifier('inputData'), false, true),\n t.objectProperty(t.identifier('initData'), t.identifier('initData'), false, true),\n ...contextNames.map(name => t.objectProperty(t.identifier(name), t.identifier(name), false, true)),\n ]);\n const callbackContext = t.objectExpression([\n t.objectProperty(t.identifier('inputData'), t.identifier('inputData'), false, true),\n t.objectProperty(t.identifier('getInitData'), t.arrowFunctionExpression([], t.identifier('initData'))),\n t.objectProperty(\n t.identifier('requestContext'),\n t.newExpression(t.identifier(requestContextClassName), [t.identifier('requestContext')]),\n ),\n ...contextNames\n .filter(name => name !== 'requestContext')\n .map(name => t.objectProperty(t.identifier(name), t.identifier(name), false, true)),\n ]);\n const callbackExpression = t.cloneNode(callback, true) as t.Expression;\n const body = t.callExpression(callbackExpression, [callbackContext]);\n statements.push(\n t.exportNamedDeclaration(\n t.variableDeclaration('const', [\n t.variableDeclarator(t.identifier(exportName), t.arrowFunctionExpression([params], body, true)),\n ]),\n ),\n );\n addBinding(exportName, mappingId);\n }\n\n return statements;\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 requestContextClassName: string,\n): t.Statement[] {\n const executeBody = mastraImportPath\n ? `\n const { mastra } = await import(${JSON.stringify(mastraImportPath)});\n return executeTemporalStep(args, { ...withRequestContext(params, args), mastra });\n `\n : hasMastraBinding\n ? 'return executeTemporalStep(args, { ...withRequestContext(params, args), mastra });'\n : 'return executeTemporalStep(args, withRequestContext(params, args));';\n\n const helperSource = `\n function withRequestContext(params, args) {\n const { requestContext, initData, ...rest } = params;\n let suspended;\n return {\n ...rest,\n requestContext: new ${requestContextClassName}(requestContext),\n getInitData: () => initData,\n suspend: async (suspendPayload, options) => {\n const parsedSuspendPayload = await parseWithSchema(args.suspendSchema, suspendPayload, 'Suspend payload');\n suspended = {\n __temporalSuspension: true,\n suspendPayload: parsedSuspendPayload,\n ...(options?.resumeLabel !== undefined && { resumeLabel: options.resumeLabel }),\n };\n },\n __getTemporalSuspension: () => suspended,\n };\n }\n\n async function parseWithSchema(schema, value, label) {\n if (!schema) return value;\n if (schema['~standard']?.validate) {\n const result = await schema['~standard'].validate(value);\n if ('issues' in result && result.issues?.length) {\n throw new Error(label + ' validation failed: ' + result.issues.map(issue => issue.message).join(', '));\n }\n return result.value;\n }\n if (typeof schema.parseAsync === 'function') return schema.parseAsync(value);\n if (typeof schema.parse === 'function') return schema.parse(value);\n return value;\n }\n\n async function executeTemporalStep(args, context) {\n const result = await args.execute(context);\n return context.__getTemporalSuspension() ?? result;\n }\n\n function createStep(args) {\n return {\n inputSchema: args.inputSchema,\n requestContextSchema: args.requestContextSchema,\n suspendSchema: args.suspendSchema,\n resumeSchema: args.resumeSchema,\n execute: async (params) => {\n ${executeBody}\n },\n };\n }\n `;\n\n return parse(helperSource, {\n sourceType: 'module',\n plugins: parserPlugins,\n }).program.body;\n}\n\nexport async function buildTemporalActivitiesModule(\n entryFile: string,\n outputDirectory: string,\n outputFileName: string,\n): Promise<BuildTemporalActivitiesModuleResult> {\n const activityBindings: TemporalActivityBinding[] = [];\n const seenActivityBindingNames = new Set<string>();\n const addGeneratedActivityBinding = (exportName: string, stepId: string): void => {\n if (seenActivityBindingNames.has(exportName)) {\n return;\n }\n\n seenActivityBindingNames.add(exportName);\n activityBindings.push({ exportName, stepId });\n };\n const addActivityBinding = (exportName: string, call: t.CallExpression): void => {\n const stepId = getCreateStepId(call);\n if (stepId) {\n addGeneratedActivityBinding(exportName, stepId);\n }\n };\n\n const bundle = await rollup({\n input: entryFile,\n treeshake: 'smallest',\n logLevel: 'silent',\n plugins: [\n {\n name: 'temporal-workflow-transform',\n transform(code, id) {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: parserPlugins,\n sourceFilename: id,\n });\n\n const usedExportNames = collectTopLevelBindingNames(ast.program);\n let requestContextClassName = 'TemporalRequestContext';\n let requestContextSuffix = 1;\n while (usedExportNames.has(requestContextClassName)) {\n requestContextClassName = `TemporalRequestContext${requestContextSuffix++}`;\n }\n usedExportNames.add(requestContextClassName);\n\n const statements: t.Statement[] = [\n t.importDeclaration(\n [t.importSpecifier(t.identifier(requestContextClassName), t.identifier('RequestContext'))],\n t.stringLiteral('@mastra/core/di'),\n ),\n ];\n const seenNames = new Set<string>();\n const strippedNames = new Set<string>();\n const workflowBindingNames = collectWorkflowBindingNames(ast);\n const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);\n const staticFunctionBindings = collectStaticFunctionBindings(ast.program);\n const sourceFilePath = id;\n const hasMastraBinding = hasLocalMastraBinding(ast);\n let helperInserted = false;\n\n const ensureHelperInserted = () => {\n if (helperInserted) {\n return;\n }\n\n statements.push(\n ...createTemporalActivitiesHelperStatements(null, hasMastraBinding, requestContextClassName),\n );\n helperInserted = true;\n };\n\n for (const statement of ast.program.body) {\n if (t.isImportDeclaration(statement)) {\n if (statement.source.value === '@mastra/core/workflows') {\n const retainedSpecifiers = statement.specifiers.filter(\n specifier =>\n !(\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n (specifier.imported.name === 'createStep' || specifier.imported.name === 'createWorkflow')\n ),\n );\n\n if (retainedSpecifiers.length > 0) {\n statements.push(t.importDeclaration(retainedSpecifiers, t.stringLiteral(statement.source.value)));\n }\n continue;\n }\n\n if (isTemporalHelperModule(statement.source.value) || isStrippedExternalModule(statement.source.value)) {\n for (const name of collectImportedNames(statement)) {\n strippedNames.add(name);\n }\n continue;\n }\n\n const rewrittenSource = rebaseModulePath(statement.source.value, sourceFilePath, id);\n if (rewrittenSource === statement.source.value) {\n statements.push(statement);\n } else {\n statements.push(\n t.importDeclaration(\n statement.specifiers.map(specifier => t.cloneNode(specifier, true)),\n t.stringLiteral(rewrittenSource),\n ),\n );\n }\n continue;\n }\n\n if (\n t.isFunctionDeclaration(statement) ||\n t.isClassDeclaration(statement) ||\n t.isTSTypeAliasDeclaration(statement) ||\n t.isTSInterfaceDeclaration(statement) ||\n t.isTSEnumDeclaration(statement)\n ) {\n ensureHelperInserted();\n statements.push(statement);\n continue;\n }\n\n if (t.isExpressionStatement(statement) && nodeReferencesName(statement, strippedNames)) {\n continue;\n }\n\n ensureHelperInserted();\n\n if (t.isVariableDeclaration(statement)) {\n const declarations: t.VariableDeclarator[] = [];\n\n for (const declaration of statement.declarations) {\n if (isWorkflowHelperDestructure(declaration)) {\n continue;\n }\n\n if (\n declaration.init &&\n nodeReferencesName(declaration.init, strippedNames) &&\n !isMastraDeclaration(declaration)\n ) {\n if (t.isIdentifier(declaration.id)) {\n strippedNames.add(declaration.id.name);\n }\n continue;\n }\n\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n declarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n if (createStepCall) {\n const isFactoryCall =\n t.isCallExpression(declaration.init) &&\n t.isIdentifier(declaration.init.callee) &&\n stepFactoryBindings.has(declaration.init.callee.name);\n\n if (isFactoryCall) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n statements.push(\n t.exportNamedDeclaration(t.variableDeclaration(statement.kind, [t.cloneNode(declaration, true)])),\n );\n continue;\n }\n\n if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n statements.push(createExportedStepStatement(declaration.id.name, createStepCall));\n continue;\n }\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n workflowBindingNames.add(declaration.id.name);\n strippedNames.add(declaration.id.name);\n statements.push(\n ...createMappingActivityStatements(\n declaration.init,\n sourceFilePath,\n staticFunctionBindings,\n usedExportNames,\n requestContextClassName,\n addGeneratedActivityBinding,\n ),\n );\n collectInlineCreateSteps(declaration.init, seenNames, statements, addActivityBinding);\n continue;\n }\n\n declarations.push(createPreservedDeclaration(declaration, strippedNames));\n }\n\n if (declarations.length > 0) {\n statements.push(\n t.variableDeclaration(\n statement.kind,\n declarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n );\n }\n continue;\n }\n\n if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n const exportedDeclarations: t.VariableDeclarator[] = [];\n const localDeclarations: t.VariableDeclarator[] = [];\n\n for (const declaration of statement.declaration.declarations) {\n if (isWorkflowHelperDestructure(declaration)) {\n continue;\n }\n\n if (\n declaration.init &&\n nodeReferencesName(declaration.init, strippedNames) &&\n !isMastraDeclaration(declaration)\n ) {\n if (t.isIdentifier(declaration.id)) {\n strippedNames.add(declaration.id.name);\n }\n continue;\n }\n\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n if (createStepCall) {\n const isFactoryCall =\n t.isCallExpression(declaration.init) &&\n t.isIdentifier(declaration.init.callee) &&\n stepFactoryBindings.has(declaration.init.callee.name);\n\n if (isFactoryCall) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n statements.push(createExportedStepStatement(declaration.id.name, createStepCall));\n continue;\n }\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n workflowBindingNames.add(declaration.id.name);\n strippedNames.add(declaration.id.name);\n statements.push(\n ...createMappingActivityStatements(\n declaration.init,\n sourceFilePath,\n staticFunctionBindings,\n usedExportNames,\n requestContextClassName,\n addGeneratedActivityBinding,\n ),\n );\n collectInlineCreateSteps(declaration.init, seenNames, statements, addActivityBinding);\n continue;\n }\n\n if (declaration.id.name === 'mastra') {\n localDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n }\n\n if (localDeclarations.length > 0) {\n statements.push(\n t.variableDeclaration(\n statement.declaration.kind,\n localDeclarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n );\n }\n\n if (exportedDeclarations.length > 0) {\n statements.push(\n t.exportNamedDeclaration(\n t.variableDeclaration(\n statement.declaration.kind,\n exportedDeclarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n ),\n );\n }\n continue;\n }\n\n if (t.isExpressionStatement(statement)) {\n if (nodeReferencesName(statement, workflowBindingNames) || nodeReferencesName(statement, strippedNames)) {\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n if (t.isExportNamedDeclaration(statement)) {\n if (\n t.isFunctionDeclaration(statement.declaration) ||\n t.isClassDeclaration(statement.declaration) ||\n t.isTSTypeAliasDeclaration(statement.declaration) ||\n t.isTSInterfaceDeclaration(statement.declaration) ||\n t.isTSEnumDeclaration(statement.declaration)\n ) {\n ensureHelperInserted();\n statements.push(statement);\n continue;\n }\n\n if (statement.declaration == null && statement.source == null) {\n const retainedSpecifiers = statement.specifiers.filter(\n specifier =>\n t.isExportSpecifier(specifier) &&\n t.isIdentifier(specifier.local) &&\n specifier.local.name !== 'mastra' &&\n !workflowBindingNames.has(specifier.local.name) &&\n !seenNames.has(specifier.local.name),\n );\n\n if (retainedSpecifiers.length > 0) {\n statements.push(t.exportNamedDeclaration(null, retainedSpecifiers));\n }\n continue;\n }\n\n if (statement.declaration == null && statement.source) {\n const mastraSpecifiers = statement.specifiers.filter(\n specifier =>\n t.isExportSpecifier(specifier) &&\n t.isIdentifier(specifier.exported, { name: 'mastra' }) &&\n t.isIdentifier(specifier.local, { name: 'mastra' }),\n );\n\n if (mastraSpecifiers.length > 0) {\n statements.push(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('mastra'), t.identifier('mastra'))],\n t.stringLiteral(rebaseModulePath(statement.source.value, sourceFilePath, id)),\n ),\n );\n }\n continue;\n }\n\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n if (t.isExportDefaultDeclaration(statement)) {\n if (t.isIdentifier(statement.declaration) && workflowBindingNames.has(statement.declaration.name)) {\n continue;\n }\n\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n statements.push(statement);\n }\n\n ensureHelperInserted();\n\n const transformedSource = generate(t.file(t.program(pruneUnusedTopLevelBindings(statements), [], 'module')), {\n sourceMaps: true,\n });\n\n return {\n code: transformedSource.code,\n map: transformedSource.map\n ? ({ ...transformedSource.map, file: transformedSource.map.file ?? undefined } as SourceMapInput)\n : undefined,\n };\n },\n },\n ],\n });\n\n try {\n const baseName = basename(outputFileName);\n const { output } = await bundle.write({\n dir: outputDirectory,\n entryFileNames: outputFileName,\n chunkFileNames: `${baseName}-[hash].mjs`,\n format: 'esm',\n sourcemap: 'inline',\n });\n\n return {\n outputPath: join(outputDirectory, output.find(chunk => chunk.type === 'chunk' && chunk.isEntry)!.fileName),\n activityBindings,\n };\n } finally {\n await bundle.close();\n }\n}\n","import { readFileSync } from 'node:fs';\nimport { builtinModules } from 'node:module';\nimport { basename, join } from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { rollup } from 'rollup';\nimport { toWorkflowType } from '../utils';\nimport {\n collectCreateStepFactoryBindings,\n collectImportedNames,\n getCreateStepCallFromExpression,\n getCreateStepId,\n getObjectPropertyName,\n isCreateWorkflowCall,\n isIdentifierNamed,\n isStrippedExternalModule,\n isTemporalHelperModule,\n isWorkflowHelperDestructure,\n nodeReferencesName,\n parseModule,\n parserPlugins,\n pruneUnusedTopLevelBindings,\n} from './shared';\n\n/**\n * Temporal workflow types must be static so the loader can deterministically map\n * a source workflow to the runtime export name used by the worker.\n */\nfunction getWorkflowIdMetadata(\n workflowConfig: t.ObjectExpression,\n workflowName: string,\n filePath: string,\n): { expression: t.Expression; workflowId: string } {\n for (const property of workflowConfig.properties) {\n if (!t.isObjectProperty(property) || getObjectPropertyName(property) !== 'id') {\n continue;\n }\n\n if (!t.isExpression(property.value)) {\n break;\n }\n\n if (t.isStringLiteral(property.value)) {\n return {\n expression: t.cloneNode(property.value, true),\n workflowId: property.value.value,\n };\n }\n\n if (t.isTemplateLiteral(property.value) && property.value.expressions.length === 0) {\n return {\n expression: t.cloneNode(property.value, true),\n workflowId: property.value.quasis[0]?.value.cooked ?? '',\n };\n }\n\n throw new Error(`Workflow id must be a static string for ${workflowName} in ${filePath}`);\n }\n\n throw new Error(`Unable to determine workflow id for ${workflowName} in ${filePath}`);\n}\n\ntype StaticProperty = { readable: true; value?: t.Node } | { readable: false };\n\nfunction getStaticKey(property: t.ObjectProperty | t.ObjectMethod): string | null {\n if (property.computed && t.isTemplateLiteral(property.key) && property.key.expressions.length === 0) {\n return property.key.quasis[0]?.value.cooked ?? null;\n }\n\n if (property.computed && t.isStringLiteral(property.key)) {\n return property.key.value;\n }\n\n return getObjectPropertyName(property);\n}\n\nfunction isDynamicKey(property: t.ObjectProperty | t.ObjectMethod): boolean {\n return (\n property.computed &&\n !t.isStringLiteral(property.key) &&\n !(t.isTemplateLiteral(property.key) && property.key.expressions.length === 0)\n );\n}\n\n// A later property overrides an earlier one, so a spread or `[key]` hides `name` only when it\n// comes after the last `name` written out in source.\nfunction findStaticProperty(object: t.ObjectExpression, name: string): StaticProperty {\n let found: StaticProperty = { readable: true };\n\n for (const property of object.properties) {\n if (t.isSpreadElement(property) || isDynamicKey(property)) {\n found = { readable: false };\n continue;\n }\n\n if (getStaticKey(property) === name) {\n found = t.isObjectProperty(property) ? { readable: true, value: property.value } : { readable: false };\n }\n }\n\n return found;\n}\n\n/**\n * Read at build time so runs started outside `TemporalRun` (Schedules, the Temporal CLI) use the\n * workflow's setting too. `TemporalRun` also sends the setting, which covers `options` the build\n * cannot read.\n */\nfunction getWorkflowValidateInputs(\n workflowConfig: t.ObjectExpression,\n workflowName: string,\n filePath: string,\n): boolean | undefined {\n const options = findStaticProperty(workflowConfig, 'options');\n if (options.readable && !options.value) {\n return undefined;\n }\n\n if (options.readable && t.isObjectExpression(options.value)) {\n const validateInputs = findStaticProperty(options.value, 'validateInputs');\n if (validateInputs.readable && !validateInputs.value) {\n return undefined;\n }\n\n if (validateInputs.readable && t.isBooleanLiteral(validateInputs.value)) {\n return validateInputs.value.value;\n }\n }\n\n console.warn(\n `[@mastra/temporal] Could not read options.validateInputs of ${workflowName} in ${filePath} at build time. ` +\n 'Runs started with run.start() or run.startAsync() use the workflow setting. ' +\n 'Runs started another way, such as from a Temporal Schedule, check step input.',\n );\n return undefined;\n}\n\n/**\n * The helper runtime lives in its own `.mjs` module so it can be linted and unit-tested\n * like normal code. We parse that file directly here instead of using `Function#toString()`,\n * which keeps fixture output stable under Vitest/Vite instrumentation.\n */\nfunction createTemporalWorkflowHelperStatements(): t.Statement[] {\n const temporalWorkflowRuntimeSource = readFileSync(\n new URL('./temporal-workflow-runtime.mjs', import.meta.url),\n 'utf8',\n );\n\n const helperProgram = parse(temporalWorkflowRuntimeSource, {\n sourceType: 'module',\n plugins: parserPlugins,\n }).program.body;\n\n return helperProgram.flatMap(statement => {\n if (t.isExportNamedDeclaration(statement) && statement.declaration) {\n return [statement.declaration];\n }\n\n return [statement];\n });\n}\n\nfunction getTemporalWorkflowRuntimeOptions(program: t.Program): t.ObjectExpression | undefined {\n for (const statement of program.body) {\n const declarationStatement = t.isVariableDeclaration(statement)\n ? statement\n : t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)\n ? statement.declaration\n : null;\n\n if (!declarationStatement) {\n continue;\n }\n\n for (const declaration of declarationStatement.declarations) {\n if (!isWorkflowHelperDestructure(declaration) || !t.isCallExpression(declaration.init)) {\n continue;\n }\n\n const [temporalParams] = declaration.init.arguments;\n if (!temporalParams || !t.isObjectExpression(temporalParams)) {\n continue;\n }\n\n const runtimeProperties = new Map<string, t.ObjectProperty>();\n const collectRuntimeProperties = (params: t.ObjectExpression): void => {\n for (const property of params.properties) {\n if (t.isSpreadElement(property)) {\n if (!t.isObjectExpression(property.argument)) {\n continue;\n }\n collectRuntimeProperties(property.argument);\n continue;\n }\n if (!t.isObjectProperty(property) || !t.isExpression(property.value)) {\n continue;\n }\n const name = getObjectPropertyName(property);\n if (name === 'startToCloseTimeout' || name === 'retry') {\n runtimeProperties.set(name, t.objectProperty(t.identifier(name), t.cloneNode(property.value, true)));\n }\n }\n };\n collectRuntimeProperties(temporalParams);\n if (runtimeProperties.size > 0) {\n return t.objectExpression([...runtimeProperties.values()]);\n }\n }\n }\n}\n\n/**\n * Walks a chained workflow expression like `createWorkflow(...).then(...).commit()`\n * back to its root `createWorkflow(...)` call while preserving method order.\n */\nfunction parseWorkflowChain(\n node: t.Node,\n): { createWorkflowCall: t.CallExpression; methods: { name: string; args: t.Node[] }[] } | null {\n const methods: { name: string; args: t.Node[] }[] = [];\n let current: t.Node = node;\n\n // Example:\n // createWorkflow(...).then(stepA).sleep(1000).commit()\n // is peeled from the outside in, producing:\n // [then(stepA), sleep(1000), commit()]\n while (t.isCallExpression(current) && t.isMemberExpression(current.callee) && !current.callee.computed) {\n if (!t.isIdentifier(current.callee.property)) {\n return null;\n }\n\n methods.unshift({\n name: current.callee.property.name,\n args: current.arguments as t.Node[],\n });\n current = current.callee.object;\n }\n\n if (!isCreateWorkflowCall(current)) {\n return null;\n }\n\n return {\n createWorkflowCall: current,\n methods,\n };\n}\n\n/**\n * Maps local `const someStep = createStep({ id: 'some-step' })` bindings to their\n * runtime ids so later chain rewriting can replace identifier references with ids.\n */\nfunction collectStepBindings(program: t.Program): Map<string, string> {\n const stepBindings = new Map<string, string>();\n const stepFactoryBindings = collectCreateStepFactoryBindings(program);\n\n for (const [factoryName, createStepCall] of stepFactoryBindings) {\n const stepId = getCreateStepId(createStepCall);\n if (stepId) {\n stepBindings.set(factoryName, stepId);\n }\n }\n\n for (const statement of program.body) {\n if (\n !t.isVariableDeclaration(statement) &&\n !(t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n ) {\n continue;\n }\n\n const declarationStatement = t.isVariableDeclaration(statement)\n ? statement\n : (statement.declaration as t.VariableDeclaration);\n\n for (const declaration of declarationStatement.declarations) {\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n const stepId = getCreateStepId(createStepCall);\n if (stepId) {\n stepBindings.set(declaration.id.name, stepId);\n }\n }\n }\n\n return stepBindings;\n}\n\n// The Temporal workflow type the child runs as, and the Mastra workflow id its step records use.\ntype WorkflowBinding = { workflowType: string; workflowId: string };\n\nfunction collectWorkflowBindings(program: t.Program, filePath: string): Map<string, WorkflowBinding> {\n const workflowBindings = new Map<string, WorkflowBinding>();\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, { workflowType: toWorkflowType(workflowId), workflowId });\n }\n }\n\n return workflowBindings;\n}\n\n/**\n * Accepts the few AST node shapes we allow as \"step references\" in workflow chains\n * and normalizes them to a single step id string.\n */\nfunction getWorkflowStepName(node: t.Node | null | undefined, stepBindings: Map<string, string>): string | null {\n if (!node) {\n return null;\n }\n\n if (t.isIdentifier(node)) {\n return stepBindings.get(node.name) ?? node.name;\n }\n\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n\n if (t.isCallExpression(node) && t.isIdentifier(node.callee)) {\n return stepBindings.get(node.callee.name) ?? getCreateStepId(node);\n }\n\n return getCreateStepId(node);\n}\n\n/**\n * Normalizes fluent workflow builder calls into the simpler Temporal runtime shape.\n *\n * Most step references collapse down to step ids so the generated workflow can call\n * activities by id instead of keeping the original `createStep` definitions around.\n */\nfunction rewriteChainMethod(\n method: { name: string; args: t.Node[] },\n filePath: string,\n workflowName: string,\n workflowId: string,\n mappingOrdinal: number,\n stepBindings: Map<string, string>,\n workflowBindings: Map<string, WorkflowBinding>,\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 binding = workflowBindings.get(arg.name);\n if (binding) {\n return rewritten(\n [t.stringLiteral(binding.workflowType), t.stringLiteral(binding.workflowId)],\n 'thenWorkflow',\n );\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 entries = arg.elements.map(element => {\n if (t.isIdentifier(element)) {\n const binding = workflowBindings.get(element.name);\n if (binding) {\n return t.objectExpression([\n t.objectProperty(t.identifier('type'), t.stringLiteral('childWorkflow')),\n t.objectProperty(t.identifier('workflowType'), t.stringLiteral(binding.workflowType)),\n t.objectProperty(t.identifier('id'), t.stringLiteral(binding.workflowId)),\n ]);\n }\n }\n\n const stepId = getWorkflowStepName(element, stepBindings);\n if (!stepId) {\n throw new Error(`Unable to determine step names inside .parallel() in ${workflowName} (${filePath})`);\n }\n\n return t.objectExpression([\n t.objectProperty(t.identifier('type'), t.stringLiteral('step')),\n t.objectProperty(\n t.identifier('step'),\n t.objectExpression([t.objectProperty(t.identifier('id'), t.stringLiteral(stepId))]),\n ),\n ]);\n });\n return rewritten([t.arrayExpression(entries)]);\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 'map': {\n const callback = argNode(0);\n if (t.isObjectExpression(callback)) {\n throw new Error(\n `.map() in ${workflowName} (${filePath}) does not yet support declarative object mappings; use a callback mapping`,\n );\n }\n if (!t.isArrowFunctionExpression(callback) && !t.isFunctionExpression(callback) && !t.isIdentifier(callback)) {\n throw new Error(\n `.map() in ${workflowName} (${filePath}) requires an inline function or a statically declared function identifier`,\n );\n }\n const args: t.Expression[] = [t.stringLiteral(`mapping_${workflowId}_${mappingOrdinal}`)];\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 workflowIdValue: string,\n methods: { name: string; args: t.Node[] }[],\n filePath: string,\n includeCommit: boolean,\n stepBindings: Map<string, string>,\n workflowBindings: Map<string, WorkflowBinding>,\n runtimeOptions?: t.ObjectExpression,\n validateInputs?: boolean,\n): t.Statement[] {\n // Start from `createWorkflow(<static id>)` and rebuild the chain one call at a time\n // using normalized arguments from `rewriteChainMethod`.\n const createWorkflowArgs = [t.cloneNode(workflowId, true)];\n const optionProperties = runtimeOptions ? runtimeOptions.properties.map(property => t.cloneNode(property, true)) : [];\n\n if (validateInputs !== undefined) {\n optionProperties.push(t.objectProperty(t.identifier('validateInputs'), t.booleanLiteral(validateInputs)));\n }\n\n if (optionProperties.length > 0) {\n createWorkflowArgs.push(t.objectExpression(optionProperties));\n }\n\n let expression: t.Expression = t.callExpression(t.identifier('createWorkflow'), createWorkflowArgs);\n let mappingOrdinal = 0;\n\n for (const method of methods) {\n const rewrittenMethod = rewriteChainMethod(\n method,\n filePath,\n exportName,\n workflowIdValue,\n mappingOrdinal,\n stepBindings,\n workflowBindings,\n );\n if (method.name === 'map') {\n mappingOrdinal += 1;\n }\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\nconst nodeBuiltinModules = new Set(builtinModules.flatMap(moduleName => [moduleName, `node:${moduleName}`]));\n\nfunction isNodeBuiltinModule(moduleId: string): boolean {\n return nodeBuiltinModules.has(moduleId);\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, WorkflowBinding>;\n workflowExports: TemporalWorkflowExport[];\n runtimeOptions?: t.ObjectExpression;\n}\n\nfunction createWorkflowTransformState(program: t.Program, filePath: string): WorkflowTransformState {\n return {\n statements: [...createTemporalWorkflowHelperStatements()],\n workflowNames: new Set<string>(),\n committedWorkflowNames: new Set<string>(),\n inlineExportedWorkflowNames: new Set<string>(),\n strippedNames: new Set<string>(),\n stepBindings: collectStepBindings(program),\n workflowBindings: collectWorkflowBindings(program, filePath),\n workflowExports: [],\n runtimeOptions: getTemporalWorkflowRuntimeOptions(program),\n };\n}\n\nfunction collectWorkflowDeclarationMetadata(statement: t.Statement, state: WorkflowTransformState): void {\n const declarationStatement = getVariableDeclarationFromStatement(statement);\n if (!declarationStatement) {\n return;\n }\n\n for (const declaration of declarationStatement.declarations) {\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n continue;\n }\n\n if (!parseWorkflowChain(declaration.init)) {\n continue;\n }\n\n state.workflowNames.add(declaration.id.name);\n if (t.isExportNamedDeclaration(statement)) {\n state.inlineExportedWorkflowNames.add(declaration.id.name);\n }\n }\n}\n\nfunction collectWorkflowExportMetadata(statement: t.Statement, state: WorkflowTransformState): void {\n if (t.isExportNamedDeclaration(statement) && statement.declaration == null && statement.source == null) {\n for (const specifier of statement.specifiers) {\n if (!t.isExportSpecifier(specifier) || !t.isIdentifier(specifier.local)) {\n continue;\n }\n\n if (!state.workflowNames.has(specifier.local.name)) {\n continue;\n }\n\n if (getExportedName(specifier.exported) === specifier.local.name) {\n state.inlineExportedWorkflowNames.add(specifier.local.name);\n }\n }\n }\n}\n\nfunction collectWorkflowTransformMetadata(program: t.Program, state: WorkflowTransformState): void {\n for (const statement of program.body) {\n collectWorkflowDeclarationMetadata(statement, state);\n\n const committedWorkflowName = getCommittedWorkflowName(statement);\n if (committedWorkflowName) {\n state.committedWorkflowNames.add(committedWorkflowName);\n }\n\n collectWorkflowExportMetadata(statement, state);\n }\n}\n\nfunction rewriteWorkflowImportDeclaration(statement: t.ImportDeclaration, state: WorkflowTransformState): void {\n if (statement.source.value === '@mastra/core/workflows') {\n const retainedSpecifiers = statement.specifiers.filter(\n specifier =>\n !(\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n (specifier.imported.name === 'createWorkflow' || specifier.imported.name === 'createStep')\n ),\n );\n\n if (retainedSpecifiers.length > 0) {\n state.statements.push(t.importDeclaration(retainedSpecifiers, t.stringLiteral(statement.source.value)));\n }\n return;\n }\n\n if (isTemporalHelperModule(statement.source.value) || isStrippedExternalModule(statement.source.value)) {\n for (const name of collectImportedNames(statement)) {\n state.strippedNames.add(name);\n }\n return;\n }\n\n state.statements.push(statement);\n}\n\nfunction getNormalizedWorkflowBindingName(name: string, state: WorkflowTransformState): string | null {\n if (!state.workflowNames.has(name)) {\n return null;\n }\n\n return state.workflowBindings.get(name)?.workflowType ?? 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, workflowId: workflowIdValue } = getWorkflowIdMetadata(\n workflowConfig,\n declaration.id.name,\n filePath,\n );\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 workflowIdValue,\n workflowChain.methods,\n filePath,\n state.committedWorkflowNames.has(declaration.id.name),\n state.stepBindings,\n state.workflowBindings,\n state.runtimeOptions,\n getWorkflowValidateInputs(workflowConfig, declaration.id.name, filePath),\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 outputOptions = {\n dir: outputDirectory,\n entryFileNames: outputFileName,\n chunkFileNames: `${baseName}-[hash].mjs`,\n format: 'esm' as const,\n sourcemap: 'inline' as const,\n };\n const generated = await bundle.generate(outputOptions);\n const forbiddenImport = generated.output\n .filter(output => output.type === 'chunk')\n .flatMap(chunk => [...chunk.imports, ...chunk.dynamicImports])\n .find(isNodeBuiltinModule);\n\n if (forbiddenImport) {\n throw new Error(\n `Temporal workflow bundle cannot depend on Node.js builtin '${forbiddenImport}'. ` +\n 'Move the dependency into an activity or remove it from workflow initialization.',\n );\n }\n\n const { output } = await bundle.write(outputOptions);\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 { RequestContext } from '@mastra/core/di';\nimport { MastraError, getErrorFromUnknown } from '@mastra/core/error';\nimport { toStandardSchema } from '@mastra/core/schema';\nimport type { PublicSchema } from '@mastra/core/schema';\nimport { validateStepInput, validateStepRequestContext } from '@mastra/core/workflows';\nimport { ApplicationFailure, CancelledFailure } from '@temporalio/activity';\nimport type { WorkerOptions, WorkerPlugin } from '@temporalio/worker';\nimport type { TemporalActivityBinding } from './transforms/activities';\nimport { buildTemporalActivitiesModule } from './transforms/activities';\nimport type { StepFailureDetails } from './transforms/temporal-workflow-runtime';\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\ninterface ActivityParams extends Record<string, unknown> {\n inputData?: unknown;\n requestContext?: Record<string, unknown>;\n validateInputs?: boolean;\n}\n\ntype GeneratedActivity = (params: ActivityParams) => Promise<unknown>;\n\ninterface GeneratedStep {\n execute: GeneratedActivity;\n inputSchema?: PublicSchema;\n requestContextSchema?: PublicSchema;\n}\n\ntype GeneratedActivitiesModule = Record<string, GeneratedActivity | GeneratedStep | undefined>;\n\n/**\n * Temporal reduces a thrown error to its class name and message, so the step's own fields go in\n * the failure's `details` for start() to rebuild the result a local run returns.\n */\nfunction toStepFailureDetails(error: unknown): StepFailureDetails {\n const serialized = getErrorFromUnknown(error, { serializeStack: false }).toJSON();\n let details: StepFailureDetails['error'];\n try {\n // The default payload converter throws on fields JSON cannot hold, such as a BigInt.\n details = JSON.parse(JSON.stringify(serialized));\n } catch {\n details = { name: serialized.name, message: serialized.message };\n }\n\n // Matched by name because `instanceof` misses a TripWire from another copy of @mastra/core.\n if (error instanceof Error && error.name === 'TripWire') {\n const { options, processorId } = error as Error & {\n options?: { retry?: boolean; metadata?: Record<string, unknown> };\n processorId?: string;\n };\n\n return {\n error: details,\n tripwire: { reason: error.message, retry: options?.retry, metadata: options?.metadata, processorId },\n };\n }\n\n return { error: details };\n}\n\n/** Fails as Temporal's own conversion would (same type, message and retries), plus the details. */\nasync function runStep(execute: () => Promise<unknown>): Promise<unknown> {\n try {\n return await execute();\n } catch (error) {\n // A step's own ApplicationFailure and Temporal's cancellation pass through unchanged.\n if (error instanceof ApplicationFailure || error instanceof CancelledFailure) {\n throw error;\n }\n\n throw ApplicationFailure.fromError(error, { details: [toStepFailureDetails(error)] });\n }\n}\n\n/**\n * Activities queued by a Workflow built before `validateInputs` existed carry no flag and run\n * unchecked. A mismatch is non-retryable because a retry gets the same input.\n */\nasync function checkStepParams(\n stepId: string,\n { inputSchema, requestContextSchema }: GeneratedStep,\n { validateInputs, ...params }: ActivityParams,\n): Promise<ActivityParams> {\n if (validateInputs !== true) {\n return params;\n }\n\n const [input, requestContext] = await Promise.all([\n validateStepInput({\n prevOutput: params.inputData,\n step: { inputSchema: inputSchema && toStandardSchema(inputSchema) },\n validateInputs: true,\n }),\n validateStepRequestContext({\n requestContext: new RequestContext(Object.entries(params.requestContext ?? {})),\n step: { id: stepId, requestContextSchema: requestContextSchema && toStandardSchema(requestContextSchema) },\n validateInputs: true,\n }),\n ]);\n\n // Input errors win, as in Mastra's step handler.\n const error = input.validationError ?? requestContext.validationError;\n\n if (error) {\n throw ApplicationFailure.create({\n type: error instanceof MastraError ? error.id : error.name,\n message: error.message,\n nonRetryable: true,\n cause: error,\n details: [toStepFailureDetails(error)],\n });\n }\n\n return { ...params, inputData: input.inputData };\n}\n\nexport class MastraPlugin implements WorkerPlugin {\n #prebuildPath: string | null = null;\n #prebuildPromise: Promise<ReturnType<typeof this.getTemporalWorkerOptions>> | null = null;\n #compiledActivitiesModules = new Map<string, Promise<GeneratedActivitiesModule>>();\n name = 'Mastra';\n\n constructor(\n private readonly entryFile: string,\n private readonly projectRoot: string = process.cwd(),\n ) {}\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 /**\n * @deprecated Please use the constructor params instead.\n */\n async prebuild({\n entryFile,\n projectRoot = process.cwd(),\n }: {\n entryFile: string;\n projectRoot?: string;\n }): Promise<ReturnType<typeof this.getTemporalWorkerOptions>> {\n return this.#prebuild(entryFile, projectRoot);\n }\n\n async #prebuild(entryFile: string, projectRoot: string): 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<GeneratedActivitiesModule> {\n const cachedModule = this.#compiledActivitiesModules.get(activitiesModulePath);\n if (cachedModule) {\n return cachedModule;\n }\n\n const modulePromise = import(\n `${pathToFileURL(activitiesModulePath).href}?t=${Date.now()}`\n ) as Promise<GeneratedActivitiesModule>;\n\n this.#compiledActivitiesModules.set(activitiesModulePath, modulePromise);\n return modulePromise;\n }\n\n #generateActivityBindings(\n activityBindings: TemporalActivityBinding[],\n compiledActivitiesPath: string,\n ): Record<string, GeneratedActivity> {\n const generatedActivities: Record<string, GeneratedActivity> = {};\n for (const binding of activityBindings) {\n if (generatedActivities[binding.stepId]) {\n continue;\n }\n\n generatedActivities[binding.stepId] = async params => {\n const activityModule = await this.#loadCompiledActivitiesModule(compiledActivitiesPath);\n const activity = activityModule[binding.exportName];\n\n // Mappings are plain functions, and so are steps generated by an older plugin version.\n // Those steps run unchecked.\n if (typeof activity === 'function') {\n return runStep(() => activity(params));\n }\n\n if (typeof activity?.execute !== 'function') {\n throw new Error(`Unable to load activity '${binding.exportName}' from ${compiledActivitiesPath}`);\n }\n\n const checkedParams = await checkStepParams(binding.stepId, activity, params);\n return runStep(() => activity.execute(checkedParams));\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 async configureWorker(options: WorkerOptions): Promise<WorkerOptions> {\n const augmentedOptions = Object.assign({}, options);\n if (!this.#prebuildPath) {\n this.#prebuildPromise ??= this.#prebuild(this.entryFile, this.projectRoot).catch(error => {\n this.#prebuildPromise = null;\n throw error;\n });\n await this.#prebuildPromise;\n }\n\n const generatedOptions = this.getTemporalWorkerOptions(this.#prebuildPath!);\n Object.assign(augmentedOptions, generatedOptions, {\n activities: {\n ...options.activities,\n ...generatedOptions.activities,\n },\n });\n\n return augmentedOptions;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,gBAAgB;CAAC;CAAc;CAAO;AAAmB;AACtE,SAAgB,YAAY,UAAkB,YAA6B;CACzE,IAAI,CAAC,YACH,cAAA,GAAaA,GAAAA,aAAAA,CAAa,UAAU,MAAM;CAG5C,QAAA,GAAOC,cAAAA,MAAAA,CAAM,YAAY;EACvB,YAAY;EACZ,SAAS;EACT,gBAAgB;CAClB,CAAC;AACH;AAEA,SAAgB,kBAAkB,MAAc,MAAuB;CACrE,OAAOC,aAAE,aAAa,IAAI,KAAK,KAAK,SAAS;AAC/C;AAEA,SAAgB,uBAAuB,QAAyB;CAC9D,OAAO,OAAO,WAAW,YAAY,2CAA2C,KAAK,MAAM;AAC7F;AAEA,MAAa,0CAA0B,IAAI,IAAI,CAAC,sBAAsB,uBAAu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AAK,sBAAsB,wBAAwB,iBAAiB,CAAC;EAE9F,OAAO;GACL,eAAe;GAKf,YAAY,KAAK,0BAA0B,kBAAkB,oBAAoB;EACnF;CACF;CAEA,MAAM,gBAAgB,SAAgD;EACpE,MAAM,mBAAmB,OAAO,OAAO,CAAC,GAAG,OAAO;EAClD,IAAI,CAAC,KAAK,eAAe;GACvB,KAAK,qBAAqB,KAAK,UAAU,KAAK,WAAW,KAAK,WAAW,CAAC,CAAC,OAAM,UAAS;IACxF,KAAK,mBAAmB;IACxB,MAAM;GACR,CAAC;GACD,MAAM,KAAK;EACb;EAEA,MAAM,mBAAmB,KAAK,yBAAyB,KAAK,aAAc;EAC1E,OAAO,OAAO,kBAAkB,kBAAkB,EAChD,YAAY;GACV,GAAG,QAAQ;GACX,GAAG,iBAAiB;EACtB,EACF,CAAC;EAED,OAAO;CACT;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.js","names":["parseWorkflowChain"],"sources":["../src/transforms/shared.ts","../src/transforms/activities.ts","../src/transforms/workflows.ts","../src/plugin.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { parse } from '@babel/parser';\nimport type { ParserPlugin } from '@babel/parser';\nimport * as t from '@babel/types';\n\nexport const parserPlugins = ['typescript', 'jsx', 'decorators-legacy'] satisfies ParserPlugin[];\nexport function parseModule(filePath: string, sourceText?: string): t.File {\n if (!sourceText) {\n sourceText = readFileSync(filePath, 'utf8');\n }\n\n return parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins,\n sourceFilename: filePath,\n });\n}\n\nexport function isIdentifierNamed(node: t.Node, name: string): boolean {\n return t.isIdentifier(node) && node.name === name;\n}\n\nexport function isTemporalHelperModule(source: string): boolean {\n return typeof source === 'string' && /(^|\\/)temporal\\.(ts|tsx|js|jsx|mts|mjs)$/.test(source);\n}\n\nexport const strippedExternalModules = new Set(['@temporalio/client', '@temporalio/envconfig']);\n\nexport function isStrippedExternalModule(source: string): boolean {\n return typeof source === 'string' && strippedExternalModules.has(source);\n}\n\nexport function collectImportedNames(statement: t.ImportDeclaration): Set<string> {\n const names = new Set<string>();\n\n for (const specifier of statement.specifiers) {\n if (\n t.isImportDefaultSpecifier(specifier) ||\n t.isImportNamespaceSpecifier(specifier) ||\n t.isImportSpecifier(specifier)\n ) {\n if (t.isIdentifier(specifier.local)) {\n names.add(specifier.local.name);\n }\n }\n }\n\n return names;\n}\n\nexport function nodeReferencesName(node: t.Node, names: Set<string>): boolean {\n let found = false;\n\n walk(node, current => {\n if (t.isIdentifier(current) && names.has(current.name)) {\n found = true;\n return false;\n }\n });\n\n return found;\n}\n\nexport function isWorkflowHelperDestructure(declaration: t.VariableDeclarator): boolean {\n if (!t.isObjectPattern(declaration.id)) {\n return false;\n }\n\n return declaration.id.properties.some(\n property =>\n t.isObjectProperty(property) &&\n !property.computed &&\n t.isIdentifier(property.value) &&\n (property.value.name === 'createStep' || property.value.name === 'createWorkflow'),\n );\n}\n\nexport function isCreateWorkflowCall(node: t.Node): node is t.CallExpression {\n return t.isCallExpression(node) && isIdentifierNamed(node.callee, 'createWorkflow');\n}\n\nexport function isCreateStepCall(node: t.Node): node is t.CallExpression {\n return t.isCallExpression(node) && isIdentifierNamed(node.callee, 'createStep');\n}\n\nexport function getObjectPropertyName(property: t.ObjectProperty | t.ObjectMethod): string | null {\n if (property.computed) {\n return null;\n }\n\n if (t.isIdentifier(property.key)) {\n return property.key.name;\n }\n\n if (t.isStringLiteral(property.key)) {\n return property.key.value;\n }\n\n return null;\n}\n\nexport function walk(node: t.Node | null | undefined, visitor: (node: t.Node) => false | void): void {\n if (!node) {\n return;\n }\n\n const result = visitor(node);\n if (result === false) {\n return;\n }\n\n const keys = (t.VISITOR_KEYS as Record<string, string[]>)[node.type] ?? [];\n for (const key of keys) {\n const value = (node as unknown as Record<string, unknown>)[key];\n\n if (Array.isArray(value)) {\n for (const child of value) {\n if (child && typeof (child as t.Node).type === 'string') {\n walk(child as t.Node, visitor);\n }\n }\n continue;\n }\n\n if (value && typeof (value as t.Node).type === 'string') {\n walk(value as t.Node, visitor);\n }\n }\n}\n\nexport function hasCreateWorkflowCall(node: t.Node): boolean {\n let found = false;\n\n walk(node, current => {\n if (isCreateWorkflowCall(current)) {\n found = true;\n return false;\n }\n });\n\n return found;\n}\n\nexport function getStepNameFromCall(node: t.CallExpression): string | null {\n const stepId = getCreateStepId(node);\n if (!stepId) {\n return null;\n }\n\n return stepId\n .replace(/[^a-zA-Z0-9]+(.)/g, (_match, char: string) => char.toUpperCase())\n .replace(/^[^a-zA-Z_$]+/, '')\n .replace(/^(.)/, (char: string) => char.toLowerCase());\n}\n\nexport function createExportedStepStatement(name: string, initializer: t.Expression): t.ExportNamedDeclaration {\n return t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(name), t.cloneNode(initializer, true))]),\n );\n}\n\nexport function collectInlineCreateSteps(\n node: t.Node,\n seenNames: Set<string>,\n statements: t.Statement[],\n onStep?: (exportName: string, call: t.CallExpression) => void,\n): void {\n walk(node, current => {\n if (!isCreateStepCall(current)) {\n return;\n }\n\n const stepName = getStepNameFromCall(current);\n if (!stepName || seenNames.has(stepName)) {\n return false;\n }\n\n seenNames.add(stepName);\n onStep?.(stepName, current);\n statements.push(createExportedStepStatement(stepName, current));\n return false;\n });\n}\n\nexport function getReturnedCreateStepCall(node: t.Node | null | undefined): t.CallExpression | null {\n if (!node) {\n return null;\n }\n\n if (t.isArrowFunctionExpression(node) && !t.isBlockStatement(node.body)) {\n return t.isCallExpression(node.body) && isIdentifierNamed(node.body.callee, 'createStep') ? node.body : null;\n }\n\n if (!t.isFunctionDeclaration(node) && !t.isFunctionExpression(node) && !t.isArrowFunctionExpression(node)) {\n return null;\n }\n\n if (!t.isBlockStatement(node.body)) {\n return null;\n }\n\n for (const statement of node.body.body) {\n if (\n t.isReturnStatement(statement) &&\n t.isCallExpression(statement.argument) &&\n isIdentifierNamed(statement.argument.callee, 'createStep')\n ) {\n return statement.argument;\n }\n }\n\n return null;\n}\n\nexport function collectCreateStepFactoryBindings(program: t.Program): Map<string, t.CallExpression> {\n const factories = new Map<string, t.CallExpression>();\n\n for (const statement of program.body) {\n const declaration = t.isExportNamedDeclaration(statement) ? statement.declaration : statement;\n\n if (t.isFunctionDeclaration(declaration) && declaration.id) {\n const createStepCall = getReturnedCreateStepCall(declaration);\n if (createStepCall) {\n factories.set(declaration.id.name, createStepCall);\n }\n continue;\n }\n\n if (!t.isVariableDeclaration(declaration)) {\n continue;\n }\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) {\n continue;\n }\n\n const createStepCall = getReturnedCreateStepCall(declarator.init);\n if (createStepCall) {\n factories.set(declarator.id.name, createStepCall);\n }\n }\n }\n\n return factories;\n}\n\nexport function getCreateStepCallFromExpression(\n node: t.Node | null | undefined,\n factoryBindings: Map<string, t.CallExpression>,\n): t.CallExpression | null {\n if (!node) {\n return null;\n }\n\n if (t.isCallExpression(node)) {\n if (isIdentifierNamed(node.callee, 'createStep')) {\n return node;\n }\n\n if (t.isIdentifier(node.callee)) {\n return factoryBindings.get(node.callee.name) ?? null;\n }\n }\n\n const returnedCreateStepCall = getReturnedCreateStepCall(node);\n if (returnedCreateStepCall) {\n return returnedCreateStepCall;\n }\n\n return null;\n}\n\nexport function getCreateStepId(node: t.Node | null | undefined): string | null {\n if (!node || !isCreateStepCall(node)) {\n return null;\n }\n\n const [config] = node.arguments;\n if (!t.isObjectExpression(config)) {\n return null;\n }\n\n for (const property of config.properties) {\n if (!t.isObjectProperty(property) && !t.isObjectMethod(property)) {\n continue;\n }\n\n if (getObjectPropertyName(property) !== 'id') {\n continue;\n }\n\n const value = t.isObjectMethod(property) ? null : property.value;\n return t.isStringLiteral(value) ? value.value : null;\n }\n\n return null;\n}\n\nexport function shouldCountIdentifierAsReference(parent: t.Node | null, key: string | null): boolean {\n if (!parent) {\n return true;\n }\n\n if ((t.isObjectProperty(parent) || t.isObjectMethod(parent)) && key === 'key' && !parent.computed) {\n return false;\n }\n\n if (t.isMemberExpression(parent) && key === 'property' && !parent.computed) {\n return false;\n }\n\n if (t.isVariableDeclarator(parent) && key === 'id') {\n return false;\n }\n\n if (\n (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent) || t.isArrowFunctionExpression(parent)) &&\n key === 'params'\n ) {\n return false;\n }\n\n if (\n (t.isFunctionDeclaration(parent) || t.isFunctionExpression(parent) || t.isClassDeclaration(parent)) &&\n key === 'id'\n ) {\n return false;\n }\n\n if (\n (t.isImportSpecifier(parent) || t.isImportDefaultSpecifier(parent) || t.isImportNamespaceSpecifier(parent)) &&\n (key === 'local' || key === 'imported')\n ) {\n return false;\n }\n\n if (t.isExportSpecifier(parent) && key === 'exported') {\n return false;\n }\n\n if (t.isLabeledStatement(parent) && key === 'label') {\n return false;\n }\n\n if (t.isCatchClause(parent) && key === 'param') {\n return false;\n }\n\n if (t.isRestElement(parent) && key === 'argument') {\n return false;\n }\n\n if (t.isAssignmentPattern(parent) && key === 'left') {\n return false;\n }\n\n if (t.isTSPropertySignature(parent) || t.isTSMethodSignature(parent) || t.isTSInterfaceHeritage(parent)) {\n return false;\n }\n\n return true;\n}\n\nexport function collectRuntimeReferencedIdentifiers(node: t.Node): Set<string> {\n const refs = new Set<string>();\n\n const visit = (current: t.Node | null | undefined, parent: t.Node | null, key: string | null) => {\n if (!current) {\n return;\n }\n\n if (current.type.startsWith('TS')) {\n return;\n }\n\n if (t.isIdentifier(current)) {\n if (shouldCountIdentifierAsReference(parent, key)) {\n refs.add(current.name);\n }\n return;\n }\n\n for (const visitorKey of t.VISITOR_KEYS[current.type] ?? []) {\n const value = (current as unknown as Record<string, unknown>)[visitorKey];\n if (Array.isArray(value)) {\n value.forEach(child => {\n if (t.isNode(child)) {\n visit(child, current, visitorKey);\n }\n });\n continue;\n }\n\n if (t.isNode(value)) {\n visit(value, current, visitorKey);\n }\n }\n };\n\n visit(node, null, null);\n return refs;\n}\n\nexport function pruneUnusedTopLevelBindings(statements: t.Statement[]): t.Statement[] {\n const bindings = new Map<string, { refs: Set<string>; statementIndex: number }>();\n const liveStatements = new Set<number>();\n const queue: number[] = [];\n\n const markLive = (statementIndex: number) => {\n if (liveStatements.has(statementIndex)) {\n return;\n }\n\n liveStatements.add(statementIndex);\n queue.push(statementIndex);\n };\n\n statements.forEach((statement, statementIndex) => {\n if (t.isImportDeclaration(statement)) {\n for (const specifier of statement.specifiers) {\n bindings.set(specifier.local.name, { refs: new Set(), statementIndex });\n }\n return;\n }\n\n if (t.isVariableDeclaration(statement)) {\n for (const declaration of statement.declarations) {\n if (t.isIdentifier(declaration.id)) {\n bindings.set(declaration.id.name, {\n refs: declaration.init ? collectRuntimeReferencedIdentifiers(declaration.init) : new Set(),\n statementIndex,\n });\n }\n }\n return;\n }\n\n if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n for (const declaration of statement.declaration.declarations) {\n if (t.isIdentifier(declaration.id)) {\n bindings.set(declaration.id.name, {\n refs: declaration.init ? collectRuntimeReferencedIdentifiers(declaration.init) : new Set(),\n statementIndex,\n });\n }\n }\n markLive(statementIndex);\n return;\n }\n\n markLive(statementIndex);\n });\n\n while (queue.length > 0) {\n const statementIndex = queue.pop()!;\n const statement = statements[statementIndex];\n if (!statement) {\n continue;\n }\n\n const refs = new Set<string>();\n\n if (t.isImportDeclaration(statement)) {\n continue;\n }\n\n if (t.isVariableDeclaration(statement)) {\n for (const declaration of statement.declarations) {\n if (declaration.init) {\n for (const ref of collectRuntimeReferencedIdentifiers(declaration.init)) {\n refs.add(ref);\n }\n }\n }\n } else if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n for (const declaration of statement.declaration.declarations) {\n if (declaration.init) {\n for (const ref of collectRuntimeReferencedIdentifiers(declaration.init)) {\n refs.add(ref);\n }\n }\n }\n } else {\n for (const ref of collectRuntimeReferencedIdentifiers(statement)) {\n refs.add(ref);\n }\n }\n\n for (const ref of refs) {\n const binding = bindings.get(ref);\n if (binding) {\n markLive(binding.statementIndex);\n }\n }\n }\n\n const prunedStatements: t.Statement[] = [];\n\n statements.forEach((statement, statementIndex) => {\n if (!liveStatements.has(statementIndex)) {\n return;\n }\n\n if (t.isImportDeclaration(statement)) {\n const specifiers = statement.specifiers.filter(specifier =>\n liveStatements.has(bindings.get(specifier.local.name)?.statementIndex ?? -1),\n );\n if (specifiers.length > 0) {\n prunedStatements.push(t.importDeclaration(specifiers, statement.source));\n }\n return;\n }\n\n if (t.isVariableDeclaration(statement)) {\n const declarations = statement.declarations.filter(\n declaration =>\n !t.isIdentifier(declaration.id) ||\n liveStatements.has(bindings.get(declaration.id.name)?.statementIndex ?? -1),\n );\n if (declarations.length > 0) {\n prunedStatements.push(t.variableDeclaration(statement.kind, declarations));\n }\n return;\n }\n\n if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n const declarations = statement.declaration.declarations.filter(\n declaration =>\n !t.isIdentifier(declaration.id) ||\n liveStatements.has(bindings.get(declaration.id.name)?.statementIndex ?? -1),\n );\n if (declarations.length > 0) {\n prunedStatements.push(\n t.exportNamedDeclaration(t.variableDeclaration(statement.declaration.kind, declarations)),\n );\n }\n return;\n }\n\n prunedStatements.push(statement);\n });\n\n return prunedStatements;\n}\n","import path, { basename, join } from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { rollup } from 'rollup';\nimport type { SourceMapInput } from 'rollup';\nimport {\n collectCreateStepFactoryBindings,\n collectImportedNames,\n collectInlineCreateSteps,\n createExportedStepStatement,\n getCreateStepCallFromExpression,\n getCreateStepId,\n getObjectPropertyName,\n getStepNameFromCall,\n hasCreateWorkflowCall,\n isCreateStepCall,\n isStrippedExternalModule,\n isTemporalHelperModule,\n isWorkflowHelperDestructure,\n nodeReferencesName,\n parserPlugins,\n pruneUnusedTopLevelBindings,\n walk,\n} from './shared';\n\nexport interface TemporalActivityBinding {\n exportName: string;\n stepId: string;\n}\n\nexport interface BuildTemporalActivitiesModuleResult {\n outputPath: string;\n activityBindings: TemporalActivityBinding[];\n}\n\nexport function collectTemporalActivityBindings(sourceText: string, filePath: string): TemporalActivityBinding[] {\n const ast = parse(sourceText, {\n sourceType: 'module',\n plugins: parserPlugins,\n sourceFilename: filePath,\n });\n\n const bindings: TemporalActivityBinding[] = [];\n const seenNames = new Set<string>();\n const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);\n\n const addBinding = (call: t.CallExpression, exportName = getStepNameFromCall(call)): void => {\n const stepId = getCreateStepId(call);\n\n if (!exportName || !stepId || seenNames.has(exportName)) {\n return;\n }\n\n seenNames.add(exportName);\n bindings.push({ exportName, stepId });\n };\n\n const collectInlineBindings = (node: t.Node): void => {\n walk(node, current => {\n if (!isCreateStepCall(current)) {\n return;\n }\n\n addBinding(current);\n return false;\n });\n };\n\n for (const statement of ast.program.body) {\n if (\n t.isVariableDeclaration(statement) ||\n (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n ) {\n const declarationStatement = t.isVariableDeclaration(statement)\n ? statement\n : (statement.declaration as t.VariableDeclaration);\n\n for (const declaration of declarationStatement.declarations) {\n if (!declaration.init) {\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n if (createStepCall) {\n addBinding(createStepCall, t.isIdentifier(declaration.id) ? declaration.id.name : undefined);\n continue;\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n collectInlineBindings(declaration.init);\n }\n }\n\n continue;\n }\n\n if (hasCreateWorkflowCall(statement)) {\n collectInlineBindings(statement);\n }\n }\n\n return bindings;\n}\n\nfunction normalizeImportPath(importPath: string, extension: string): string {\n const normalizedPath = importPath.split(path.sep).join('/');\n const pathWithExtension =\n extension === '.mjs' || extension === '.cjs' ? normalizedPath : normalizedPath.replace(/\\.[cm]?[jt]sx?$/, '');\n\n return pathWithExtension.startsWith('.') ? pathWithExtension : `./${pathWithExtension}`;\n}\n\nfunction rebaseModulePath(modulePath: string, sourceFilePath: string, outputFilePath: string): string {\n if (!modulePath.startsWith('.')) {\n return modulePath;\n }\n\n const resolvedPath = path.resolve(path.dirname(sourceFilePath), modulePath);\n const relativePath = path.relative(path.dirname(outputFilePath), resolvedPath);\n return normalizeImportPath(relativePath, path.extname(resolvedPath));\n}\n\nfunction 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 = node;\n\n while (t.isCallExpression(current) && t.isMemberExpression(current.callee) && !current.callee.computed) {\n if (!t.isIdentifier(current.callee.property)) {\n return null;\n }\n methods.unshift({ name: current.callee.property.name, args: current.arguments as t.Node[] });\n current = current.callee.object;\n }\n\n if (!t.isCallExpression(current) || !t.isIdentifier(current.callee, { name: 'createWorkflow' })) {\n return null;\n }\n\n return { createWorkflowCall: current, methods };\n}\n\nfunction getStaticWorkflowId(call: t.CallExpression, filePath: string): string {\n const [config] = call.arguments;\n if (!t.isObjectExpression(config)) {\n throw new Error(`Unable to determine workflow config in ${filePath}`);\n }\n\n for (const property of config.properties) {\n if (!t.isObjectProperty(property) || getObjectPropertyName(property) !== 'id') {\n continue;\n }\n if (t.isStringLiteral(property.value)) {\n return property.value.value;\n }\n if (t.isTemplateLiteral(property.value) && property.value.expressions.length === 0) {\n return property.value.quasis[0]?.value.cooked ?? '';\n }\n }\n\n throw new Error(`Workflow id must be a static string in ${filePath}`);\n}\n\nfunction toExportName(id: string): string {\n return id\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\nfunction collectStaticFunctionBindings(program: t.Program): Set<string> {\n const bindings = new Set<string>();\n for (const statement of program.body) {\n const declaration = t.isExportNamedDeclaration(statement) ? statement.declaration : statement;\n if (t.isFunctionDeclaration(declaration) && declaration.id) {\n bindings.add(declaration.id.name);\n continue;\n }\n if (!t.isVariableDeclaration(declaration) || declaration.kind !== 'const') {\n continue;\n }\n for (const declarator of declaration.declarations) {\n if (\n t.isIdentifier(declarator.id) &&\n (t.isArrowFunctionExpression(declarator.init) || t.isFunctionExpression(declarator.init))\n ) {\n bindings.add(declarator.id.name);\n }\n }\n }\n return bindings;\n}\n\nfunction collectTopLevelBindingNames(program: t.Program): Set<string> {\n const bindings = new Set<string>();\n for (const statement of program.body) {\n for (const name of Object.keys(t.getBindingIdentifiers(statement))) {\n bindings.add(name);\n }\n }\n return bindings;\n}\n\nfunction createMappingActivityStatements(\n workflowExpression: t.Expression,\n filePath: string,\n staticFunctionBindings: Set<string>,\n usedExportNames: Set<string>,\n requestContextClassName: string,\n addBinding: (exportName: string, stepId: string) => void,\n): t.Statement[] {\n const chain = parseWorkflowChain(workflowExpression);\n if (!chain) {\n return [];\n }\n\n const workflowId = getStaticWorkflowId(chain.createWorkflowCall, filePath);\n const statements: t.Statement[] = [];\n let mappingOrdinal = 0;\n\n for (const method of chain.methods) {\n if (method.name !== 'map') {\n continue;\n }\n\n const [callback] = method.args;\n if (t.isObjectExpression(callback)) {\n throw new Error(\n `.map() in workflow ${workflowId} (${filePath}) does not yet support declarative object mappings`,\n );\n }\n if (\n !t.isArrowFunctionExpression(callback) &&\n !t.isFunctionExpression(callback) &&\n !(t.isIdentifier(callback) && staticFunctionBindings.has(callback.name))\n ) {\n throw new Error(\n `.map() in workflow ${workflowId} (${filePath}) requires an inline function or a statically declared function identifier`,\n );\n }\n\n const mappingId = `mapping_${workflowId}_${mappingOrdinal++}`;\n const baseExportName = toExportName(mappingId);\n let exportName = baseExportName;\n let exportSuffix = 1;\n while (usedExportNames.has(exportName)) {\n exportName = `${baseExportName}${exportSuffix++}`;\n }\n usedExportNames.add(exportName);\n const contextNames = ['requestContext', 'runId', 'resourceId', 'workflowId'];\n const params = t.objectPattern([\n t.objectProperty(t.identifier('inputData'), t.identifier('inputData'), false, true),\n t.objectProperty(t.identifier('initData'), t.identifier('initData'), false, true),\n ...contextNames.map(name => t.objectProperty(t.identifier(name), t.identifier(name), false, true)),\n ]);\n const callbackContext = t.objectExpression([\n t.objectProperty(t.identifier('inputData'), t.identifier('inputData'), false, true),\n t.objectProperty(t.identifier('getInitData'), t.arrowFunctionExpression([], t.identifier('initData'))),\n t.objectProperty(\n t.identifier('requestContext'),\n t.newExpression(t.identifier(requestContextClassName), [t.identifier('requestContext')]),\n ),\n ...contextNames\n .filter(name => name !== 'requestContext')\n .map(name => t.objectProperty(t.identifier(name), t.identifier(name), false, true)),\n ]);\n const callbackExpression = t.cloneNode(callback, true) as t.Expression;\n const body = t.callExpression(callbackExpression, [callbackContext]);\n statements.push(\n t.exportNamedDeclaration(\n t.variableDeclaration('const', [\n t.variableDeclarator(t.identifier(exportName), t.arrowFunctionExpression([params], body, true)),\n ]),\n ),\n );\n addBinding(exportName, mappingId);\n }\n\n return statements;\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 requestContextClassName: string,\n): t.Statement[] {\n const executeBody = mastraImportPath\n ? `\n const { mastra } = await import(${JSON.stringify(mastraImportPath)});\n return executeTemporalStep(args, { ...withRequestContext(params, args), mastra });\n `\n : hasMastraBinding\n ? 'return executeTemporalStep(args, { ...withRequestContext(params, args), mastra });'\n : 'return executeTemporalStep(args, withRequestContext(params, args));';\n\n const helperSource = `\n function withRequestContext(params, args) {\n const { requestContext, initData, ...rest } = params;\n let suspended;\n return {\n ...rest,\n requestContext: new ${requestContextClassName}(requestContext),\n getInitData: () => initData,\n suspend: async (suspendPayload, options) => {\n const parsedSuspendPayload = await parseWithSchema(args.suspendSchema, suspendPayload, 'Suspend payload');\n suspended = {\n __temporalSuspension: true,\n suspendPayload: parsedSuspendPayload,\n ...(options?.resumeLabel !== undefined && { resumeLabel: options.resumeLabel }),\n };\n },\n __getTemporalSuspension: () => suspended,\n };\n }\n\n async function parseWithSchema(schema, value, label) {\n if (!schema) return value;\n if (schema['~standard']?.validate) {\n const result = await schema['~standard'].validate(value);\n if ('issues' in result && result.issues?.length) {\n throw new Error(label + ' validation failed: ' + result.issues.map(issue => issue.message).join(', '));\n }\n return result.value;\n }\n if (typeof schema.parseAsync === 'function') return schema.parseAsync(value);\n if (typeof schema.parse === 'function') return schema.parse(value);\n return value;\n }\n\n async function executeTemporalStep(args, context) {\n const result = await args.execute(context);\n return context.__getTemporalSuspension() ?? result;\n }\n\n function createStep(args) {\n return {\n inputSchema: args.inputSchema,\n requestContextSchema: args.requestContextSchema,\n suspendSchema: args.suspendSchema,\n resumeSchema: args.resumeSchema,\n execute: async (params) => {\n ${executeBody}\n },\n };\n }\n `;\n\n return parse(helperSource, {\n sourceType: 'module',\n plugins: parserPlugins,\n }).program.body;\n}\n\nexport async function buildTemporalActivitiesModule(\n entryFile: string,\n outputDirectory: string,\n outputFileName: string,\n): Promise<BuildTemporalActivitiesModuleResult> {\n const activityBindings: TemporalActivityBinding[] = [];\n const seenActivityBindingNames = new Set<string>();\n const addGeneratedActivityBinding = (exportName: string, stepId: string): void => {\n if (seenActivityBindingNames.has(exportName)) {\n return;\n }\n\n seenActivityBindingNames.add(exportName);\n activityBindings.push({ exportName, stepId });\n };\n const addActivityBinding = (exportName: string, call: t.CallExpression): void => {\n const stepId = getCreateStepId(call);\n if (stepId) {\n addGeneratedActivityBinding(exportName, stepId);\n }\n };\n\n const bundle = await rollup({\n input: entryFile,\n treeshake: 'smallest',\n logLevel: 'silent',\n plugins: [\n {\n name: 'temporal-workflow-transform',\n transform(code, id) {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: parserPlugins,\n sourceFilename: id,\n });\n\n const usedExportNames = collectTopLevelBindingNames(ast.program);\n let requestContextClassName = 'TemporalRequestContext';\n let requestContextSuffix = 1;\n while (usedExportNames.has(requestContextClassName)) {\n requestContextClassName = `TemporalRequestContext${requestContextSuffix++}`;\n }\n usedExportNames.add(requestContextClassName);\n\n const statements: t.Statement[] = [\n t.importDeclaration(\n [t.importSpecifier(t.identifier(requestContextClassName), t.identifier('RequestContext'))],\n t.stringLiteral('@mastra/core/di'),\n ),\n ];\n const seenNames = new Set<string>();\n const strippedNames = new Set<string>();\n const workflowBindingNames = collectWorkflowBindingNames(ast);\n const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);\n const staticFunctionBindings = collectStaticFunctionBindings(ast.program);\n const sourceFilePath = id;\n const hasMastraBinding = hasLocalMastraBinding(ast);\n let helperInserted = false;\n\n const ensureHelperInserted = () => {\n if (helperInserted) {\n return;\n }\n\n statements.push(\n ...createTemporalActivitiesHelperStatements(null, hasMastraBinding, requestContextClassName),\n );\n helperInserted = true;\n };\n\n for (const statement of ast.program.body) {\n if (t.isImportDeclaration(statement)) {\n if (statement.source.value === '@mastra/core/workflows') {\n const retainedSpecifiers = statement.specifiers.filter(\n specifier =>\n !(\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n (specifier.imported.name === 'createStep' || specifier.imported.name === 'createWorkflow')\n ),\n );\n\n if (retainedSpecifiers.length > 0) {\n statements.push(t.importDeclaration(retainedSpecifiers, t.stringLiteral(statement.source.value)));\n }\n continue;\n }\n\n if (isTemporalHelperModule(statement.source.value) || isStrippedExternalModule(statement.source.value)) {\n for (const name of collectImportedNames(statement)) {\n strippedNames.add(name);\n }\n continue;\n }\n\n const rewrittenSource = rebaseModulePath(statement.source.value, sourceFilePath, id);\n if (rewrittenSource === statement.source.value) {\n statements.push(statement);\n } else {\n statements.push(\n t.importDeclaration(\n statement.specifiers.map(specifier => t.cloneNode(specifier, true)),\n t.stringLiteral(rewrittenSource),\n ),\n );\n }\n continue;\n }\n\n if (\n t.isFunctionDeclaration(statement) ||\n t.isClassDeclaration(statement) ||\n t.isTSTypeAliasDeclaration(statement) ||\n t.isTSInterfaceDeclaration(statement) ||\n t.isTSEnumDeclaration(statement)\n ) {\n ensureHelperInserted();\n statements.push(statement);\n continue;\n }\n\n if (t.isExpressionStatement(statement) && nodeReferencesName(statement, strippedNames)) {\n continue;\n }\n\n ensureHelperInserted();\n\n if (t.isVariableDeclaration(statement)) {\n const declarations: t.VariableDeclarator[] = [];\n\n for (const declaration of statement.declarations) {\n if (isWorkflowHelperDestructure(declaration)) {\n continue;\n }\n\n if (\n declaration.init &&\n nodeReferencesName(declaration.init, strippedNames) &&\n !isMastraDeclaration(declaration)\n ) {\n if (t.isIdentifier(declaration.id)) {\n strippedNames.add(declaration.id.name);\n }\n continue;\n }\n\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n declarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n if (createStepCall) {\n const isFactoryCall =\n t.isCallExpression(declaration.init) &&\n t.isIdentifier(declaration.init.callee) &&\n stepFactoryBindings.has(declaration.init.callee.name);\n\n if (isFactoryCall) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n statements.push(\n t.exportNamedDeclaration(t.variableDeclaration(statement.kind, [t.cloneNode(declaration, true)])),\n );\n continue;\n }\n\n if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n statements.push(createExportedStepStatement(declaration.id.name, createStepCall));\n continue;\n }\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n workflowBindingNames.add(declaration.id.name);\n strippedNames.add(declaration.id.name);\n statements.push(\n ...createMappingActivityStatements(\n declaration.init,\n sourceFilePath,\n staticFunctionBindings,\n usedExportNames,\n requestContextClassName,\n addGeneratedActivityBinding,\n ),\n );\n collectInlineCreateSteps(declaration.init, seenNames, statements, addActivityBinding);\n continue;\n }\n\n declarations.push(createPreservedDeclaration(declaration, strippedNames));\n }\n\n if (declarations.length > 0) {\n statements.push(\n t.variableDeclaration(\n statement.kind,\n declarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n );\n }\n continue;\n }\n\n if (t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)) {\n const exportedDeclarations: t.VariableDeclarator[] = [];\n const localDeclarations: t.VariableDeclarator[] = [];\n\n for (const declaration of statement.declaration.declarations) {\n if (isWorkflowHelperDestructure(declaration)) {\n continue;\n }\n\n if (\n declaration.init &&\n nodeReferencesName(declaration.init, strippedNames) &&\n !isMastraDeclaration(declaration)\n ) {\n if (t.isIdentifier(declaration.id)) {\n strippedNames.add(declaration.id.name);\n }\n continue;\n }\n\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n if (createStepCall) {\n const isFactoryCall =\n t.isCallExpression(declaration.init) &&\n t.isIdentifier(declaration.init.callee) &&\n stepFactoryBindings.has(declaration.init.callee.name);\n\n if (isFactoryCall) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n if (isCreateStepCall(declaration.init)) {\n seenNames.add(declaration.id.name);\n addActivityBinding(declaration.id.name, createStepCall);\n statements.push(createExportedStepStatement(declaration.id.name, createStepCall));\n continue;\n }\n }\n\n if (hasCreateWorkflowCall(declaration.init)) {\n workflowBindingNames.add(declaration.id.name);\n strippedNames.add(declaration.id.name);\n statements.push(\n ...createMappingActivityStatements(\n declaration.init,\n sourceFilePath,\n staticFunctionBindings,\n usedExportNames,\n requestContextClassName,\n addGeneratedActivityBinding,\n ),\n );\n collectInlineCreateSteps(declaration.init, seenNames, statements, addActivityBinding);\n continue;\n }\n\n if (declaration.id.name === 'mastra') {\n localDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n continue;\n }\n\n exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));\n }\n\n if (localDeclarations.length > 0) {\n statements.push(\n t.variableDeclaration(\n statement.declaration.kind,\n localDeclarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n );\n }\n\n if (exportedDeclarations.length > 0) {\n statements.push(\n t.exportNamedDeclaration(\n t.variableDeclaration(\n statement.declaration.kind,\n exportedDeclarations.map(declaration => t.cloneNode(declaration, true)),\n ),\n ),\n );\n }\n continue;\n }\n\n if (t.isExpressionStatement(statement)) {\n if (nodeReferencesName(statement, workflowBindingNames) || nodeReferencesName(statement, strippedNames)) {\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n if (t.isExportNamedDeclaration(statement)) {\n if (\n t.isFunctionDeclaration(statement.declaration) ||\n t.isClassDeclaration(statement.declaration) ||\n t.isTSTypeAliasDeclaration(statement.declaration) ||\n t.isTSInterfaceDeclaration(statement.declaration) ||\n t.isTSEnumDeclaration(statement.declaration)\n ) {\n ensureHelperInserted();\n statements.push(statement);\n continue;\n }\n\n if (statement.declaration == null && statement.source == null) {\n const retainedSpecifiers = statement.specifiers.filter(\n specifier =>\n t.isExportSpecifier(specifier) &&\n t.isIdentifier(specifier.local) &&\n specifier.local.name !== 'mastra' &&\n !workflowBindingNames.has(specifier.local.name) &&\n !seenNames.has(specifier.local.name),\n );\n\n if (retainedSpecifiers.length > 0) {\n statements.push(t.exportNamedDeclaration(null, retainedSpecifiers));\n }\n continue;\n }\n\n if (statement.declaration == null && statement.source) {\n const mastraSpecifiers = statement.specifiers.filter(\n specifier =>\n t.isExportSpecifier(specifier) &&\n t.isIdentifier(specifier.exported, { name: 'mastra' }) &&\n t.isIdentifier(specifier.local, { name: 'mastra' }),\n );\n\n if (mastraSpecifiers.length > 0) {\n statements.push(\n t.importDeclaration(\n [t.importSpecifier(t.identifier('mastra'), t.identifier('mastra'))],\n t.stringLiteral(rebaseModulePath(statement.source.value, sourceFilePath, id)),\n ),\n );\n }\n continue;\n }\n\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n if (t.isExportDefaultDeclaration(statement)) {\n if (t.isIdentifier(statement.declaration) && workflowBindingNames.has(statement.declaration.name)) {\n continue;\n }\n\n collectInlineCreateSteps(statement, seenNames, statements, addActivityBinding);\n continue;\n }\n\n statements.push(statement);\n }\n\n ensureHelperInserted();\n\n const transformedSource = generate(t.file(t.program(pruneUnusedTopLevelBindings(statements), [], 'module')), {\n sourceMaps: true,\n });\n\n return {\n code: transformedSource.code,\n map: transformedSource.map\n ? ({ ...transformedSource.map, file: transformedSource.map.file ?? undefined } as SourceMapInput)\n : undefined,\n };\n },\n },\n ],\n });\n\n try {\n const baseName = basename(outputFileName);\n const { output } = await bundle.write({\n dir: outputDirectory,\n entryFileNames: outputFileName,\n chunkFileNames: `${baseName}-[hash].mjs`,\n format: 'esm',\n sourcemap: 'inline',\n });\n\n return {\n outputPath: join(outputDirectory, output.find(chunk => chunk.type === 'chunk' && chunk.isEntry)!.fileName),\n activityBindings,\n };\n } finally {\n await bundle.close();\n }\n}\n","import { readFileSync } from 'node:fs';\nimport { builtinModules } from 'node:module';\nimport { basename, join } from 'node:path';\nimport { generate } from '@babel/generator';\nimport { parse } from '@babel/parser';\nimport * as t from '@babel/types';\nimport { rollup } from 'rollup';\nimport { toWorkflowType } from '../utils';\nimport {\n collectCreateStepFactoryBindings,\n collectImportedNames,\n getCreateStepCallFromExpression,\n getCreateStepId,\n getObjectPropertyName,\n isCreateWorkflowCall,\n isIdentifierNamed,\n isStrippedExternalModule,\n isTemporalHelperModule,\n isWorkflowHelperDestructure,\n nodeReferencesName,\n parseModule,\n parserPlugins,\n pruneUnusedTopLevelBindings,\n} from './shared';\n\n/**\n * Temporal workflow types must be static so the loader can deterministically map\n * a source workflow to the runtime export name used by the worker.\n */\nfunction getWorkflowIdMetadata(\n workflowConfig: t.ObjectExpression,\n workflowName: string,\n filePath: string,\n): { expression: t.Expression; workflowId: string } {\n for (const property of workflowConfig.properties) {\n if (!t.isObjectProperty(property) || getObjectPropertyName(property) !== 'id') {\n continue;\n }\n\n if (!t.isExpression(property.value)) {\n break;\n }\n\n if (t.isStringLiteral(property.value)) {\n return {\n expression: t.cloneNode(property.value, true),\n workflowId: property.value.value,\n };\n }\n\n if (t.isTemplateLiteral(property.value) && property.value.expressions.length === 0) {\n return {\n expression: t.cloneNode(property.value, true),\n workflowId: property.value.quasis[0]?.value.cooked ?? '',\n };\n }\n\n throw new Error(`Workflow id must be a static string for ${workflowName} in ${filePath}`);\n }\n\n throw new Error(`Unable to determine workflow id for ${workflowName} in ${filePath}`);\n}\n\ntype StaticProperty = { readable: true; value?: t.Node } | { readable: false };\n\nfunction getStaticKey(property: t.ObjectProperty | t.ObjectMethod): string | null {\n if (property.computed && t.isTemplateLiteral(property.key) && property.key.expressions.length === 0) {\n return property.key.quasis[0]?.value.cooked ?? null;\n }\n\n if (property.computed && t.isStringLiteral(property.key)) {\n return property.key.value;\n }\n\n return getObjectPropertyName(property);\n}\n\nfunction isDynamicKey(property: t.ObjectProperty | t.ObjectMethod): boolean {\n return (\n property.computed &&\n !t.isStringLiteral(property.key) &&\n !(t.isTemplateLiteral(property.key) && property.key.expressions.length === 0)\n );\n}\n\n// A later property overrides an earlier one, so a spread or `[key]` hides `name` only when it\n// comes after the last `name` written out in source.\nfunction findStaticProperty(object: t.ObjectExpression, name: string): StaticProperty {\n let found: StaticProperty = { readable: true };\n\n for (const property of object.properties) {\n if (t.isSpreadElement(property) || isDynamicKey(property)) {\n found = { readable: false };\n continue;\n }\n\n if (getStaticKey(property) === name) {\n found = t.isObjectProperty(property) ? { readable: true, value: property.value } : { readable: false };\n }\n }\n\n return found;\n}\n\n/**\n * Read at build time so runs started outside `TemporalRun` (Schedules, the Temporal CLI) use the\n * workflow's setting too. `TemporalRun` also sends the setting, which covers `options` the build\n * cannot read.\n */\nfunction getWorkflowValidateInputs(\n workflowConfig: t.ObjectExpression,\n workflowName: string,\n filePath: string,\n): boolean | undefined {\n const options = findStaticProperty(workflowConfig, 'options');\n if (options.readable && !options.value) {\n return undefined;\n }\n\n if (options.readable && t.isObjectExpression(options.value)) {\n const validateInputs = findStaticProperty(options.value, 'validateInputs');\n if (validateInputs.readable && !validateInputs.value) {\n return undefined;\n }\n\n if (validateInputs.readable && t.isBooleanLiteral(validateInputs.value)) {\n return validateInputs.value.value;\n }\n }\n\n console.warn(\n `[@mastra/temporal] Could not read options.validateInputs of ${workflowName} in ${filePath} at build time. ` +\n 'Runs started with run.start() or run.startAsync() use the workflow setting. ' +\n 'Runs started another way, such as from a Temporal Schedule, check step input.',\n );\n return undefined;\n}\n\n/**\n * The helper runtime lives in its own `.mjs` module so it can be linted and unit-tested\n * like normal code. We parse that file directly here instead of using `Function#toString()`,\n * which keeps fixture output stable under Vitest/Vite instrumentation.\n */\nfunction createTemporalWorkflowHelperStatements(): t.Statement[] {\n const temporalWorkflowRuntimeSource = readFileSync(\n new URL('./temporal-workflow-runtime.mjs', import.meta.url),\n 'utf8',\n );\n\n const helperProgram = parse(temporalWorkflowRuntimeSource, {\n sourceType: 'module',\n plugins: parserPlugins,\n }).program.body;\n\n return helperProgram.flatMap(statement => {\n if (t.isExportNamedDeclaration(statement) && statement.declaration) {\n return [statement.declaration];\n }\n\n return [statement];\n });\n}\n\nfunction getTemporalWorkflowRuntimeOptions(program: t.Program): t.ObjectExpression | undefined {\n for (const statement of program.body) {\n const declarationStatement = t.isVariableDeclaration(statement)\n ? statement\n : t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration)\n ? statement.declaration\n : null;\n\n if (!declarationStatement) {\n continue;\n }\n\n for (const declaration of declarationStatement.declarations) {\n if (!isWorkflowHelperDestructure(declaration) || !t.isCallExpression(declaration.init)) {\n continue;\n }\n\n const [temporalParams] = declaration.init.arguments;\n if (!temporalParams || !t.isObjectExpression(temporalParams)) {\n continue;\n }\n\n const runtimeProperties = new Map<string, t.ObjectProperty>();\n const collectRuntimeProperties = (params: t.ObjectExpression): void => {\n for (const property of params.properties) {\n if (t.isSpreadElement(property)) {\n if (!t.isObjectExpression(property.argument)) {\n continue;\n }\n collectRuntimeProperties(property.argument);\n continue;\n }\n if (!t.isObjectProperty(property) || !t.isExpression(property.value)) {\n continue;\n }\n const name = getObjectPropertyName(property);\n if (name === 'startToCloseTimeout' || name === 'retry') {\n runtimeProperties.set(name, t.objectProperty(t.identifier(name), t.cloneNode(property.value, true)));\n }\n }\n };\n collectRuntimeProperties(temporalParams);\n if (runtimeProperties.size > 0) {\n return t.objectExpression([...runtimeProperties.values()]);\n }\n }\n }\n}\n\n/**\n * Walks a chained workflow expression like `createWorkflow(...).then(...).commit()`\n * back to its root `createWorkflow(...)` call while preserving method order.\n */\nfunction parseWorkflowChain(\n node: t.Node,\n): { createWorkflowCall: t.CallExpression; methods: { name: string; args: t.Node[] }[] } | null {\n const methods: { name: string; args: t.Node[] }[] = [];\n let current: t.Node = node;\n\n // Example:\n // createWorkflow(...).then(stepA).sleep(1000).commit()\n // is peeled from the outside in, producing:\n // [then(stepA), sleep(1000), commit()]\n while (t.isCallExpression(current) && t.isMemberExpression(current.callee) && !current.callee.computed) {\n if (!t.isIdentifier(current.callee.property)) {\n return null;\n }\n\n methods.unshift({\n name: current.callee.property.name,\n args: current.arguments as t.Node[],\n });\n current = current.callee.object;\n }\n\n if (!isCreateWorkflowCall(current)) {\n return null;\n }\n\n return {\n createWorkflowCall: current,\n methods,\n };\n}\n\n/**\n * Maps local `const someStep = createStep({ id: 'some-step' })` bindings to their\n * runtime ids so later chain rewriting can replace identifier references with ids.\n */\nfunction collectStepBindings(program: t.Program): Map<string, string> {\n const stepBindings = new Map<string, string>();\n const stepFactoryBindings = collectCreateStepFactoryBindings(program);\n\n for (const [factoryName, createStepCall] of stepFactoryBindings) {\n const stepId = getCreateStepId(createStepCall);\n if (stepId) {\n stepBindings.set(factoryName, stepId);\n }\n }\n\n for (const statement of program.body) {\n if (\n !t.isVariableDeclaration(statement) &&\n !(t.isExportNamedDeclaration(statement) && t.isVariableDeclaration(statement.declaration))\n ) {\n continue;\n }\n\n const declarationStatement = t.isVariableDeclaration(statement)\n ? statement\n : (statement.declaration as t.VariableDeclaration);\n\n for (const declaration of declarationStatement.declarations) {\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n continue;\n }\n\n const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);\n const stepId = getCreateStepId(createStepCall);\n if (stepId) {\n stepBindings.set(declaration.id.name, stepId);\n }\n }\n }\n\n return stepBindings;\n}\n\n// The Temporal workflow type the child runs as, and the Mastra workflow id its step records use.\ntype WorkflowBinding = { workflowType: string; workflowId: string };\n\nfunction collectWorkflowBindings(program: t.Program, filePath: string): Map<string, WorkflowBinding> {\n const workflowBindings = new Map<string, WorkflowBinding>();\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, { workflowType: toWorkflowType(workflowId), workflowId });\n }\n }\n\n return workflowBindings;\n}\n\n/**\n * Accepts the few AST node shapes we allow as \"step references\" in workflow chains\n * and normalizes them to a single step id string.\n */\nfunction getWorkflowStepName(node: t.Node | null | undefined, stepBindings: Map<string, string>): string | null {\n if (!node) {\n return null;\n }\n\n if (t.isIdentifier(node)) {\n return stepBindings.get(node.name) ?? node.name;\n }\n\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n\n if (t.isCallExpression(node) && t.isIdentifier(node.callee)) {\n return stepBindings.get(node.callee.name) ?? getCreateStepId(node);\n }\n\n return getCreateStepId(node);\n}\n\n/**\n * Normalizes fluent workflow builder calls into the simpler Temporal runtime shape.\n *\n * Most step references collapse down to step ids so the generated workflow can call\n * activities by id instead of keeping the original `createStep` definitions around.\n */\nfunction rewriteChainMethod(\n method: { name: string; args: t.Node[] },\n filePath: string,\n workflowName: string,\n workflowId: string,\n mappingOrdinal: number,\n stepBindings: Map<string, string>,\n workflowBindings: Map<string, WorkflowBinding>,\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 binding = workflowBindings.get(arg.name);\n if (binding) {\n return rewritten(\n [t.stringLiteral(binding.workflowType), t.stringLiteral(binding.workflowId)],\n 'thenWorkflow',\n );\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 entries = arg.elements.map(element => {\n if (t.isIdentifier(element)) {\n const binding = workflowBindings.get(element.name);\n if (binding) {\n return t.objectExpression([\n t.objectProperty(t.identifier('type'), t.stringLiteral('childWorkflow')),\n t.objectProperty(t.identifier('workflowType'), t.stringLiteral(binding.workflowType)),\n t.objectProperty(t.identifier('id'), t.stringLiteral(binding.workflowId)),\n ]);\n }\n }\n\n const stepId = getWorkflowStepName(element, stepBindings);\n if (!stepId) {\n throw new Error(`Unable to determine step names inside .parallel() in ${workflowName} (${filePath})`);\n }\n\n return t.objectExpression([\n t.objectProperty(t.identifier('type'), t.stringLiteral('step')),\n t.objectProperty(\n t.identifier('step'),\n t.objectExpression([t.objectProperty(t.identifier('id'), t.stringLiteral(stepId))]),\n ),\n ]);\n });\n return rewritten([t.arrayExpression(entries)]);\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 'map': {\n const callback = argNode(0);\n if (t.isObjectExpression(callback)) {\n throw new Error(\n `.map() in ${workflowName} (${filePath}) does not yet support declarative object mappings; use a callback mapping`,\n );\n }\n if (!t.isArrowFunctionExpression(callback) && !t.isFunctionExpression(callback) && !t.isIdentifier(callback)) {\n throw new Error(\n `.map() in ${workflowName} (${filePath}) requires an inline function or a statically declared function identifier`,\n );\n }\n const args: t.Expression[] = [t.stringLiteral(`mapping_${workflowId}_${mappingOrdinal}`)];\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 workflowIdValue: string,\n methods: { name: string; args: t.Node[] }[],\n filePath: string,\n includeCommit: boolean,\n stepBindings: Map<string, string>,\n workflowBindings: Map<string, WorkflowBinding>,\n runtimeOptions?: t.ObjectExpression,\n validateInputs?: boolean,\n): t.Statement[] {\n // Start from `createWorkflow(<static id>)` and rebuild the chain one call at a time\n // using normalized arguments from `rewriteChainMethod`.\n const createWorkflowArgs = [t.cloneNode(workflowId, true)];\n const optionProperties = runtimeOptions ? runtimeOptions.properties.map(property => t.cloneNode(property, true)) : [];\n\n if (validateInputs !== undefined) {\n optionProperties.push(t.objectProperty(t.identifier('validateInputs'), t.booleanLiteral(validateInputs)));\n }\n\n if (optionProperties.length > 0) {\n createWorkflowArgs.push(t.objectExpression(optionProperties));\n }\n\n let expression: t.Expression = t.callExpression(t.identifier('createWorkflow'), createWorkflowArgs);\n let mappingOrdinal = 0;\n\n for (const method of methods) {\n const rewrittenMethod = rewriteChainMethod(\n method,\n filePath,\n exportName,\n workflowIdValue,\n mappingOrdinal,\n stepBindings,\n workflowBindings,\n );\n if (method.name === 'map') {\n mappingOrdinal += 1;\n }\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\nconst nodeBuiltinModules = new Set(builtinModules.flatMap(moduleName => [moduleName, `node:${moduleName}`]));\n\nfunction isNodeBuiltinModule(moduleId: string): boolean {\n return nodeBuiltinModules.has(moduleId);\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, WorkflowBinding>;\n workflowExports: TemporalWorkflowExport[];\n runtimeOptions?: t.ObjectExpression;\n}\n\nfunction createWorkflowTransformState(program: t.Program, filePath: string): WorkflowTransformState {\n return {\n statements: [...createTemporalWorkflowHelperStatements()],\n workflowNames: new Set<string>(),\n committedWorkflowNames: new Set<string>(),\n inlineExportedWorkflowNames: new Set<string>(),\n strippedNames: new Set<string>(),\n stepBindings: collectStepBindings(program),\n workflowBindings: collectWorkflowBindings(program, filePath),\n workflowExports: [],\n runtimeOptions: getTemporalWorkflowRuntimeOptions(program),\n };\n}\n\nfunction collectWorkflowDeclarationMetadata(statement: t.Statement, state: WorkflowTransformState): void {\n const declarationStatement = getVariableDeclarationFromStatement(statement);\n if (!declarationStatement) {\n return;\n }\n\n for (const declaration of declarationStatement.declarations) {\n if (!t.isIdentifier(declaration.id) || !declaration.init) {\n continue;\n }\n\n if (!parseWorkflowChain(declaration.init)) {\n continue;\n }\n\n state.workflowNames.add(declaration.id.name);\n if (t.isExportNamedDeclaration(statement)) {\n state.inlineExportedWorkflowNames.add(declaration.id.name);\n }\n }\n}\n\nfunction collectWorkflowExportMetadata(statement: t.Statement, state: WorkflowTransformState): void {\n if (t.isExportNamedDeclaration(statement) && statement.declaration == null && statement.source == null) {\n for (const specifier of statement.specifiers) {\n if (!t.isExportSpecifier(specifier) || !t.isIdentifier(specifier.local)) {\n continue;\n }\n\n if (!state.workflowNames.has(specifier.local.name)) {\n continue;\n }\n\n if (getExportedName(specifier.exported) === specifier.local.name) {\n state.inlineExportedWorkflowNames.add(specifier.local.name);\n }\n }\n }\n}\n\nfunction collectWorkflowTransformMetadata(program: t.Program, state: WorkflowTransformState): void {\n for (const statement of program.body) {\n collectWorkflowDeclarationMetadata(statement, state);\n\n const committedWorkflowName = getCommittedWorkflowName(statement);\n if (committedWorkflowName) {\n state.committedWorkflowNames.add(committedWorkflowName);\n }\n\n collectWorkflowExportMetadata(statement, state);\n }\n}\n\nfunction rewriteWorkflowImportDeclaration(statement: t.ImportDeclaration, state: WorkflowTransformState): void {\n if (statement.source.value === '@mastra/core/workflows') {\n const retainedSpecifiers = statement.specifiers.filter(\n specifier =>\n !(\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n (specifier.imported.name === 'createWorkflow' || specifier.imported.name === 'createStep')\n ),\n );\n\n if (retainedSpecifiers.length > 0) {\n state.statements.push(t.importDeclaration(retainedSpecifiers, t.stringLiteral(statement.source.value)));\n }\n return;\n }\n\n if (isTemporalHelperModule(statement.source.value) || isStrippedExternalModule(statement.source.value)) {\n for (const name of collectImportedNames(statement)) {\n state.strippedNames.add(name);\n }\n return;\n }\n\n state.statements.push(statement);\n}\n\nfunction getNormalizedWorkflowBindingName(name: string, state: WorkflowTransformState): string | null {\n if (!state.workflowNames.has(name)) {\n return null;\n }\n\n return state.workflowBindings.get(name)?.workflowType ?? 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, workflowId: workflowIdValue } = getWorkflowIdMetadata(\n workflowConfig,\n declaration.id.name,\n filePath,\n );\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 workflowIdValue,\n workflowChain.methods,\n filePath,\n state.committedWorkflowNames.has(declaration.id.name),\n state.stepBindings,\n state.workflowBindings,\n state.runtimeOptions,\n getWorkflowValidateInputs(workflowConfig, declaration.id.name, filePath),\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 outputOptions = {\n dir: outputDirectory,\n entryFileNames: outputFileName,\n chunkFileNames: `${baseName}-[hash].mjs`,\n format: 'esm' as const,\n sourcemap: 'inline' as const,\n };\n const generated = await bundle.generate(outputOptions);\n const forbiddenImport = generated.output\n .filter(output => output.type === 'chunk')\n .flatMap(chunk => [...chunk.imports, ...chunk.dynamicImports])\n .find(isNodeBuiltinModule);\n\n if (forbiddenImport) {\n throw new Error(\n `Temporal workflow bundle cannot depend on Node.js builtin '${forbiddenImport}'. ` +\n 'Move the dependency into an activity or remove it from workflow initialization.',\n );\n }\n\n const { output } = await bundle.write(outputOptions);\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 { RequestContext } from '@mastra/core/di';\nimport { MastraError, getErrorFromUnknown } from '@mastra/core/error';\nimport { toStandardSchema } from '@mastra/core/schema';\nimport type { PublicSchema } from '@mastra/core/schema';\nimport { validateStepInput, validateStepRequestContext } from '@mastra/core/workflows';\nimport { ApplicationFailure, CancelledFailure } from '@temporalio/activity';\nimport type { WorkerOptions, WorkerPlugin } from '@temporalio/worker';\nimport type { TemporalActivityBinding } from './transforms/activities';\nimport { buildTemporalActivitiesModule } from './transforms/activities';\nimport type { StepFailureDetails } from './transforms/temporal-workflow-runtime';\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\ninterface ActivityParams extends Record<string, unknown> {\n inputData?: unknown;\n requestContext?: Record<string, unknown>;\n validateInputs?: boolean;\n}\n\ntype GeneratedActivity = (params: ActivityParams) => Promise<unknown>;\n\ninterface GeneratedStep {\n execute: GeneratedActivity;\n inputSchema?: PublicSchema;\n requestContextSchema?: PublicSchema;\n}\n\ntype GeneratedActivitiesModule = Record<string, GeneratedActivity | GeneratedStep | undefined>;\n\n/**\n * Temporal reduces a thrown error to its class name and message, so the step's own fields go in\n * the failure's `details` for start() to rebuild the result a local run returns.\n */\nfunction toStepFailureDetails(error: unknown): StepFailureDetails {\n const serialized = getErrorFromUnknown(error, { serializeStack: false }).toJSON();\n let details: StepFailureDetails['error'];\n try {\n // The default payload converter throws on fields JSON cannot hold, such as a BigInt.\n details = JSON.parse(JSON.stringify(serialized));\n } catch {\n details = { name: serialized.name, message: serialized.message };\n }\n\n // Matched by name because `instanceof` misses a TripWire from another copy of @mastra/core.\n if (error instanceof Error && error.name === 'TripWire') {\n const { options, processorId } = error as Error & {\n options?: { retry?: boolean; metadata?: Record<string, unknown> };\n processorId?: string;\n };\n\n return {\n error: details,\n tripwire: { reason: error.message, retry: options?.retry, metadata: options?.metadata, processorId },\n };\n }\n\n return { error: details };\n}\n\n/** Fails as Temporal's own conversion would (same type, message and retries), plus the details. */\nasync function runStep(execute: () => Promise<unknown>): Promise<unknown> {\n try {\n return await execute();\n } catch (error) {\n // A step's own ApplicationFailure and Temporal's cancellation pass through unchanged.\n if (error instanceof ApplicationFailure || error instanceof CancelledFailure) {\n throw error;\n }\n\n throw ApplicationFailure.fromError(error, { details: [toStepFailureDetails(error)] });\n }\n}\n\n/**\n * Activities queued by a Workflow built before `validateInputs` existed carry no flag and run\n * unchecked. A mismatch is non-retryable because a retry gets the same input.\n */\nasync function checkStepParams(\n stepId: string,\n { inputSchema, requestContextSchema }: GeneratedStep,\n { validateInputs, ...params }: ActivityParams,\n): Promise<ActivityParams> {\n if (validateInputs !== true) {\n return params;\n }\n\n const [input, requestContext] = await Promise.all([\n validateStepInput({\n prevOutput: params.inputData,\n step: { inputSchema: inputSchema && toStandardSchema(inputSchema) },\n validateInputs: true,\n }),\n validateStepRequestContext({\n requestContext: new RequestContext(Object.entries(params.requestContext ?? {})),\n step: { id: stepId, requestContextSchema: requestContextSchema && toStandardSchema(requestContextSchema) },\n validateInputs: true,\n }),\n ]);\n\n // Input errors win, as in Mastra's step handler.\n const error = input.validationError ?? requestContext.validationError;\n\n if (error) {\n throw ApplicationFailure.create({\n type: error instanceof MastraError ? error.id : error.name,\n message: error.message,\n nonRetryable: true,\n cause: error,\n details: [toStepFailureDetails(error)],\n });\n }\n\n return { ...params, inputData: input.inputData };\n}\n\nexport class MastraPlugin implements WorkerPlugin {\n #prebuildPath: string | null = null;\n #prebuildPromise: Promise<ReturnType<typeof this.getTemporalWorkerOptions>> | null = null;\n #compiledActivitiesModules = new Map<string, Promise<GeneratedActivitiesModule>>();\n name = 'Mastra';\n\n constructor(\n private readonly entryFile: string,\n private readonly projectRoot: string = process.cwd(),\n ) {}\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 /**\n * @deprecated Please use the constructor params instead.\n */\n async prebuild({\n entryFile,\n projectRoot = process.cwd(),\n }: {\n entryFile: string;\n projectRoot?: string;\n }): Promise<ReturnType<typeof this.getTemporalWorkerOptions>> {\n return this.#prebuild(entryFile, projectRoot);\n }\n\n async #prebuild(entryFile: string, projectRoot: string): 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<GeneratedActivitiesModule> {\n const cachedModule = this.#compiledActivitiesModules.get(activitiesModulePath);\n if (cachedModule) {\n return cachedModule;\n }\n\n const modulePromise = import(\n `${pathToFileURL(activitiesModulePath).href}?t=${Date.now()}`\n ) as Promise<GeneratedActivitiesModule>;\n\n this.#compiledActivitiesModules.set(activitiesModulePath, modulePromise);\n return modulePromise;\n }\n\n #generateActivityBindings(\n activityBindings: TemporalActivityBinding[],\n compiledActivitiesPath: string,\n ): Record<string, GeneratedActivity> {\n const generatedActivities: Record<string, GeneratedActivity> = {};\n for (const binding of activityBindings) {\n if (generatedActivities[binding.stepId]) {\n continue;\n }\n\n generatedActivities[binding.stepId] = async params => {\n const activityModule = await this.#loadCompiledActivitiesModule(compiledActivitiesPath);\n const activity = activityModule[binding.exportName];\n\n // Mappings are plain functions, and so are steps generated by an older plugin version.\n // Those steps run unchecked.\n if (typeof activity === 'function') {\n return runStep(() => activity(params));\n }\n\n if (typeof activity?.execute !== 'function') {\n throw new Error(`Unable to load activity '${binding.exportName}' from ${compiledActivitiesPath}`);\n }\n\n const checkedParams = await checkStepParams(binding.stepId, activity, params);\n return runStep(() => activity.execute(checkedParams));\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 async configureWorker(options: WorkerOptions): Promise<WorkerOptions> {\n const augmentedOptions = Object.assign({}, options);\n if (!this.#prebuildPath) {\n this.#prebuildPromise ??= this.#prebuild(this.entryFile, this.projectRoot).catch(error => {\n this.#prebuildPromise = null;\n throw error;\n });\n await this.#prebuildPromise;\n }\n\n const generatedOptions = this.getTemporalWorkerOptions(this.#prebuildPath!);\n Object.assign(augmentedOptions, generatedOptions, {\n activities: {\n ...options.activities,\n ...generatedOptions.activities,\n },\n });\n\n return augmentedOptions;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,MAAa,gBAAgB;CAAC;CAAc;CAAO;AAAmB;AACtE,SAAgB,YAAY,UAAkB,YAA6B;CACzE,IAAI,CAAC,YACH,aAAa,aAAa,UAAU,MAAM;CAG5C,OAAO,MAAM,YAAY;EACvB,YAAY;EACZ,SAAS;EACT,gBAAgB;CAClB,CAAC;AACH;AAEA,SAAgB,kBAAkB,MAAc,MAAuB;CACrE,OAAO,EAAE,aAAa,IAAI,KAAK,KAAK,SAAS;AAC/C;AAEA,SAAgB,uBAAuB,QAAyB;CAC9D,OAAO,OAAO,WAAW,YAAY,2CAA2C,KAAK,MAAM;AAC7F;AAEA,MAAa,0CAA0B,IAAI,IAAI,CAAC,sBAAsB,uBAAuB,CAAC;AAE9F,SAAgB,yBAAyB,QAAyB;CAChE,OAAO,OAAO,WAAW,YAAY,w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