motia 0.0.37 → 0.0.39-alpha

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 CHANGED
@@ -36,51 +36,55 @@ yarn add motia
36
36
  pnpm add motia
37
37
  ```
38
38
 
39
-
40
39
  ## Quick Start
41
40
 
42
- ### Email Auto-Reply with Sentiment Analysis
43
-
44
- Here's a real-world example of using Motia to create an automated email reply system with sentiment analysis:
45
-
46
- ```typescript
47
- import { OpenAI } from 'openai';
48
- import { z } from 'zod';
49
- import type { EventConfig, StepHandler } from 'motia';
50
-
51
- const openai = new OpenAI({
52
- apiKey: process.env.OPENAI_API_KEY,
53
- });
54
-
55
- export const config: EventConfig = {
56
- type: 'event',
57
- name: 'Auto-Reply to Support Emails',
58
- subscribes: ['email.received'],
59
- emits: ['email.send'],
60
- flows: ['email-support'],
61
- input: z.object({ subject: z.string(), body: z.string(), from: z.string() }),
62
- };
63
-
64
- export const handler: StepHandler<typeof config> = async (inputData, context) => {
65
- const { subject, body, from } = inputData;
66
- const { emit, logger } = context;
67
-
68
- const sentimentResponse = await openai.chat.completions.create({
69
- model: "gpt-4o",
70
- messages: [{ role: "user", content: `Analyze the sentiment of the following email: ${body}` }]
71
- });
72
-
73
- const sentiment = sentimentResponse.choices[0].message.content;
74
-
75
- logger.info('[EmailAutoReply] Sentiment analysis', { sentiment });
76
-
77
- emit({
78
- type: 'email.send',
79
- data: { from, subject, body, sentiment },
80
- });
81
- };
82
- ```
41
+ Ready to get started in minutes? Follow these simple steps using **pnpm** and the automated project creation:
42
+
43
+ 1. **Create a new project using the Motia CLI:**
44
+
45
+ ```bash
46
+ npx motia create -t default -n my-motia-project
47
+ ```
48
+ *(Replace `my-motia-project` with your desired project name)*
49
+
50
+ This command will:
51
+ * Create a new folder `my-motia-project`
52
+ * Set up a basic Motia project with example steps
53
+ * Install dependencies using pnpm
54
+
55
+ 2. **Navigate into your new project directory:**
56
+
57
+ ```bash
58
+ cd my-motia-project
59
+ ```
60
+
61
+ 3. **Start the Motia development server:**
62
+
63
+ ```bash
64
+ pnpm run dev
65
+ ```
66
+
67
+ This will launch the Motia server and the Workbench UI (typically at `http://localhost:3000`).
68
+
69
+ 4. **Open the Motia Workbench in your browser (usually `http://localhost:3000`)**. You should see a pre-built flow named "default" with example steps visualized.
70
+
71
+ 5. **Test an example API Step:** In your terminal, use `curl` to trigger the example API endpoint (often `/default` in the default template):
72
+
73
+ ```bash
74
+ curl -X POST http://localhost:3000/default \
75
+ -H "Content-Type: application/json" \
76
+ -d '{}'
77
+ ```
78
+
79
+ Alternatively, use the Motia CLI to emit an event (for event-based steps in the template):
80
+
81
+ ```bash
82
+ npx motia emit --topic test-state --message '{}'
83
+ ```
84
+
85
+ Check the Workbench logs – you should see logs indicating the step execution and event flow!
83
86
 
87
+ **Congratulations! You've just created and run your first Motia workflow using the automated project setup.**
84
88
  ## CLI Commands
85
89
 
86
90
  Motia comes with a powerful CLI to help you manage your projects:
package/dist/src/cli.js CHANGED
@@ -22,7 +22,7 @@ commander_1.program
22
22
  .action(async (arg) => {
23
23
  const { create } = require('./create');
24
24
  await create({
25
- projectName: arg.project ?? '.',
25
+ projectName: arg.name ?? '.',
26
26
  template: arg.template ?? undefined,
27
27
  });
28
28
  });
@@ -84,7 +84,7 @@ commander_1.program
84
84
  method: 'POST',
85
85
  headers: { 'Content-Type': 'application/json' },
86
86
  body: JSON.stringify({
87
- type: options.topic,
87
+ topic: options.topic,
88
88
  data: JSON.parse(options.message),
89
89
  }),
90
90
  });
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "motia",
3
3
  "description": "Code-first framework for intelligent workflows",
4
- "version": "0.0.37",
4
+ "version": "0.0.39-alpha",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/motiadev/motia.git"
9
+ },
6
10
  "bin": {
7
11
  "motia": "dist/src/cli.js"
8
12
  },
@@ -17,8 +21,8 @@
17
21
  "inquirer": "^12.4.1",
18
22
  "ts-node": "^10.9.2",
19
23
  "yaml": "^2.7.0",
20
- "@motiadev/workbench": "0.0.37",
21
- "@motiadev/core": "0.0.37"
24
+ "@motiadev/core": "0.0.39-alpha",
25
+ "@motiadev/workbench": "0.0.39-alpha"
22
26
  },
23
27
  "devDependencies": {
24
28
  "@types/archiver": "^6.0.3",