@mastra/temporal 0.4.19 → 0.5.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -37,7 +37,8 @@ var TemporalRun = class extends _mastra_core_workflows.Run {
37
37
  outputOptions: args.outputOptions,
38
38
  tracingOptions: args.tracingOptions,
39
39
  perStep: args.perStep,
40
- recordStepMeta: true
40
+ recordStepMeta: true,
41
+ validateInputs: this.validateInputs
41
42
  }]
42
43
  })).result();
43
44
  return {
@@ -103,7 +104,8 @@ var TemporalRun = class extends _mastra_core_workflows.Run {
103
104
  resourceId: this.resourceId,
104
105
  outputOptions: args.outputOptions,
105
106
  tracingOptions: args.tracingOptions,
106
- perStep: args.perStep
107
+ perStep: args.perStep,
108
+ validateInputs: this.validateInputs
107
109
  }]
108
110
  });
109
111
  return { runId: this.runId };
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Run","toWorkflowType","Workflow"],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Builds Mastra step records from the Temporal result. Iterates `stepMeta` rather than `steps`\n// because a step that returned undefined has no key in `steps` once serialized. A result without\n// `stepMeta` came from a Worker that predates it, so `steps` stays empty instead of guessing times.\nfunction toStepResults(input: unknown, { steps, stepMeta }: WorkflowExecutionResult): Record<string, unknown> {\n if (!stepMeta) {\n return {};\n }\n\n const records: Record<string, unknown> = { input };\n for (const [stepId, times] of Object.entries(stepMeta)) {\n records[stepId] = { status: 'success', output: steps[stepId], ...times };\n }\n return records;\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n recordStepMeta: true,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: toStepResults(input, result),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async 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 resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\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\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport 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":";;;;AAWA,SAAS,cAAc,OAAgB,EAAE,OAAO,YAA8D;CAC5G,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAAmC,EAAE,MAAM;CACjD,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,QAAQ,GACnD,QAAQ,UAAU;EAAE,QAAQ;EAAW,QAAQ,MAAM;EAAS,GAAG;CAAM;CAEzE,OAAO;AACT;AAQA,IAAa,cAAb,cAcUA,uBAAAA,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;GAkBF,M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oBAAoB,KAAK;GACzB,SAAS,KAAA;EACX,GACA;GACE,QAAQ,KAAK;GACb,WAAW,KAAK;EAClB,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,YAAA,uBAAA;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["Run","toWorkflowType","Workflow"],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Builds Mastra step records from the Temporal result. Iterates `stepMeta` rather than `steps`\n// because a step that returned undefined has no key in `steps` once serialized. A result without\n// `stepMeta` came from a Worker that predates it, so `steps` stays empty instead of guessing times.\nfunction toStepResults(input: unknown, { steps, stepMeta }: WorkflowExecutionResult): Record<string, unknown> {\n if (!stepMeta) {\n return {};\n }\n\n const records: Record<string, unknown> = { input };\n for (const [stepId, times] of Object.entries(stepMeta)) {\n records[stepId] = { status: 'success', output: steps[stepId], ...times };\n }\n return records;\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n recordStepMeta: true,\n validateInputs: this.validateInputs,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: toStepResults(input, result),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async 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 resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\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\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n validateInputs: this.validateInputs,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport 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":";;;;AAWA,SAAS,cAAc,OAAgB,EAAE,OAAO,YAA8D;CAC5G,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAAmC,EAAE,MAAM;CACjD,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,QAAQ,GACnD,QAAQ,UAAU;EAAE,QAAQ;EAAW,QAAQ,MAAM;EAAS,GAAG;CAAM;CAEzE,OAAO;AACT;AAQA,IAAa,cAAb,cAcUA,uBAAAA,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;GAmBF,MAAM,SAAU,OAAM,MAlBD,KAAK,OAAO,SAAS,MAAMC,cAAAA,eAAe,KAAK,UAAU,GAAG;IAC/E,WAAW,KAAK;IAChB,YAAY,KAAK;IACjB,MAAM,CACJ;KACE,WAAW;KACX;KACA,gBAAgB,KAAK,iBAAiB,OAAO,YAAY,KAAK,eAAe,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d,QACA,UACA;CACA,OAAO,IAAI,iBAAwF,QAAQ,QAAQ;AACrH;AAEA,SAAgB,KAAK,gBAAwC;CAC3D,OAAO;EACL,iBAQE,WACG,eAA8E,QAAQ,cAAc;EACzG,YAAA,uBAAA;CACF;AACF"}
package/dist/index.js CHANGED
@@ -36,7 +36,8 @@ var TemporalRun = class extends Run {
36
36
  outputOptions: args.outputOptions,
37
37
  tracingOptions: args.tracingOptions,
38
38
  perStep: args.perStep,
39
- recordStepMeta: true
39
+ recordStepMeta: true,
40
+ validateInputs: this.validateInputs
40
41
  }]
41
42
  })).result();
42
43
  return {
@@ -102,7 +103,8 @@ var TemporalRun = class extends Run {
102
103
  resourceId: this.resourceId,
103
104
  outputOptions: args.outputOptions,
104
105
  tracingOptions: args.tracingOptions,
105
- perStep: args.perStep
106
+ perStep: args.perStep,
107
+ validateInputs: this.validateInputs
106
108
  }]
107
109
  });
108
110
  return { runId: this.runId };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Builds Mastra step records from the Temporal result. Iterates `stepMeta` rather than `steps`\n// because a step that returned undefined has no key in `steps` once serialized. A result without\n// `stepMeta` came from a Worker that predates it, so `steps` stays empty instead of guessing times.\nfunction toStepResults(input: unknown, { steps, stepMeta }: WorkflowExecutionResult): Record<string, unknown> {\n if (!stepMeta) {\n return {};\n }\n\n const records: Record<string, unknown> = { input };\n for (const [stepId, times] of Object.entries(stepMeta)) {\n records[stepId] = { status: 'success', output: steps[stepId], ...times };\n }\n return records;\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n recordStepMeta: true,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: toStepResults(input, result),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async 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 resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\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\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport 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":";;;AAWA,SAAS,cAAc,OAAgB,EAAE,OAAO,YAA8D;CAC5G,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAAmC,EAAE,MAAM;CACjD,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,QAAQ,GACnD,QAAQ,UAAU;EAAE,QAAQ;EAAW,QAAQ,MAAM;EAAS,GAAG;CAAM;CAEzE,OAAO;AACT;AAQA,IAAa,cAAb,cAcU,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;G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,SAAS,KAAA;EACX,GACA;GACE,QAAQ,KAAK;GACb,WAAW,KAAK;EAClB,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
+ {"version":3,"file":"index.js","names":[],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Builds Mastra step records from the Temporal result. Iterates `stepMeta` rather than `steps`\n// because a step that returned undefined has no key in `steps` once serialized. A result without\n// `stepMeta` came from a Worker that predates it, so `steps` stays empty instead of guessing times.\nfunction toStepResults(input: unknown, { steps, stepMeta }: WorkflowExecutionResult): Record<string, unknown> {\n if (!stepMeta) {\n return {};\n }\n\n const records: Record<string, unknown> = { input };\n for (const [stepId, times] of Object.entries(stepMeta)) {\n records[stepId] = { status: 'success', output: steps[stepId], ...times };\n }\n return records;\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n recordStepMeta: true,\n validateInputs: this.validateInputs,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: toStepResults(input, result),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async 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 resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\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\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n validateInputs: this.validateInputs,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport 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":";;;AAWA,SAAS,cAAc,OAAgB,EAAE,OAAO,YAA8D;CAC5G,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAAmC,EAAE,MAAM;CACjD,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,QAAQ,GACnD,QAAQ,UAAU;EAAE,QAAQ;EAAW,QAAQ,MAAM;EAAS,GAAG;CAAM;CAEzE,OAAO;AACT;AAQA,IAAa,cAAb,cAcU,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;GAmBF,MAAM,SAAU,OAAM,MAlBD,KAAK,OAAO,SAAS,MAAM,eAAe,KAAK,UAAU,GAAG;IAC/E,WAAW,KAAK;IAChB,YAAY,KAAK;IACjB,MAAM,CACJ;KACE,WAAW;KACX;KACA,gBAAgB,KAAK,iBAAiB,OAAO,YAAY,KAAK,eAAe,QAAQ,CAAC,IAAI,CAAC;KAC3F,OAAO,KAAK;KACZ,YAAY,KAAK;KACjB,eAAe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,OAAO;EACL,iBAQE,WACG,eAA8E,QAAQ,cAAc;EACzG;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAsBtE,qBAAa,YAAa,YAAW,YAAY;;IAO7C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAJ9B,IAAI,SAAY;IAEhB,YACmB,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,MAAsB,EAClD;IAeJ;;OAEG;IACG,QAAQ,CAAC,EACb,SAAS,EACT,WAA2B,GAC5B,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAE5D;IAsED,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG;QAEnD,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;QAC9C,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAaA;IAEK,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBpE;CACF"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA+EtE,qBAAa,YAAa,YAAW,YAAY;;IAO7C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAJ9B,IAAI,SAAY;IAEhB,YACmB,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,MAAsB,EAClD;IAeJ;;OAEG;IACG,QAAQ,CAAC,EAC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AC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAEhD;IAEQ,MAAM,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAE1C;IAEQ,WAAW,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAE/C;IAEQ,OAAO,CACd,GAAG,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,GACzG,KAAK,CAEP;IAEQ,UAAU,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAE9C;IAEQ,gBAAgB,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAEpD;IAEK,UAAU,CAAC,IAAI,GAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAM;;OAwBhF;CACF"}
@@ -18,6 +18,7 @@ export class TemporalExecutionEngine {
18
18
  ...(params.requestContext !== undefined && { requestContext: params.requestContext }),
19
19
  ...(params.runId !== undefined && { runId: params.runId }),
20
20
  ...(params.resourceId !== undefined && { resourceId: params.resourceId }),
21
+ validateInputs: params.validateInputs,
21
22
  workflowId: params.workflowId,
22
23
  };
23
24
  // Step times let start() build Mastra step records. Only recorded on request so runs that
@@ -211,6 +212,8 @@ export function createWorkflow(workflowId, options) {
211
212
  runId: startArgs?.runId,
212
213
  resourceId: startArgs?.resourceId,
213
214
  requestContext: startArgs?.requestContext,
215
+ // A child Workflow gets its parent's setting in startArgs, as nested workflows do in Mastra.
216
+ validateInputs: startArgs?.validateInputs ?? options?.validateInputs ?? true,
214
217
  graph: {
215
218
  id: workflowId,
216
219
  steps: stepFlow,
@@ -1 +1 @@
1
- {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;AA2SD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CAoZ9C"}
1
+ {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;AAoSD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CAoZ9C"}
@@ -4,6 +4,7 @@ export declare class TemporalExecutionEngine {
4
4
  requestContext?: any;
5
5
  runId?: any;
6
6
  resourceId?: any;
7
+ validateInputs: any;
7
8
  workflowId: any;
8
9
  } | undefined;
9
10
  stepMeta: {} | undefined;
@@ -23,6 +24,7 @@ export declare class TemporalExecutionEngine {
23
24
  requestContext?: any;
24
25
  runId?: any;
25
26
  resourceId?: any;
27
+ validateInputs?: any;
26
28
  workflowId?: any;
27
29
  inputData: any;
28
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAEA,qBAAa,uBAAuB;IAa3B,QAAQ;IACR,gBAAgB;;;;;;IAQhB,QAAQ;IArBf,mBAAmB,MAAC;IACpB,cAAc,wGAAC;IAEf,YAAY,MAAM,KAAA,EAMjB;IAEK,OAAO,CAAC,MAAM,KAAA;;;;;;;OA0BnB;IAIK,KAAK,CAAC,WAAW,KAAA,EAAE,EAAE,KAAA,EAAE,GAAG,KAAA,gBAQ/B;IAED,cAAc,CAAC,SAAS,KAAA,EAAE,KAAK,KAAK;;;;;;MAEnC;IAEK,YAAY,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,gBA2I/C;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsJjD"}
1
+ {"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAEA,qBAAa,uBAAuB;IAa3B,QAAQ;IACR,gBAAgB;;;;;;;IAShB,QAAQ;IAtBf,mBAAmB,MAAC;IACpB,cAAc,wGAAC;IAEf,YAAY,MAAM,KAAA,EAMjB;IAEK,OAAO,CAAC,MAAM,KAAA;;;;;;;OA2BnB;IAIK,KAAK,CAAC,WAAW,KAAA,EAAE,EAAE,KAAA,EAAE,GAAG,KAAA,gBAQ/B;IAED,cAAc,CAAC,SAAS,KAAA,EAAE,KAAK,KAAK;;;;;;;MAEnC;IAEK,YAAY,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,gBA2I/C;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwJjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/transforms/workflows.ts"],"names":[],"mappings":"AA2gBA,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;AA+UD;;;;;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
+ {"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"}
package/dist/worker.cjs CHANGED
@@ -21,11 +21,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  const require_utils = require("./utils-BVE1AkTt.cjs");
24
+ let _mastra_core_workflows = require("@mastra/core/workflows");
24
25
  let fs = require("fs");
25
26
  let fs_promises = require("fs/promises");
26
27
  let path = require("path");
27
28
  path = __toESM(path, 1);
28
29
  let url = require("url");
30
+ let _mastra_core_di = require("@mastra/core/di");
31
+ let _mastra_core_error = require("@mastra/core/error");
32
+ let _mastra_core_schema = require("@mastra/core/schema");
33
+ let _temporalio_activity = require("@temporalio/activity");
29
34
  let _babel_generator = require("@babel/generator");
30
35
  let _babel_parser = require("@babel/parser");
31
36
  let _babel_types = require("@babel/types");
@@ -431,26 +436,18 @@ function createTemporalActivitiesHelperStatements(mastraImportPath, hasMastraBin
431
436
  };
432
437
  }
433
438
 
434
- ${mastraImportPath ? `
435
- function createStep(args) {
436
- return async (params) => {
437
- const { mastra } = await import(${JSON.stringify(mastraImportPath)});
438
- return args.execute({ ...withRequestContext(params), mastra });
439
- };
440
- }
441
- ` : hasMastraBinding ? `
442
- function createStep(args) {
443
- return async (params) => {
444
- return args.execute({ ...withRequestContext(params), mastra });
445
- };
446
- }
447
- ` : `
448
- function createStep(args) {
449
- return async (params) => {
450
- return args.execute(withRequestContext(params));
451
- };
452
- }
453
- `}
439
+ function createStep(args) {
440
+ return {
441
+ inputSchema: args.inputSchema,
442
+ requestContextSchema: args.requestContextSchema,
443
+ execute: async (params) => {
444
+ ${mastraImportPath ? `
445
+ const { mastra } = await import(${JSON.stringify(mastraImportPath)});
446
+ return args.execute({ ...withRequestContext(params), mastra });
447
+ ` : hasMastraBinding ? "return args.execute({ ...withRequestContext(params), mastra });" : "return args.execute(withRequestContext(params));"}
448
+ },
449
+ };
450
+ }
454
451
  `;
455
452
  return (0, _babel_parser.parse)(helperSource, {
456
453
  sourceType: "module",
@@ -693,6 +690,43 @@ function getWorkflowIdMetadata(workflowConfig, workflowName, filePath) {
693
690
  }
694
691
  throw new Error(`Unable to determine workflow id for ${workflowName} in ${filePath}`);
695
692
  }
693
+ function getStaticKey(property) {
694
+ if (property.computed && _babel_types.isTemplateLiteral(property.key) && property.key.expressions.length === 0) return property.key.quasis[0]?.value.cooked ?? null;
695
+ if (property.computed && _babel_types.isStringLiteral(property.key)) return property.key.value;
696
+ return getObjectPropertyName(property);
697
+ }
698
+ function isDynamicKey(property) {
699
+ return property.computed && !_babel_types.isStringLiteral(property.key) && !(_babel_types.isTemplateLiteral(property.key) && property.key.expressions.length === 0);
700
+ }
701
+ function findStaticProperty(object, name) {
702
+ let found = { readable: true };
703
+ for (const property of object.properties) {
704
+ if (_babel_types.isSpreadElement(property) || isDynamicKey(property)) {
705
+ found = { readable: false };
706
+ continue;
707
+ }
708
+ if (getStaticKey(property) === name) found = _babel_types.isObjectProperty(property) ? {
709
+ readable: true,
710
+ value: property.value
711
+ } : { readable: false };
712
+ }
713
+ return found;
714
+ }
715
+ /**
716
+ * Read at build time so runs started outside `TemporalRun` (Schedules, the Temporal CLI) use the
717
+ * workflow's setting too. `TemporalRun` also sends the setting, which covers `options` the build
718
+ * cannot read.
719
+ */
720
+ function getWorkflowValidateInputs(workflowConfig, workflowName, filePath) {
721
+ const options = findStaticProperty(workflowConfig, "options");
722
+ if (options.readable && !options.value) return;
723
+ if (options.readable && _babel_types.isObjectExpression(options.value)) {
724
+ const validateInputs = findStaticProperty(options.value, "validateInputs");
725
+ if (validateInputs.readable && !validateInputs.value) return;
726
+ if (validateInputs.readable && _babel_types.isBooleanLiteral(validateInputs.value)) return validateInputs.value.value;
727
+ }
728
+ console.warn(`[@mastra/temporal] Could not read options.validateInputs of ${workflowName} in ${filePath} at build time. Runs started with run.start() or run.startAsync() use the workflow setting. Runs started another way, such as from a Temporal Schedule, check step input.`);
729
+ }
696
730
  /**
697
731
  * The helper runtime lives in its own `.mjs` module so it can be linted and unit-tested
698
732
  * like normal code. We parse that file directly here instead of using `Function#toString()`,
@@ -913,9 +947,11 @@ function getExportedName(node) {
913
947
  * we emit a deterministic exported function whose name matches Temporal's runtime
914
948
  * lookup and whose body delegates into the injected helper runtime.
915
949
  */
916
- function createTemporalWorkflowStatements(exportName, workflowId, workflowIdValue, methods, filePath, includeCommit, stepBindings, workflowBindings, runtimeOptions) {
950
+ function createTemporalWorkflowStatements(exportName, workflowId, workflowIdValue, methods, filePath, includeCommit, stepBindings, workflowBindings, runtimeOptions, validateInputs) {
917
951
  const createWorkflowArgs = [_babel_types.cloneNode(workflowId, true)];
918
- if (runtimeOptions) createWorkflowArgs.push(_babel_types.cloneNode(runtimeOptions, true));
952
+ const optionProperties = runtimeOptions ? runtimeOptions.properties.map((property) => _babel_types.cloneNode(property, true)) : [];
953
+ if (validateInputs !== void 0) optionProperties.push(_babel_types.objectProperty(_babel_types.identifier("validateInputs"), _babel_types.booleanLiteral(validateInputs)));
954
+ if (optionProperties.length > 0) createWorkflowArgs.push(_babel_types.objectExpression(optionProperties));
919
955
  let expression = _babel_types.callExpression(_babel_types.identifier("createWorkflow"), createWorkflowArgs);
920
956
  let mappingOrdinal = 0;
921
957
  for (const method of methods) {
@@ -1050,7 +1086,7 @@ function rewriteWorkflowVariableDeclaration(statement, filePath, state) {
1050
1086
  if (!workflowExport) throw new Error(`Unable to determine workflow export for ${declaration.id.name} in ${filePath}`);
1051
1087
  const { exportName } = workflowExport;
1052
1088
  state.workflowExports.push(workflowExport);
1053
- state.statements.push(...createTemporalWorkflowStatements(exportName, workflowId, workflowIdValue, workflowChain.methods, filePath, state.committedWorkflowNames.has(declaration.id.name), state.stepBindings, state.workflowBindings, state.runtimeOptions));
1089
+ state.statements.push(...createTemporalWorkflowStatements(exportName, workflowId, workflowIdValue, workflowChain.methods, filePath, state.committedWorkflowNames.has(declaration.id.name), state.stepBindings, state.workflowBindings, state.runtimeOptions, getWorkflowValidateInputs(workflowConfig, declaration.id.name, filePath)));
1054
1090
  }
1055
1091
  if (declarations.length > 0) {
1056
1092
  const cloned = declarations.map((declaration) => _babel_types.cloneNode(declaration, true));
@@ -1144,6 +1180,36 @@ function getGeneratedActivitiesModulePath(outputDir) {
1144
1180
  function getActivityBindingsPath(outputDir) {
1145
1181
  return path.default.join(outputDir, ACTIVITY_BINDINGS_FILE_NAME);
1146
1182
  }
1183
+ /**
1184
+ * Activities queued by a Workflow built before `validateInputs` existed carry no flag and run
1185
+ * unchecked. A mismatch is non-retryable because a retry gets the same input.
1186
+ */
1187
+ async function checkStepParams(stepId, { inputSchema, requestContextSchema }, { validateInputs, ...params }) {
1188
+ if (validateInputs !== true) return params;
1189
+ const [input, requestContext] = await Promise.all([(0, _mastra_core_workflows.validateStepInput)({
1190
+ prevOutput: params.inputData,
1191
+ step: { inputSchema: inputSchema && (0, _mastra_core_schema.toStandardSchema)(inputSchema) },
1192
+ validateInputs: true
1193
+ }), (0, _mastra_core_workflows.validateStepRequestContext)({
1194
+ requestContext: new _mastra_core_di.RequestContext(Object.entries(params.requestContext ?? {})),
1195
+ step: {
1196
+ id: stepId,
1197
+ requestContextSchema: requestContextSchema && (0, _mastra_core_schema.toStandardSchema)(requestContextSchema)
1198
+ },
1199
+ validateInputs: true
1200
+ })]);
1201
+ const error = input.validationError ?? requestContext.validationError;
1202
+ if (error) throw _temporalio_activity.ApplicationFailure.create({
1203
+ type: error instanceof _mastra_core_error.MastraError ? error.id : error.name,
1204
+ message: error.message,
1205
+ nonRetryable: true,
1206
+ cause: error
1207
+ });
1208
+ return {
1209
+ ...params,
1210
+ inputData: input.inputData
1211
+ };
1212
+ }
1147
1213
  var MastraPlugin = class {
1148
1214
  entryFile;
1149
1215
  projectRoot;
@@ -1199,10 +1265,11 @@ var MastraPlugin = class {
1199
1265
  const generatedActivities = {};
1200
1266
  for (const binding of activityBindings) {
1201
1267
  if (generatedActivities[binding.stepId]) continue;
1202
- generatedActivities[binding.stepId] = async (...args) => {
1268
+ generatedActivities[binding.stepId] = async (params) => {
1203
1269
  const activity = (await this.#loadCompiledActivitiesModule(compiledActivitiesPath))[binding.exportName];
1204
- if (typeof activity !== "function") throw new Error(`Unable to load activity '${binding.exportName}' from ${compiledActivitiesPath}`);
1205
- return activity(...args);
1270
+ if (typeof activity === "function") return activity(params);
1271
+ if (typeof activity?.execute !== "function") throw new Error(`Unable to load activity '${binding.exportName}' from ${compiledActivitiesPath}`);
1272
+ return activity.execute(await checkStepParams(binding.stepId, activity, params));
1206
1273
  };
1207
1274
  }
1208
1275
  return generatedActivities;