motia 0.0.33 → 0.0.34
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 +108 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,18 +1,91 @@
|
|
|
1
|
-
# Motia
|
|
1
|
+
# Motia
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/motiajs/motia/main/assets/logo.png" alt="Motia Logo" width="200" />
|
|
5
|
+
</p>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>A modern, declarative workflow framework for multiple programming languages</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/motia"><img src="https://img.shields.io/npm/v/motia.svg" alt="npm version"></a>
|
|
13
|
+
<a href="https://github.com/motiajs/motia/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
## What is Motia?
|
|
17
|
+
|
|
18
|
+
Motia is a lightweight, flexible framework for building complex workflows and business processes across multiple programming languages. It allows you to define, visualize, and execute workflows with a clean, declarative API in JavaScript, TypeScript, Ruby, Python, and more languages coming soon.
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
Key features:
|
|
21
|
+
- 🔄 **Declarative Workflows**: Define complex processes with a simple, readable syntax
|
|
22
|
+
- 🛠️ **Type-Safe**: Built with strong typing support for all supported languages
|
|
23
|
+
- 🔍 **Visualizable**: Inspect and debug your workflows with Motia Workbench
|
|
24
|
+
- 🧩 **Composable**: Build complex workflows from reusable components
|
|
25
|
+
- 🚀 **Multi-Language Support**: Works with JavaScript, TypeScript, Ruby, Python, with more languages coming soon
|
|
26
|
+
- 🌐 **Framework Agnostic**: Integrates with any framework in your language of choice
|
|
8
27
|
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### JavaScript/TypeScript
|
|
9
31
|
```sh
|
|
10
|
-
npm install
|
|
32
|
+
npm install motia
|
|
33
|
+
# or
|
|
34
|
+
yarn add motia
|
|
35
|
+
# or
|
|
36
|
+
pnpm add motia
|
|
11
37
|
```
|
|
12
38
|
|
|
13
|
-
## Usage
|
|
14
39
|
|
|
15
|
-
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
### Email Auto-Reply with Sentiment Analysis
|
|
45
|
+
|
|
46
|
+
Here's a real-world example of using Motia to create an automated email reply system with sentiment analysis:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { OpenAI } from 'openai';
|
|
50
|
+
import { z } from 'zod';
|
|
51
|
+
import type { EventConfig, StepHandler } from 'motia';
|
|
52
|
+
|
|
53
|
+
const openai = new OpenAI({
|
|
54
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const config: EventConfig = {
|
|
58
|
+
type: 'event',
|
|
59
|
+
name: 'Auto-Reply to Support Emails',
|
|
60
|
+
subscribes: ['email.received'],
|
|
61
|
+
emits: ['email.send'],
|
|
62
|
+
flows: ['email-support'],
|
|
63
|
+
input: z.object({ subject: z.string(), body: z.string(), from: z.string() }),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const handler: StepHandler<typeof config> = async (inputData, context) => {
|
|
67
|
+
const { subject, body, from } = inputData;
|
|
68
|
+
const { emit, logger } = context;
|
|
69
|
+
|
|
70
|
+
const sentimentResponse = await openai.chat.completions.create({
|
|
71
|
+
model: "gpt-4o",
|
|
72
|
+
messages: [{ role: "user", content: `Analyze the sentiment of the following email: ${body}` }]
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const sentiment = sentimentResponse.choices[0].message.content;
|
|
76
|
+
|
|
77
|
+
logger.info('[EmailAutoReply] Sentiment analysis', { sentiment });
|
|
78
|
+
|
|
79
|
+
emit({
|
|
80
|
+
type: 'email.send',
|
|
81
|
+
data: { from, subject, body, sentiment },
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## CLI Commands
|
|
87
|
+
|
|
88
|
+
Motia comes with a powerful CLI to help you manage your projects:
|
|
16
89
|
|
|
17
90
|
### `motia init`
|
|
18
91
|
|
|
@@ -38,6 +111,26 @@ Initiates a dev environment for your project allowing you to use Motia Workbench
|
|
|
38
111
|
motia dev
|
|
39
112
|
```
|
|
40
113
|
|
|
114
|
+
## Visualizing Workflows
|
|
115
|
+
|
|
116
|
+
Motia Workbench provides a visual interface to inspect and debug your workflows:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
motia dev
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Then open your browser at `http://localhost:3000` to see your workflows in action.
|
|
123
|
+
|
|
124
|
+
## Language Support
|
|
125
|
+
|
|
126
|
+
Motia currently supports:
|
|
127
|
+
- JavaScript
|
|
128
|
+
- TypeScript
|
|
129
|
+
- Ruby
|
|
130
|
+
- Python
|
|
131
|
+
|
|
132
|
+
With more languages coming soon!
|
|
133
|
+
|
|
41
134
|
## Help
|
|
42
135
|
|
|
43
136
|
For more information on a specific command, you can use the `--help` flag:
|
|
@@ -46,6 +139,14 @@ For more information on a specific command, you can use the `--help` flag:
|
|
|
46
139
|
motia <command> --help
|
|
47
140
|
```
|
|
48
141
|
|
|
142
|
+
## Documentation
|
|
143
|
+
|
|
144
|
+
For full documentation, visit [https://motia.dev/docs](https://motia.dev/docs)
|
|
145
|
+
|
|
146
|
+
## Contributing
|
|
147
|
+
|
|
148
|
+
We welcome contributions! Please see our [Contributing Guide](https://github.com/motiajs/motia/blob/main/CONTRIBUTING.md) for details.
|
|
149
|
+
|
|
49
150
|
## License
|
|
50
151
|
|
|
51
152
|
This project is licensed under the MIT License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motia",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"motia": "dist/src/cli.js"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"inquirer": "^12.4.1",
|
|
17
17
|
"ts-node": "^10.9.2",
|
|
18
18
|
"yaml": "^2.7.0",
|
|
19
|
-
"@motiadev/core": "0.0.
|
|
20
|
-
"@motiadev/workbench": "0.0.
|
|
19
|
+
"@motiadev/core": "0.0.34",
|
|
20
|
+
"@motiadev/workbench": "0.0.34"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/archiver": "^6.0.3",
|