@mastra/temporal 0.0.0-observe-20260504181920

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +107 -0
  4. package/dist/chunk-BF6TR7JX.js +9 -0
  5. package/dist/chunk-BF6TR7JX.js.map +1 -0
  6. package/dist/chunk-DYBSPLCJ.cjs +11 -0
  7. package/dist/chunk-DYBSPLCJ.cjs.map +1 -0
  8. package/dist/index.cjs +132 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +130 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/mastra-deployer-UCBGECM5.js +39 -0
  15. package/dist/mastra-deployer-UCBGECM5.js.map +1 -0
  16. package/dist/mastra-deployer-YVT5GB5G.cjs +41 -0
  17. package/dist/mastra-deployer-YVT5GB5G.cjs.map +1 -0
  18. package/dist/mastra-deployer.d.ts +16 -0
  19. package/dist/mastra-deployer.d.ts.map +1 -0
  20. package/dist/plugin.d.ts +16 -0
  21. package/dist/plugin.d.ts.map +1 -0
  22. package/dist/run.d.ts +24 -0
  23. package/dist/run.d.ts.map +1 -0
  24. package/dist/temporal-workflow-runtime.mjs +295 -0
  25. package/dist/transforms/activities.d.ts +11 -0
  26. package/dist/transforms/activities.d.ts.map +1 -0
  27. package/dist/transforms/shared.d.ts +23 -0
  28. package/dist/transforms/shared.d.ts.map +1 -0
  29. package/dist/transforms/temporal-workflow-runtime.d.mts +92 -0
  30. package/dist/transforms/temporal-workflow-runtime.d.mts.map +1 -0
  31. package/dist/transforms/workflows.d.ts +20 -0
  32. package/dist/transforms/workflows.d.ts.map +1 -0
  33. package/dist/types.d.ts +4 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/dist/utils.d.ts +2 -0
  36. package/dist/utils.d.ts.map +1 -0
  37. package/dist/worker.cjs +1336 -0
  38. package/dist/worker.cjs.map +1 -0
  39. package/dist/worker.d.ts +2 -0
  40. package/dist/worker.d.ts.map +1 -0
  41. package/dist/worker.js +1310 -0
  42. package/dist/worker.js.map +1 -0
  43. package/dist/workflow.d.ts +27 -0
  44. package/dist/workflow.d.ts.map +1 -0
  45. package/package.json +95 -0
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var bundler = require('@mastra/deployer/bundler');
4
+
5
+ // src/mastra-deployer.ts
6
+ var BuildBundler = class extends bundler.Bundler {
7
+ constructor() {
8
+ super("Temporal");
9
+ this.platform = process.versions?.bun ? "neutral" : "node";
10
+ }
11
+ async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
12
+ const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);
13
+ return {
14
+ ...bundlerOptions,
15
+ externals: true,
16
+ sourcemap: true
17
+ };
18
+ }
19
+ getEnvFiles() {
20
+ return Promise.resolve([]);
21
+ }
22
+ installDependencies() {
23
+ return Promise.resolve();
24
+ }
25
+ copyPublic() {
26
+ return Promise.resolve();
27
+ }
28
+ writePackageJson() {
29
+ return Promise.resolve();
30
+ }
31
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
32
+ return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);
33
+ }
34
+ async lint(entryFile, outputDirectory, toolsPaths) {
35
+ await super.lint(entryFile, outputDirectory, toolsPaths);
36
+ }
37
+ };
38
+
39
+ exports.BuildBundler = BuildBundler;
40
+ //# sourceMappingURL=mastra-deployer-YVT5GB5G.cjs.map
41
+ //# sourceMappingURL=mastra-deployer-YVT5GB5G.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mastra-deployer.ts"],"names":["Bundler"],"mappings":";;;;;AAGO,IAAM,YAAA,GAAN,cAA2BA,eAAA,CAAQ;AAAA,EACxC,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,UAAU,CAAA;AAChB,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA,CAAQ,QAAA,EAAU,GAAA,GAAM,SAAA,GAAY,MAAA;AAAA,EACtD;AAAA,EAEA,MAAgB,qBAAA,CACd,eAAA,EACA,eAAA,EACyC;AACzC,IAAA,MAAM,cAAA,GAAiB,MAAM,KAAA,CAAM,qBAAA,CAAsB,iBAAiB,eAAe,CAAA;AAEzF,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,SAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW;AAAA,KACb;AAAA,EACF;AAAA,EAEA,WAAA,GAAiC;AAC/B,IAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,CAAA;AAAA,EAC3B;AAAA,EAEU,mBAAA,GAAqC;AAC7C,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEU,UAAA,GAA4B;AACpC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,gBAAA,GAAkC;AAChC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,MAAM,MAAA,CACJ,SAAA,EACA,iBACA,EAAE,UAAA,EAAY,aAAY,EACX;AACf,IAAA,OAAO,IAAA,CAAK,QAAQ,SAAA,EAAW,SAAA,EAAW,EAAE,eAAA,EAAiB,WAAA,IAAe,UAAU,CAAA;AAAA,EACxF;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAAA,EACzD;AACF","file":"mastra-deployer-YVT5GB5G.cjs","sourcesContent":["import type { Config } from '@mastra/core/mastra';\nimport { Bundler } from '@mastra/deployer/bundler';\n\nexport class BuildBundler extends Bundler {\n constructor() {\n super('Temporal');\n this.platform = process.versions?.bun ? 'neutral' : 'node';\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n\n return {\n ...bundlerOptions,\n externals: true,\n sourcemap: true,\n };\n }\n\n getEnvFiles(): Promise<string[]> {\n return Promise.resolve([]);\n }\n\n protected installDependencies(): Promise<void> {\n return Promise.resolve();\n }\n\n protected copyPublic(): Promise<void> {\n return Promise.resolve();\n }\n\n writePackageJson(): Promise<void> {\n return Promise.resolve();\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { Config } from '@mastra/core/mastra';
2
+ import { Bundler } from '@mastra/deployer/bundler';
3
+ export declare class BuildBundler extends Bundler {
4
+ constructor();
5
+ protected getUserBundlerOptions(mastraEntryFile: string, outputDirectory: string): Promise<NonNullable<Config['bundler']>>;
6
+ getEnvFiles(): Promise<string[]>;
7
+ protected installDependencies(): Promise<void>;
8
+ protected copyPublic(): Promise<void>;
9
+ writePackageJson(): Promise<void>;
10
+ bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
11
+ toolsPaths: (string | string[])[];
12
+ projectRoot: string;
13
+ }): Promise<void>;
14
+ lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=mastra-deployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra-deployer.d.ts","sourceRoot":"","sources":["../src/mastra-deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,qBAAa,YAAa,SAAQ,OAAO;;cAMvB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAU1C,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIhC,SAAS,CAAC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9C,SAAS,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAIV,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzG"}
@@ -0,0 +1,16 @@
1
+ import type { WorkerOptions, WorkerPlugin } from '@temporalio/worker';
2
+ export declare class MastraPlugin implements WorkerPlugin {
3
+ #private;
4
+ name: string;
5
+ constructor();
6
+ prebuild({ entryFile, projectRoot, }: {
7
+ entryFile: string;
8
+ projectRoot?: string;
9
+ }): Promise<ReturnType<typeof this.getTemporalWorkerOptions>>;
10
+ getTemporalWorkerOptions(temporalOutputDir: string): {
11
+ workflowsPath: WorkerOptions['workflowsPath'];
12
+ activities: WorkerOptions['activities'];
13
+ };
14
+ configureWorker(options: WorkerOptions): WorkerOptions;
15
+ }
16
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +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;;IAG/C,IAAI,SAAY;;IAiBV,QAAQ,CAAC,EACb,SAAS,EACT,WAA2B,GAC5B,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAoE7D,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG;QAEnD,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;QAC9C,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC;IAeD,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa;CAYvD"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { RequestContext } from '@mastra/core/di';
2
+ import { Run } from '@mastra/core/workflows';
3
+ import type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';
4
+ import type { Client } from '@temporalio/client';
5
+ import type { TemporalEngineType } from './types.js';
6
+ type TemporalRunStartArgs<TState, TInput, TRequestContext> = {
7
+ inputData?: TInput;
8
+ initialState?: TState;
9
+ requestContext?: RequestContext<TRequestContext>;
10
+ } & WorkflowRunStartOptions;
11
+ export declare class TemporalRun<TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<string, unknown, unknown, unknown, unknown, unknown, TemporalEngineType>[], TState = unknown, TInput = unknown, TOutput = unknown, TRequestContext extends Record<string, any> | unknown = unknown> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {
12
+ private readonly client;
13
+ private readonly taskQueue;
14
+ constructor(params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0], temporalParams: {
15
+ client: Client;
16
+ taskQueue: string;
17
+ });
18
+ start(args?: TemporalRunStartArgs<TState, TInput, TRequestContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
19
+ startAsync(args?: TemporalRunStartArgs<TState, TInput, TRequestContext>): Promise<{
20
+ runId: string;
21
+ }>;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,KAAK,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,IAAI;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAClD,GAAG,uBAAuB,CAAC;AAE5B,qBAAa,WAAW,CACtB,MAAM,SAAS,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,CACpF,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,kBAAkB,CACnB,EAAE,EACH,MAAM,GAAG,OAAO,EAChB,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,EACjB,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,OAAO,CAC/D,SAAQ,GAAG,CAAC,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC;IACjF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAGjC,MAAM,EAAE,qBAAqB,CAAC,OAAO,GAAG,CAAC,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,EAClH,cAAc,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB;IAQG,KAAK,CAAC,IAAI,GAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAM;IA0CtE,UAAU,CAAC,IAAI,GAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAM;;;CAwBlF"}
@@ -0,0 +1,295 @@
1
+ import { executeChild, proxyActivities, log, sleep } from '@temporalio/workflow';
2
+
3
+ export class TemporalExecutionEngine {
4
+ startToCloseTimeout;
5
+ activityHandle;
6
+
7
+ constructor(params) {
8
+ this.startToCloseTimeout = params?.options?.startToCloseTimeout ?? '1 minute';
9
+ this.activityHandle = proxyActivities({ startToCloseTimeout: this.startToCloseTimeout });
10
+ }
11
+
12
+ async execute(params) {
13
+ let result = params.input;
14
+ const stepResults = {};
15
+
16
+ for (const entry of params.graph.steps) {
17
+ result = await this.executeEntry(entry, result, stepResults);
18
+ }
19
+
20
+ return {
21
+ status: 'success',
22
+ input: params.input,
23
+ result,
24
+ state: params.initialState,
25
+ steps: stepResults,
26
+ };
27
+ }
28
+
29
+ async executeEntry(entry, inputData, stepResults) {
30
+ switch (entry.type) {
31
+ case 'step': {
32
+ log.info('step', { stepId: entry.step.id });
33
+ const out = await this.activityHandle[entry.step.id]({ inputData });
34
+ stepResults[entry.step.id] = out;
35
+ return out;
36
+ }
37
+
38
+ case 'childWorkflow': {
39
+ log.info('childWorkflow', { workflowType: entry.workflowType });
40
+ const childResult = await executeChild(entry.workflowType, { args: [{ inputData }] });
41
+ const out = childResult?.result ?? childResult;
42
+ stepResults[entry.workflowType] = out;
43
+ return out;
44
+ }
45
+
46
+ case 'sleep': {
47
+ const duration = entry.duration ?? (entry.fn ? await this.activityHandle[entry.fn]({ inputData }) : 0);
48
+ log.info('sleep', { id: entry.id, duration });
49
+ await sleep(duration);
50
+ return inputData;
51
+ }
52
+
53
+ case 'sleepUntil': {
54
+ const date =
55
+ entry.date != null
56
+ ? new Date(entry.date)
57
+ : entry.fn
58
+ ? new Date(await this.activityHandle[entry.fn]({ inputData }))
59
+ : new Date();
60
+ log.info('sleepUntil', { id: entry.id, date: date.toISOString() });
61
+ const duration = Math.max(0, date.getTime() - Date.now());
62
+ await sleep(duration);
63
+ return inputData;
64
+ }
65
+
66
+ case 'parallel': {
67
+ log.info('parallel', { steps: entry.steps.map(s => s.step.id) });
68
+ const results = await Promise.all(entry.steps.map(s => this.activityHandle[s.step.id]({ inputData })));
69
+ const out = {};
70
+
71
+ entry.steps.forEach((s, i) => {
72
+ out[s.step.id] = results[i];
73
+ stepResults[s.step.id] = results[i];
74
+ });
75
+
76
+ return out;
77
+ }
78
+
79
+ case 'conditional': {
80
+ log.info('conditional', {
81
+ conditions: entry.serializedConditions.map(condition => condition.id),
82
+ });
83
+ const condResults = await Promise.all(
84
+ entry.serializedConditions.map(condition => this.activityHandle[condition.id]({ inputData })),
85
+ );
86
+ const out = {};
87
+
88
+ for (let i = 0; i < entry.steps.length; i++) {
89
+ if (condResults[i]) {
90
+ const stepId = entry.steps[i].step.id;
91
+ const res = await this.activityHandle[stepId]({ inputData });
92
+ out[stepId] = res;
93
+ stepResults[stepId] = res;
94
+ }
95
+ }
96
+
97
+ return out;
98
+ }
99
+
100
+ case 'loop': {
101
+ log.info('loop', { step: entry.step.id, loopType: entry.loopType });
102
+ let current = inputData;
103
+
104
+ while (true) {
105
+ current = await this.activityHandle[entry.step.id]({ inputData: current });
106
+ stepResults[entry.step.id] = current;
107
+ const shouldContinue = Boolean(
108
+ await this.activityHandle[entry.serializedCondition.id]({ inputData: current }),
109
+ );
110
+
111
+ if (entry.loopType === 'dowhile' ? !shouldContinue : shouldContinue) {
112
+ break;
113
+ }
114
+ }
115
+
116
+ return current;
117
+ }
118
+
119
+ case 'foreach': {
120
+ log.info('foreach', { step: entry.step.id, concurrency: entry.opts.concurrency });
121
+ const items = Array.isArray(inputData) ? inputData : [];
122
+ const concurrency = Math.max(1, entry.opts.concurrency ?? 1);
123
+ const results = new Array(items.length);
124
+ let index = 0;
125
+ const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
126
+ while (true) {
127
+ const i = index++;
128
+ if (i >= items.length) {
129
+ break;
130
+ }
131
+ results[i] = await this.activityHandle[entry.step.id]({ inputData: items[i] });
132
+ }
133
+ });
134
+
135
+ await Promise.all(workers);
136
+ stepResults[entry.step.id] = results;
137
+ return results;
138
+ }
139
+
140
+ default:
141
+ return inputData;
142
+ }
143
+ }
144
+ }
145
+
146
+ export function createWorkflow(workflowId) {
147
+ const stepFlow = [];
148
+ let autoId = 0;
149
+ const nextId = prefix => `${prefix}_${autoId++}`;
150
+
151
+ const workflow = async startArgs => {
152
+ const engine = new TemporalExecutionEngine({
153
+ options: {
154
+ startToCloseTimeout: '1 minute',
155
+ },
156
+ });
157
+
158
+ return engine.execute({
159
+ workflowId,
160
+ runId: startArgs?.runId,
161
+ resourceId: startArgs?.resourceId,
162
+ graph: {
163
+ id: workflowId,
164
+ steps: stepFlow,
165
+ },
166
+ input: startArgs?.inputData,
167
+ initialState: startArgs?.initialState,
168
+ });
169
+ };
170
+
171
+ return Object.assign(workflow, {
172
+ then(stepId) {
173
+ stepFlow.push({
174
+ type: 'step',
175
+ step: {
176
+ id: stepId,
177
+ },
178
+ });
179
+ return workflow;
180
+ },
181
+ thenWorkflow(workflowType) {
182
+ stepFlow.push({
183
+ type: 'childWorkflow',
184
+ workflowType,
185
+ });
186
+ return workflow;
187
+ },
188
+ sleep(durationOrFnId) {
189
+ if (typeof durationOrFnId === 'number') {
190
+ stepFlow.push({
191
+ type: 'sleep',
192
+ id: nextId('sleep'),
193
+ duration: durationOrFnId,
194
+ });
195
+ } else {
196
+ stepFlow.push({
197
+ type: 'sleep',
198
+ id: nextId('sleep'),
199
+ fn: durationOrFnId,
200
+ });
201
+ }
202
+ return workflow;
203
+ },
204
+ sleepUntil(dateOrFnId) {
205
+ if (dateOrFnId instanceof Date) {
206
+ stepFlow.push({
207
+ type: 'sleepUntil',
208
+ id: nextId('sleepUntil'),
209
+ date: dateOrFnId.toISOString(),
210
+ });
211
+ } else if (typeof dateOrFnId === 'number' || (typeof dateOrFnId === 'string' && !isNaN(Date.parse(dateOrFnId)))) {
212
+ stepFlow.push({
213
+ type: 'sleepUntil',
214
+ id: nextId('sleepUntil'),
215
+ date: new Date(dateOrFnId).toISOString(),
216
+ });
217
+ } else {
218
+ stepFlow.push({
219
+ type: 'sleepUntil',
220
+ id: nextId('sleepUntil'),
221
+ fn: dateOrFnId,
222
+ });
223
+ }
224
+ return workflow;
225
+ },
226
+ parallel(stepIds) {
227
+ stepFlow.push({
228
+ type: 'parallel',
229
+ steps: stepIds.map(id => ({
230
+ type: 'step',
231
+ step: {
232
+ id,
233
+ },
234
+ })),
235
+ });
236
+ return workflow;
237
+ },
238
+ branch(pairs) {
239
+ stepFlow.push({
240
+ type: 'conditional',
241
+ serializedConditions: pairs.map(pair => ({
242
+ id: pair[0],
243
+ })),
244
+ steps: pairs.map(pair => ({
245
+ type: 'step',
246
+ step: {
247
+ id: pair[1],
248
+ },
249
+ })),
250
+ });
251
+ return workflow;
252
+ },
253
+ dowhile(stepId, condId) {
254
+ stepFlow.push({
255
+ type: 'loop',
256
+ step: {
257
+ id: stepId,
258
+ },
259
+ serializedCondition: {
260
+ id: condId,
261
+ },
262
+ loopType: 'dowhile',
263
+ });
264
+ return workflow;
265
+ },
266
+ dountil(stepId, condId) {
267
+ stepFlow.push({
268
+ type: 'loop',
269
+ step: {
270
+ id: stepId,
271
+ },
272
+ serializedCondition: {
273
+ id: condId,
274
+ },
275
+ loopType: 'dountil',
276
+ });
277
+ return workflow;
278
+ },
279
+ foreach(stepId, opts) {
280
+ stepFlow.push({
281
+ type: 'foreach',
282
+ step: {
283
+ id: stepId,
284
+ },
285
+ opts: {
286
+ concurrency: opts?.concurrency ?? 1,
287
+ },
288
+ });
289
+ return workflow;
290
+ },
291
+ commit() {
292
+ return workflow;
293
+ },
294
+ });
295
+ }
@@ -0,0 +1,11 @@
1
+ export interface TemporalActivityBinding {
2
+ exportName: string;
3
+ stepId: string;
4
+ }
5
+ export interface BuildTemporalActivitiesModuleResult {
6
+ outputPath: string;
7
+ activityBindings: TemporalActivityBinding[];
8
+ }
9
+ export declare function collectTemporalActivityBindings(sourceText: string, filePath: string): TemporalActivityBinding[];
10
+ export declare function buildTemporalActivitiesModule(entryFile: string, outputDirectory: string, outputFileName: string): Promise<BuildTemporalActivitiesModuleResult>;
11
+ //# sourceMappingURL=activities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AAsBA,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,CAkE/G;AA6HD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CA0T9C"}
@@ -0,0 +1,23 @@
1
+ import * as t from '@babel/types';
2
+ export declare const parserPlugins: readonly ["typescript", "jsx", "classProperties", "classPrivateProperties", "classPrivateMethods", "topLevelAwait", "importAttributes", "decorators-legacy"];
3
+ export declare function parseModule(filePath: string, sourceText?: string): t.File;
4
+ export declare function isIdentifierNamed(node: t.Node, name: string): boolean;
5
+ export declare function isTemporalHelperModule(source: string): boolean;
6
+ export declare const strippedExternalModules: Set<string>;
7
+ export declare function isStrippedExternalModule(source: string): boolean;
8
+ export declare function collectImportedNames(statement: t.ImportDeclaration): Set<string>;
9
+ export declare function nodeReferencesName(node: t.Node, names: Set<string>): boolean;
10
+ export declare function isWorkflowHelperDestructure(declaration: t.VariableDeclarator): boolean;
11
+ export declare function isCreateWorkflowCall(node: t.Node): node is t.CallExpression;
12
+ export declare function isCreateStepCall(node: t.Node): node is t.CallExpression;
13
+ export declare function getObjectPropertyName(property: t.ObjectProperty | t.ObjectMethod): string | null;
14
+ export declare function walk(node: t.Node | null | undefined, visitor: (node: t.Node) => false | void): void;
15
+ export declare function hasCreateWorkflowCall(node: t.Node): boolean;
16
+ export declare function getStepNameFromCall(node: t.CallExpression): string | null;
17
+ export declare function createExportedStepStatement(name: string, initializer: t.Expression): t.ExportNamedDeclaration;
18
+ export declare function collectInlineCreateSteps(node: t.Node, seenNames: Set<string>, statements: t.Statement[], onStep?: (exportName: string, call: t.CallExpression) => void): void;
19
+ export declare function getCreateStepId(node: t.Node | null | undefined): string | null;
20
+ export declare function shouldCountIdentifierAsReference(parent: t.Node | null, key: string | null): boolean;
21
+ export declare function collectRuntimeReferencedIdentifiers(node: t.Node): Set<string>;
22
+ export declare function pruneUnusedTopLevelBindings(statements: t.Statement[]): t.Statement[];
23
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/transforms/shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,eAAO,MAAM,aAAa,8JAShB,CAAC;AACX,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,CAUzE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,eAAO,MAAM,uBAAuB,aAA2D,CAAC;AAEhG,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,CAAC,CAAC,iBAAiB,GAAG,GAAG,CAAC,MAAM,CAAC,CAgBhF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAW5E;AAED,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,CAAC,CAAC,kBAAkB,GAAG,OAAO,CAYtF;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,cAAc,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,cAAc,CAEvE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,YAAY,GAAG,MAAM,GAAG,IAAI,CAchG;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,IAAI,CA2BnG;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,OAAO,CAW3D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,GAAG,MAAM,GAAG,IAAI,CAUzE;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,sBAAsB,CAI7G;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,CAAC,CAAC,IAAI,EACZ,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,EACtB,UAAU,EAAE,CAAC,CAAC,SAAS,EAAE,EACzB,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,KAAK,IAAI,GAC5D,IAAI,CAgBN;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAwB9E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CA+DnG;AAED,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAsC7E;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,SAAS,EAAE,CA4IpF"}
@@ -0,0 +1,92 @@
1
+ export function createWorkflow(workflowId: any): ((startArgs: any) => Promise<{
2
+ status: string;
3
+ input: any;
4
+ result: any;
5
+ state: any;
6
+ steps: {};
7
+ }>) & {
8
+ then(stepId: any): (startArgs: any) => Promise<{
9
+ status: string;
10
+ input: any;
11
+ result: any;
12
+ state: any;
13
+ steps: {};
14
+ }>;
15
+ thenWorkflow(workflowType: any): (startArgs: any) => Promise<{
16
+ status: string;
17
+ input: any;
18
+ result: any;
19
+ state: any;
20
+ steps: {};
21
+ }>;
22
+ sleep(durationOrFnId: any): (startArgs: any) => Promise<{
23
+ status: string;
24
+ input: any;
25
+ result: any;
26
+ state: any;
27
+ steps: {};
28
+ }>;
29
+ sleepUntil(dateOrFnId: any): (startArgs: any) => Promise<{
30
+ status: string;
31
+ input: any;
32
+ result: any;
33
+ state: any;
34
+ steps: {};
35
+ }>;
36
+ parallel(stepIds: any): (startArgs: any) => Promise<{
37
+ status: string;
38
+ input: any;
39
+ result: any;
40
+ state: any;
41
+ steps: {};
42
+ }>;
43
+ branch(pairs: any): (startArgs: any) => Promise<{
44
+ status: string;
45
+ input: any;
46
+ result: any;
47
+ state: any;
48
+ steps: {};
49
+ }>;
50
+ dowhile(stepId: any, condId: any): (startArgs: any) => Promise<{
51
+ status: string;
52
+ input: any;
53
+ result: any;
54
+ state: any;
55
+ steps: {};
56
+ }>;
57
+ dountil(stepId: any, condId: any): (startArgs: any) => Promise<{
58
+ status: string;
59
+ input: any;
60
+ result: any;
61
+ state: any;
62
+ steps: {};
63
+ }>;
64
+ foreach(stepId: any, opts: any): (startArgs: any) => Promise<{
65
+ status: string;
66
+ input: any;
67
+ result: any;
68
+ state: any;
69
+ steps: {};
70
+ }>;
71
+ commit(): (startArgs: any) => Promise<{
72
+ status: string;
73
+ input: any;
74
+ result: any;
75
+ state: any;
76
+ steps: {};
77
+ }>;
78
+ };
79
+ export class TemporalExecutionEngine {
80
+ constructor(params: any);
81
+ startToCloseTimeout: any;
82
+ activityHandle: import("@temporalio/workflow").ActivityInterfaceFor<import("@temporalio/workflow").UntypedActivities>;
83
+ execute(params: any): Promise<{
84
+ status: string;
85
+ input: any;
86
+ result: any;
87
+ state: any;
88
+ steps: {};
89
+ }>;
90
+ executeEntry(entry: any, inputData: any, stepResults: any): Promise<any>;
91
+ }
92
+ //# sourceMappingURL=temporal-workflow-runtime.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAiJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqJC;AApSD;IAIE,yBAGC;IAND,yBAAoB;IACpB,sHAAe;IAOf;;;;;;OAeC;IAED,yEAkHC;CACF"}
@@ -0,0 +1,20 @@
1
+ export interface BuildTemporalWorkflowOptions {
2
+ }
3
+ export interface TemporalWorkflowExport {
4
+ exportName: string;
5
+ workflowId: string;
6
+ }
7
+ export interface BuildTemporalWorkflowModuleResult {
8
+ code: string;
9
+ workflows: TemporalWorkflowExport[];
10
+ }
11
+ /**
12
+ * Transforms a user-authored workflow module into a Temporal-friendly module:
13
+ * - strips Mastra/Temporal setup that cannot run in the workflow sandbox
14
+ * - rewrites fluent workflow chains into deterministic exported functions
15
+ * - returns registry metadata so the entry module can re-export the right names
16
+ */
17
+ export declare function buildTemporalWorkflowModule(entryFile: string, outputDirectory: string, outputFileName: string): Promise<{
18
+ outputPath: string;
19
+ }>;
20
+ //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/transforms/workflows.ts"],"names":[],"mappings":"AAsYA,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;AAiUD;;;;;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,CAwCjC"}
@@ -0,0 +1,4 @@
1
+ export type TemporalEngineType = {
2
+ step: any;
3
+ };
4
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export declare function toWorkflowType(id: string): string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,UAGxC"}