@mastra/temporal 0.4.2-alpha.6 → 0.4.2-alpha.8
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/README.md +8 -64
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -7,62 +7,10 @@ Run Mastra workflows on [Temporal](https://temporal.io/) with a workflow authori
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @mastra/temporal
|
|
10
|
+
npm install @mastra/temporal
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
The following example demonstrates the same pattern used in the `temporal-snapshot` app: create a Temporal client, call `init()`, and define workflows with `createWorkflow()` and `createStep()`.
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { z } from 'zod';
|
|
19
|
-
import { init } from '@mastra/temporal';
|
|
20
|
-
import { loadClientConnectConfig } from '@temporalio/envconfig';
|
|
21
|
-
import { Client, Connection } from '@temporalio/client';
|
|
22
|
-
|
|
23
|
-
const config = loadClientConnectConfig();
|
|
24
|
-
const connection = await Connection.connect(config.connectionOptions);
|
|
25
|
-
const client = new Client({ connection });
|
|
26
|
-
|
|
27
|
-
const { createWorkflow, createStep } = init({
|
|
28
|
-
client,
|
|
29
|
-
taskQueue: 'mastra',
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const fetchWeather = createStep({
|
|
33
|
-
id: 'fetch-weather',
|
|
34
|
-
inputSchema: z.object({ city: z.string() }),
|
|
35
|
-
outputSchema: z.object({ forecast: z.string() }),
|
|
36
|
-
execute: async ({ inputData }) => {
|
|
37
|
-
return {
|
|
38
|
-
forecast: `Sunny in ${inputData.city}`,
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export const weatherWorkflow = createWorkflow({
|
|
44
|
-
id: 'weather-workflow',
|
|
45
|
-
inputSchema: z.object({ city: z.string() }),
|
|
46
|
-
outputSchema: z.object({ forecast: z.string() }),
|
|
47
|
-
}).then(fetchWeather);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Register the workflow in your Mastra entry file
|
|
51
|
-
|
|
52
|
-
`MastraPlugin` precompiles your Mastra entry file into dedicated workflow and activity modules before Temporal starts. Point the plugin at the file where your `Mastra` instance registers workflows.
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import { Mastra } from '@mastra/core/mastra';
|
|
56
|
-
import { weatherWorkflow } from './workflows/weather-workflow';
|
|
57
|
-
|
|
58
|
-
export const mastra = new Mastra({
|
|
59
|
-
workflows: { weatherWorkflow },
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Start a Temporal worker
|
|
64
|
-
|
|
65
|
-
Create a worker and pass the Mastra entry file to `MastraPlugin`.
|
|
13
|
+
## Usage
|
|
66
14
|
|
|
67
15
|
```ts
|
|
68
16
|
import { NativeConnection, Worker } from '@temporalio/worker';
|
|
@@ -84,18 +32,14 @@ const worker = await Worker.create({
|
|
|
84
32
|
await worker.run();
|
|
85
33
|
```
|
|
86
34
|
|
|
87
|
-
##
|
|
35
|
+
## Documentation
|
|
88
36
|
|
|
89
|
-
-
|
|
90
|
-
- `MastraPlugin(entryFile)`: Points the plugin at the Mastra entry file that registers workflows and compiles it when the worker is configured.
|
|
91
|
-
- Generated activities: The plugin extracts `createStep()` handlers into `node_modules/.mastra/activities.mjs` and wires them into the worker automatically.
|
|
92
|
-
- `debug: true`: Writes emitted workflow bundles to `node_modules/.mastra` for inspection.
|
|
37
|
+
- [Temporal deployment and worker guide](https://mastra.ai/integrations/deploy/temporal)
|
|
93
38
|
|
|
94
|
-
##
|
|
39
|
+
## Changelog
|
|
95
40
|
|
|
96
|
-
|
|
97
|
-
- The plugin expects `entryFile` to point to the Mastra entry file that registers workflows in `new Mastra({ workflows: ... })`.
|
|
41
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/workflows/temporal/CHANGELOG.md) for version history and release notes.
|
|
98
42
|
|
|
99
|
-
##
|
|
43
|
+
## Support
|
|
100
44
|
|
|
101
|
-
|
|
45
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/temporal",
|
|
3
|
-
"version": "0.4.2-alpha.
|
|
3
|
+
"version": "0.4.2-alpha.8",
|
|
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",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@temporalio/worker": "^1.22.0",
|
|
51
51
|
"@temporalio/workflow": "^1.22.0",
|
|
52
52
|
"rollup": "^4.61.1",
|
|
53
|
-
"@mastra/deployer": "1.64.0-alpha.
|
|
53
|
+
"@mastra/deployer": "1.64.0-alpha.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@mastra/core": ">=1.50.0-0 <2.0.0-0",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"zod": "^4.4.3",
|
|
66
66
|
"@internal/lint": "0.0.129",
|
|
67
67
|
"@internal/types-builder": "0.0.104",
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
68
|
+
"@internal/workflow-test-utils": "0.0.30",
|
|
69
|
+
"@mastra/core": "1.64.0-alpha.8"
|
|
70
70
|
},
|
|
71
71
|
"homepage": "https://mastra.ai",
|
|
72
72
|
"repository": {
|