motia 0.17.11-beta.193 → 0.17.12-beta.194

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 (37) hide show
  1. package/README.md +1 -3
  2. package/dist/create/templates/hello/.env +3 -0
  3. package/dist/create/templates/hello/README.md.txt +10 -60
  4. package/dist/create/templates/hello_js/.env +3 -0
  5. package/dist/create/templates/hello_js/README.md.txt +10 -60
  6. package/dist/create/templates/hello_multilang/.env +3 -0
  7. package/dist/create/templates/hello_multilang/README.md.txt +10 -83
  8. package/dist/create/templates/hello_python/.env +3 -0
  9. package/dist/create/templates/hello_python/README.md.txt +10 -61
  10. package/dist/create/templates/nodejs/.env +3 -0
  11. package/dist/create/templates/nodejs/README.md.txt +10 -69
  12. package/dist/create/templates/nodejs/src/petstore/api.step.ts.txt +1 -1
  13. package/dist/create/templates/nodejs/src/petstore/state-audit-cron.step.ts.txt +1 -1
  14. package/dist/create/templates/nodejs/src/services/pet-store.ts.txt +4 -2
  15. package/dist/create/templates/python/.env +3 -0
  16. package/dist/create/templates/python/README.md.txt +10 -70
  17. package/dist/create/templates/python/src/petstore/api_step.py.txt +2 -1
  18. package/dist/create/templates/python/src/petstore/state_audit_cron_step.py.txt +2 -1
  19. package/dist/create/templates/python/src/services/pet_store.py.txt +5 -2
  20. package/dist/create/templates/python/tutorial/petstore/api_step.py-features.json.txt +8 -8
  21. package/dist/create/templates/python/tutorial/petstore/state_audit_cron_step.py-features.json.txt +4 -10
  22. package/dist/cursor-rules/dot-files/.claude/agents/motia-developer.md +1 -1
  23. package/dist/cursor-rules/dot-files/.cursor/architecture/architecture.mdc +5 -26
  24. package/dist/cursor-rules/dot-files/.cursor/rules/motia/api-steps.mdc +2 -2
  25. package/dist/cursor-rules/dot-files/.cursor/rules/motia/cron-steps.mdc +2 -2
  26. package/dist/cursor-rules/dot-files/.cursor/rules/motia/event-steps.mdc +2 -2
  27. package/dist/cursor-rules/dot-files/.cursor/rules/motia/middlewares.mdc +1 -1
  28. package/dist/cursor-rules/dot-files/.cursor/rules/motia/motia-config.mdc +1 -1
  29. package/dist/cursor-rules/dot-files/.cursor/rules/motia/realtime-streaming.mdc +4 -4
  30. package/dist/cursor-rules/dot-files/.cursor/rules/motia/state-management.mdc +1 -1
  31. package/dist/cursor-rules/dot-files/.cursor/rules/motia/ui-steps.mdc +2 -2
  32. package/dist/cursor-rules/dot-files/.cursor/rules/motia/virtual-steps.mdc +2 -2
  33. package/dist/cursor-rules/dot-files/AGENTS.md +2 -15
  34. package/dist/cursor-rules/dot-files/CLAUDE.md +1 -1
  35. package/dist/install.mjs +18 -13
  36. package/dist/install.mjs.map +1 -1
  37. package/package.json +8 -8
package/README.md CHANGED
@@ -46,7 +46,7 @@ Follow the prompts to pick a template, project name, and language.
46
46
  Inside your new project folder, launch the dev server:
47
47
 
48
48
  ```bash
49
- npx motia dev # ➜ http://localhost:3000
49
+ npm run dev # ➜ http://localhost:3000
50
50
  ```
51
51
 
52
52
  This spins up the Motia Workbench – a local UI for building, testing & observing your backend in real-time.
@@ -245,8 +245,6 @@ npm run dev [options]
245
245
  yarn dev [options]
246
246
  # or
247
247
  pnpm dev [options]
248
- # or
249
- bun run dev [options]
250
248
 
251
249
  # options:
252
250
  # -p, --port <port> The port to run the server on (default: 3000)
@@ -0,0 +1,3 @@
1
+ # Motia automatically loads environment variables from .env files
2
+ APP_NAME="Motia App"
3
+ GREETING_PREFIX="Hello"
@@ -1,10 +1,8 @@
1
1
  # {{PROJECT_NAME}}
2
2
 
3
- A Motia project created with the starter template.
3
+ This is a **Motia** project bootstrapped with the Motia CLI.
4
4
 
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
5
+ Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
8
6
 
9
7
  ## Quick Start
10
8
 
@@ -17,67 +15,19 @@ yarn dev
17
15
  pnpm dev
18
16
  ```
19
17
 
20
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
21
-
22
- ```bash
23
- # Test your first endpoint
24
- curl http://localhost:3000/hello
25
- ```
26
-
27
- ## Step Types
28
-
29
- Every Step has a `type` that defines how it triggers:
30
-
31
- | Type | When it runs | Use case |
32
- |------|--------------|----------|
33
- | **`api`** | HTTP request | REST APIs, webhooks |
34
- | **`event`** | Event emitted | Background jobs, workflows |
35
- | **`cron`** | Schedule | Cleanup, reports, reminders |
36
-
37
- ## Development Commands
38
-
39
- ```bash
40
- # Start Workbench and development server
41
- npm run dev
42
- # or
43
- yarn dev
44
- # or
45
- pnpm dev
46
-
47
- # Start production server (without hot reload)
48
- npm run start
49
- # or
50
- yarn start
51
- # or
52
- pnpm start
18
+ This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
53
19
 
54
- # Generate TypeScript types from Step configs
55
- npm run generate-types
56
- # or
57
- yarn generate-types
58
- # or
59
- pnpm generate-types
20
+ You can start editing the project by making changes to `src/hello/hello-api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
60
21
 
61
- # Build project for deployment
62
- npm run build
63
- # or
64
- yarn build
65
- # or
66
- pnpm build
67
- ```
22
+ Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
68
23
 
69
- ## Project Structure
70
-
71
- ```
72
- steps/ # Your Step definitions (or use src/)
73
- motia.config.ts # Motia configuration
74
- ```
24
+ ## Project Config
75
25
 
76
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required.
26
+ The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
77
27
 
78
28
  ## Learn More
79
29
 
80
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
81
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
82
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
30
+ - [Docs](https://motia.dev/docs) - Complete guides and API reference
31
+ - [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
32
+ - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
83
33
  - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -0,0 +1,3 @@
1
+ # Motia automatically loads environment variables from .env files
2
+ APP_NAME="Motia App"
3
+ GREETING_PREFIX="Hello"
@@ -1,10 +1,8 @@
1
1
  # {{PROJECT_NAME}}
2
2
 
3
- A Motia project created with the starter template.
3
+ This is a **Motia** project bootstrapped with the Motia CLI.
4
4
 
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
5
+ Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
8
6
 
9
7
  ## Quick Start
10
8
 
@@ -17,67 +15,19 @@ yarn dev
17
15
  pnpm dev
18
16
  ```
19
17
 
20
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
21
-
22
- ```bash
23
- # Test your first endpoint
24
- curl http://localhost:3000/hello
25
- ```
26
-
27
- ## Step Types
28
-
29
- Every Step has a `type` that defines how it triggers:
30
-
31
- | Type | When it runs | Use case |
32
- |------|--------------|----------|
33
- | **`api`** | HTTP request | REST APIs, webhooks |
34
- | **`event`** | Event emitted | Background jobs, workflows |
35
- | **`cron`** | Schedule | Cleanup, reports, reminders |
36
-
37
- ## Development Commands
38
-
39
- ```bash
40
- # Start Workbench and development server
41
- npm run dev
42
- # or
43
- yarn dev
44
- # or
45
- pnpm dev
46
-
47
- # Start production server (without hot reload)
48
- npm run start
49
- # or
50
- yarn start
51
- # or
52
- pnpm start
18
+ This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
53
19
 
54
- # Generate TypeScript types from Step configs
55
- npm run generate-types
56
- # or
57
- yarn generate-types
58
- # or
59
- pnpm generate-types
20
+ You can start editing the project by making changes to `src/hello/hello-api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
60
21
 
61
- # Build project for deployment
62
- npm run build
63
- # or
64
- yarn build
65
- # or
66
- pnpm build
67
- ```
22
+ Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
68
23
 
69
- ## Project Structure
70
-
71
- ```
72
- steps/ # Your Step definitions (or use src/)
73
- motia.config.ts # Motia configuration
74
- ```
24
+ ## Project Config
75
25
 
76
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required.
26
+ The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
77
27
 
78
28
  ## Learn More
79
29
 
80
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
81
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
82
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
30
+ - [Docs](https://motia.dev/docs) - Complete guides and API reference
31
+ - [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
32
+ - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
83
33
  - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -0,0 +1,3 @@
1
+ # Motia automatically loads environment variables from .env files
2
+ APP_NAME="Motia App"
3
+ GREETING_PREFIX="Hello"
@@ -1,20 +1,8 @@
1
1
  # {{PROJECT_NAME}}
2
2
 
3
- A Motia project created with the **multi-language** starter template (TypeScript + Python).
3
+ This is a **Motia** project bootstrapped with the Motia CLI.
4
4
 
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
8
-
9
- ## Polyglot Architecture
10
-
11
- This template demonstrates Motia's polyglot capabilities by combining:
12
-
13
- - **TypeScript**: API endpoint (`hello-api.step.ts`) - handles HTTP requests
14
- - **Python**: Event processor (`process_greeting_step.py`) - handles background processing
15
- - **JavaScript**: Logger (`log-greeting.step.js`) - handles workflow completion
16
-
17
- This shows how you can use the best language for each task while keeping everything in a single unified system.
5
+ Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
18
6
 
19
7
  ## Quick Start
20
8
 
@@ -27,80 +15,19 @@ yarn dev
27
15
  pnpm dev
28
16
  ```
29
17
 
30
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
31
-
32
- ```bash
33
- # Test your first endpoint
34
- curl http://localhost:3000/hello
35
- ```
36
-
37
- ## How It Works
38
-
39
- 1. **TypeScript API Step** receives the HTTP request at `/hello`
40
- 2. It emits a `process-greeting` event with the request data
41
- 3. **Python Event Step** picks up the event, processes it, and stores the result in state
42
- 4. Python emits a `greeting-processed` event
43
- 5. **JavaScript Event Step** logs the completed workflow
44
-
45
- ## Step Types
46
-
47
- Every Step has a `type` that defines how it triggers:
48
-
49
- | Type | When it runs | Use case |
50
- |------|--------------|----------|
51
- | **`api`** | HTTP request | REST APIs, webhooks |
52
- | **`event`** | Event emitted | Background jobs, workflows |
53
- | **`cron`** | Schedule | Cleanup, reports, reminders |
54
-
55
- ## Development Commands
56
-
57
- ```bash
58
- # Start Workbench and development server
59
- npm run dev
60
- # or
61
- yarn dev
62
- # or
63
- pnpm dev
64
-
65
- # Start production server (without hot reload)
66
- npm run start
67
- # or
68
- yarn start
69
- # or
70
- pnpm start
71
-
72
- # Generate TypeScript types from Step configs
73
- npm run generate-types
74
- # or
75
- yarn generate-types
76
- # or
77
- pnpm generate-types
18
+ This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
78
19
 
79
- # Build project for deployment
80
- npm run build
81
- # or
82
- yarn build
83
- # or
84
- pnpm build
85
- ```
20
+ You can start editing the project by making changes to `src/hello/hello-api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
86
21
 
87
- ## Project Structure
22
+ Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
88
23
 
89
- ```
90
- steps/ # Your Step definitions
91
- ├── hello/
92
- │ ├── hello-api.step.ts # TypeScript API endpoint
93
- │ ├── process_greeting_step.py # Python event processor
94
- │ └── log-greeting.step.js # JavaScript logger
95
- motia.config.ts # Motia configuration
96
- requirements.txt # Python dependencies
97
- ```
24
+ ## Project Config
98
25
 
99
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required.
26
+ The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
100
27
 
101
28
  ## Learn More
102
29
 
103
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
104
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
105
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
30
+ - [Docs](https://motia.dev/docs) - Complete guides and API reference
31
+ - [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
32
+ - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
106
33
  - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -0,0 +1,3 @@
1
+ # Motia automatically loads environment variables from .env files
2
+ APP_NAME="Motia App"
3
+ GREETING_PREFIX="Hello"
@@ -1,10 +1,8 @@
1
1
  # {{PROJECT_NAME}}
2
2
 
3
- A Motia project created with the starter template.
3
+ This is a **Motia** project bootstrapped with the Motia CLI.
4
4
 
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
5
+ Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
8
6
 
9
7
  ## Quick Start
10
8
 
@@ -17,68 +15,19 @@ yarn dev
17
15
  pnpm dev
18
16
  ```
19
17
 
20
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
21
-
22
- ```bash
23
- # Test your first endpoint
24
- curl http://localhost:3000/hello
25
- ```
26
-
27
- ## Step Types
28
-
29
- Every Step has a `type` that defines how it triggers:
30
-
31
- | Type | When it runs | Use case |
32
- |------|--------------|----------|
33
- | **`api`** | HTTP request | REST APIs, webhooks |
34
- | **`event`** | Event emitted | Background jobs, workflows |
35
- | **`cron`** | Schedule | Cleanup, reports, reminders |
36
-
37
- ## Development Commands
38
-
39
- ```bash
40
- # Start Workbench and development server
41
- npm run dev
42
- # or
43
- yarn dev
44
- # or
45
- pnpm dev
46
-
47
- # Start production server (without hot reload)
48
- npm run start
49
- # or
50
- yarn start
51
- # or
52
- pnpm start
18
+ This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
53
19
 
54
- # Generate TypeScript types from Step configs
55
- npm run generate-types
56
- # or
57
- yarn generate-types
58
- # or
59
- pnpm generate-types
20
+ You can start editing the project by making changes to `src/hello/hello_api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
60
21
 
61
- # Build project for deployment
62
- npm run build
63
- # or
64
- yarn build
65
- # or
66
- pnpm build
67
- ```
22
+ Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
68
23
 
69
- ## Project Structure
70
-
71
- ```
72
- steps/ # Your Step definitions (or use src/)
73
- motia.config.ts # Motia configuration
74
- requirements.txt # Python dependencies
75
- ```
24
+ ## Project Config
76
25
 
77
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required. You can write Steps in Python, TypeScript, or JavaScript, all in the same project.
26
+ The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
78
27
 
79
28
  ## Learn More
80
29
 
81
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
82
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
83
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
30
+ - [Docs](https://motia.dev/docs) - Complete guides and API reference
31
+ - [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
32
+ - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
84
33
  - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -0,0 +1,3 @@
1
+ # Motia automatically loads environment variables from .env files
2
+ API_URL="https://xnigaj-xtnawg.motiahub.com"
3
+ SAMPLE_EMAIL="test@test.com"
@@ -1,10 +1,8 @@
1
1
  # {{PROJECT_NAME}}
2
2
 
3
- A Motia tutorial project in TypeScript.
3
+ This is a **Motia** project bootstrapped with the Motia CLI.
4
4
 
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
5
+ Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
8
6
 
9
7
  ## Quick Start
10
8
 
@@ -17,76 +15,19 @@ yarn dev
17
15
  pnpm dev
18
16
  ```
19
17
 
20
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
21
-
22
- 1. **Open the Workbench** in your browser at [`http://localhost:3000`](http://localhost:3000)
23
- 2. **Click the `Tutorial`** button on the top right of the workbench
24
- 3. **Complete the `Tutorial`** to get an understanding of the basics of Motia and using the Workbench
25
-
26
- ## Step Types
27
-
28
- Every Step has a `type` that defines how it triggers:
29
-
30
- | Type | When it runs | Use case |
31
- |------|--------------|----------|
32
- | **`api`** | HTTP request | REST APIs, webhooks |
33
- | **`event`** | Event emitted | Background jobs, workflows |
34
- | **`cron`** | Schedule | Cleanup, reports, reminders |
35
-
36
- ## Development Commands
37
-
38
- ```bash
39
- # Start Workbench and development server
40
- npm run dev
41
- # or
42
- yarn dev
43
- # or
44
- pnpm dev
45
-
46
- # Start production server (without hot reload)
47
- npm run start
48
- # or
49
- yarn start
50
- # or
51
- pnpm start
52
-
53
- # Generate TypeScript types from Step configs
54
- npm run generate-types
55
- # or
56
- yarn generate-types
57
- # or
58
- pnpm generate-types
59
-
60
- # Build project for deployment
61
- npm run build
62
- # or
63
- yarn build
64
- # or
65
- pnpm build
66
- ```
67
-
68
- ## Project Structure
18
+ This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
69
19
 
70
- ```
71
- steps/ # Your Step definitions (or use src/)
72
- src/ # Shared services and utilities
73
- motia.config.ts # Motia configuration
74
- ```
20
+ You can start editing the project by making changes to `src/petstore/api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
75
21
 
76
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required.
22
+ Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
77
23
 
78
- ## Tutorial
24
+ ## Project Config
79
25
 
80
- This project includes an interactive tutorial that will guide you through:
81
- - Understanding Steps and their types
82
- - Creating API endpoints
83
- - Building event-driven workflows
84
- - Using state management
85
- - Observing your flows in the Workbench
26
+ The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
86
27
 
87
28
  ## Learn More
88
29
 
89
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
90
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
91
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
30
+ - [Docs](https://motia.dev/docs) - Complete guides and API reference
31
+ - [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
32
+ - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
92
33
  - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -38,7 +38,7 @@ export const handler: Handlers['ApiTrigger'] = async (req, { logger, traceId, em
38
38
  topic: 'process-food-order',
39
39
  data: {
40
40
  quantity: foodOrder.quantity,
41
- email: 'test@test.com', // sample email
41
+ email: process.env.SAMPLE_EMAIL || 'test@test.com',
42
42
  petId: newPetRecord.id,
43
43
  },
44
44
  })
@@ -28,7 +28,7 @@ export const handler: Handlers['StateAuditJob'] = async ({ logger, state, emit }
28
28
  await emit({
29
29
  topic: 'notification',
30
30
  data: {
31
- email: 'test@test.com',
31
+ email: process.env.SAMPLE_EMAIL || 'test@test.com',
32
32
  templateId: 'order-audit-warning',
33
33
  templateData: {
34
34
  orderId: item.id,
@@ -1,8 +1,10 @@
1
1
  import type { Order, Pet } from './types'
2
2
 
3
+ const API_URL = process.env.API_URL || 'https://xnigaj-xtnawg.motiahub.com'
4
+
3
5
  export const petStoreService = {
4
6
  createPet: async (pet: Omit<Pet, 'id'>): Promise<Pet> => {
5
- const response = await fetch('https://xnigaj-xtnawg.motiahub.com/pet', {
7
+ const response = await fetch(`${API_URL}/pet`, {
6
8
  method: 'POST',
7
9
  body: JSON.stringify({
8
10
  name: pet?.name ?? '',
@@ -14,7 +16,7 @@ export const petStoreService = {
14
16
  return response.json()
15
17
  },
16
18
  createOrder: async (order: Omit<Order, 'id' | 'complete'>): Promise<Order> => {
17
- const response = await fetch('https://xnigaj-xtnawg.motiahub.com/store/order', {
19
+ const response = await fetch(`${API_URL}/store/order`, {
18
20
  method: 'POST',
19
21
  body: JSON.stringify({
20
22
  quantity: order?.quantity ?? 1,
@@ -0,0 +1,3 @@
1
+ # Motia automatically loads environment variables from .env files
2
+ API_URL="https://xnigaj-xtnawg.motiahub.com"
3
+ SAMPLE_EMAIL="test@test.com"
@@ -1,10 +1,8 @@
1
1
  # {{PROJECT_NAME}}
2
2
 
3
- A Motia tutorial project in Python.
3
+ This is a **Motia** project bootstrapped with the Motia CLI.
4
4
 
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
5
+ Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
8
6
 
9
7
  ## Quick Start
10
8
 
@@ -17,77 +15,19 @@ yarn dev
17
15
  pnpm dev
18
16
  ```
19
17
 
20
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
21
-
22
- 1. **Open the Workbench** in your browser at [`http://localhost:3000`](http://localhost:3000)
23
- 2. **Click the `Tutorial`** button on the top right of the workbench
24
- 3. **Complete the `Tutorial`** to get an understanding of the basics of Motia and using the Workbench
25
-
26
- ## Step Types
27
-
28
- Every Step has a `type` that defines how it triggers:
29
-
30
- | Type | When it runs | Use case |
31
- |------|--------------|----------|
32
- | **`api`** | HTTP request | REST APIs, webhooks |
33
- | **`event`** | Event emitted | Background jobs, workflows |
34
- | **`cron`** | Schedule | Cleanup, reports, reminders |
35
-
36
- ## Development Commands
37
-
38
- ```bash
39
- # Start Workbench and development server
40
- npm run dev
41
- # or
42
- yarn dev
43
- # or
44
- pnpm dev
45
-
46
- # Start production server (without hot reload)
47
- npm run start
48
- # or
49
- yarn start
50
- # or
51
- pnpm start
52
-
53
- # Generate TypeScript types from Step configs
54
- npm run generate-types
55
- # or
56
- yarn generate-types
57
- # or
58
- pnpm generate-types
59
-
60
- # Build project for deployment
61
- npm run build
62
- # or
63
- yarn build
64
- # or
65
- pnpm build
66
- ```
67
-
68
- ## Project Structure
18
+ This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
69
19
 
70
- ```
71
- steps/ # Your Step definitions (or use src/)
72
- src/ # Shared services and utilities
73
- motia.config.ts # Motia configuration
74
- requirements.txt # Python dependencies
75
- ```
20
+ You can start editing the project by making changes to `src/petstore/api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
76
21
 
77
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required. You can write Steps in Python, TypeScript, or JavaScript, all in the same project.
22
+ Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
78
23
 
79
- ## Tutorial
24
+ ## Project Config
80
25
 
81
- This project includes an interactive tutorial that will guide you through:
82
- - Understanding Steps and their types
83
- - Creating API endpoints
84
- - Building event-driven workflows
85
- - Using state management
86
- - Observing your flows in the Workbench
26
+ The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
87
27
 
88
28
  ## Learn More
89
29
 
90
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
91
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
92
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
30
+ - [Docs](https://motia.dev/docs) - Complete guides and API reference
31
+ - [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
32
+ - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
93
33
  - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from pydantic import BaseModel
2
3
  from typing import Optional
3
4
  from src.services.pet_store import pet_store_service
@@ -42,7 +43,7 @@ async def handler(req, context):
42
43
  "topic": "process-food-order",
43
44
  "data": {
44
45
  "quantity": food_order.get("quantity"),
45
- "email": "test@test.com", # sample email
46
+ "email": os.environ.get("SAMPLE_EMAIL", "test@test.com"),
46
47
  "pet_id": new_pet_record.get("id"),
47
48
  },
48
49
  })
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from datetime import datetime, timezone
2
3
 
3
4
  config = {
@@ -27,7 +28,7 @@ async def handler(context):
27
28
  await context.emit({
28
29
  "topic": "notification",
29
30
  "data": {
30
- "email": "test@test.com",
31
+ "email": os.environ.get("SAMPLE_EMAIL", "test@test.com"),
31
32
  "template_id": "order-audit-warning",
32
33
  "template_data": {
33
34
  "order_id": item.get("id"),
@@ -1,7 +1,10 @@
1
+ import os
1
2
  import httpx
2
3
  from typing import Dict, Any
3
4
  from .types import Order, Pet
4
5
 
6
+ api_url = os.environ.get("API_URL", "https://xnigaj-xtnawg.motiahub.com")
7
+
5
8
  class PetStoreService:
6
9
  async def create_pet(self, pet: Dict[str, Any]) -> Pet:
7
10
  pet_data = {
@@ -12,7 +15,7 @@ class PetStoreService:
12
15
 
13
16
  async with httpx.AsyncClient() as client:
14
17
  response = await client.post(
15
- 'https://xnigaj-xtnawg.motiahub.com/pet',
18
+ f"{api_url}/pet",
16
19
  json=pet_data,
17
20
  headers={'Content-Type': 'application/json'}
18
21
  )
@@ -28,7 +31,7 @@ class PetStoreService:
28
31
  }
29
32
 
30
33
  response = await client.post(
31
- 'https://xnigaj-xtnawg.motiahub.com/store/order',
34
+ f"{api_url}/store/order",
32
35
  json=order_data,
33
36
  headers={'Content-Type': 'application/json'}
34
37
  )
@@ -3,48 +3,48 @@
3
3
  "id": "step-configuration",
4
4
  "title": "Step Configuration",
5
5
  "description": "All steps should have a defined configuration, this is how you define the step's behavior and how it will be triggered.",
6
- "lines": ["6-29"]
6
+ "lines": ["7-30"]
7
7
  },
8
8
  {
9
9
  "id": "api-configuration",
10
10
  "title": "API Step",
11
11
  "description": "Definition of an API endpoint",
12
- "lines": ["18", "22-23"]
12
+ "lines": ["19", "23-24"]
13
13
  },
14
14
  {
15
15
  "id": "request-body",
16
16
  "title": "Request body",
17
17
  "description": "Definition of the expected request body. Motia will automatically generate types based on this schema.",
18
- "lines": ["6-15", "24"]
18
+ "lines": ["7-16", "25"]
19
19
  },
20
20
  {
21
21
  "id": "response-payload",
22
22
  "title": "Response Payload",
23
23
  "description": "Definition of the expected response payload, Motia will generate the types automatically based on this schema. This is also important to create the Open API spec later.",
24
- "lines": ["4", "25-27"]
24
+ "lines": ["5", "26-28"]
25
25
  },
26
26
  {
27
27
  "id": "event-driven-architecture",
28
28
  "title": "Emits",
29
29
  "description": "We can define the events that this step will emit, this is how we can trigger other Motia Steps.",
30
- "lines": ["28", "41-48"]
30
+ "lines": ["29", "42-49"]
31
31
  },
32
32
  {
33
33
  "id": "handler",
34
34
  "title": "Handler",
35
35
  "description": "The handler is the function that will be executed when the step is triggered. This one receives the request body and emits events.",
36
- "lines": ["31-50"]
36
+ "lines": ["32-51"]
37
37
  },
38
38
  {
39
39
  "id": "logger",
40
40
  "title": "Logger",
41
41
  "description": "The logger is a utility that allows you to log messages to the console. It is available in the handler function. We encourage you to use it instead of console.log. It will automatically be tied to the trace id of the request.",
42
- "lines": ["33"]
42
+ "lines": ["34"]
43
43
  },
44
44
  {
45
45
  "id": "http-response",
46
46
  "title": "HTTP Response",
47
47
  "description": "The handler can return a response to the client. This is how we can return a response to the client. It must comply with the responseSchema defined in the step configuration.",
48
- "lines": ["50"]
48
+ "lines": ["51"]
49
49
  }
50
50
  ]
@@ -3,24 +3,18 @@
3
3
  "id": "step-configuration",
4
4
  "title": "Step Configuration",
5
5
  "description": "All steps should have a defined configuration, this is how you define the step's behavior and how it will be triggered.",
6
- "lines": [
7
- "3-10"
8
- ]
6
+ "lines": ["4-11"]
9
7
  },
10
8
  {
11
9
  "id": "cron-configuration",
12
10
  "title": "Cron Configuration",
13
11
  "description": "Cron steps require a specific configuration structure with the 'type' field set to 'cron' and a valid cron expression.",
14
- "lines": [
15
- "4-5"
16
- ]
12
+ "lines": ["5-6"]
17
13
  },
18
14
  {
19
15
  "id": "handler",
20
16
  "title": "Cron Step Handler",
21
17
  "description": "The Cron step handler only receives one argument.",
22
- "lines": [
23
- "12-39"
24
- ]
18
+ "lines": ["13-40"]
25
19
  }
26
- ]
20
+ ]
@@ -86,7 +86,7 @@ Before writing ANY Motia code, you MUST read the relevant cursor rules from `.cu
86
86
  ## Key Principles
87
87
 
88
88
  - **All guides have TypeScript, JavaScript, and Python examples**
89
- - **Steps can live in `/src` or `/steps`** - Motia discovers both (use `/src` for modern structure)
89
+ - **Steps can live anywhere within `/src`** - Motia discovers them automatically
90
90
  - **Always export `config` and `handler`**
91
91
  - **List all emits in config before using them**
92
92
  - **Follow naming conventions**: `*.step.ts` (TS), `*.step.js` (JS), `*_step.py` (Python)
@@ -10,17 +10,13 @@ alwaysApply: true
10
10
 
11
11
  This guide covers the architecture and best practices for structuring Motia projects.
12
12
 
13
- **Key Takeaway**: Motia automatically discovers steps from anywhere in your project. Modern projects use `/src` for a familiar structure that works seamlessly with Domain-Driven Design.
13
+ **Key Takeaway**: Motia automatically discovers steps from anywhere in the `/src` folder. Modern projects use `/src` for a familiar structure that works seamlessly with Domain-Driven Design.
14
14
 
15
15
  ## File Structure
16
16
 
17
- Motia automatically discovers step files from your project. You can organize steps in either:
17
+ Motia automatically discovers step files from your project.
18
18
 
19
- - **`/src` folder** (recommended) - Familiar pattern for most developers
20
- - **`/steps` folder** - Traditional Motia pattern
21
- - Both folders simultaneously
22
-
23
- ### Recommended Structure (using `/src`)
19
+ ### Recommended Structure
24
20
 
25
21
  ```
26
22
  project/
@@ -39,24 +35,7 @@ project/
39
35
  └── motia.config.ts
40
36
  ```
41
37
 
42
- ### Alternative Structure (using `/steps`)
43
-
44
- ```
45
- project/
46
- ├── steps/
47
- │ ├── api/
48
- │ │ └── users.step.ts
49
- │ ├── events/
50
- │ │ └── order-processing.step.ts
51
- │ └── cron/
52
- │ └── cleanup.step.ts
53
- ├── src/
54
- │ ├── services/
55
- │ └── utils/
56
- └── motia.config.ts
57
- ```
58
-
59
- Create subfolders within your chosen directory to organize related steps into logical groups (domains, features, or flows).
38
+ Create subfolders within your `/src` directory to organize related steps into logical groups (domains, features, or flows).
60
39
 
61
40
  **Why `/src` is recommended:**
62
41
  - Familiar to developers from other frameworks (Next.js, NestJS, etc.)
@@ -109,7 +88,7 @@ Motia encourages Domain-Driven Design (DDD) principles for maintainable, scalabl
109
88
 
110
89
  ### Folder Structure for DDD
111
90
 
112
- When using `/src` for steps (recommended), your structure naturally supports DDD:
91
+ When using `/src` for steps, your structure naturally supports DDD:
113
92
 
114
93
  ```
115
94
  src/
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: How to create HTTP endpoints in Motia
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
4
4
  alwaysApply: false
5
5
  ---
6
6
  # API Steps Guide
@@ -9,7 +9,7 @@ API Steps expose HTTP endpoints that can trigger workflows and emit events.
9
9
 
10
10
  ## Creating API Steps
11
11
 
12
- Steps need to be created in the `steps` folder, it can be in subfolders.
12
+ Steps need to be created in the `src` folder, it can be in subfolders.
13
13
 
14
14
  - Steps in TS and JS should end with `.step.ts` and `.step.js` respectively.
15
15
  - Steps in Python should end with `_step.py`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Cron Steps are scheduled tasks that run based on cron expressions.
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
4
4
  alwaysApply: false
5
5
  ---
6
6
  # Cron Steps Guide
@@ -15,7 +15,7 @@ ultimately trigger an Event Step that will handle the logic.
15
15
 
16
16
  ## Creating Cron Steps
17
17
 
18
- Steps need to be created in the `steps` folder, it can be in subfolders.
18
+ Steps need to be created in the `src` folder, it can be in subfolders.
19
19
 
20
20
  - Steps in TS and JS should end with `.step.ts` and `.step.js` respectively
21
21
  - Steps in Python should end with `_step.py`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: How to create background tasks in Motia
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
4
4
  alwaysApply: false
5
5
  ---
6
6
  # Event Steps Guide
@@ -19,7 +19,7 @@ Other applicable examples are tasks that are likely to fail, examples:
19
19
 
20
20
  ## Creating Event Steps
21
21
 
22
- Steps need to be created in the `steps` folder, it can be in subfolders.
22
+ Steps need to be created in the `src` folder, it can be in subfolders.
23
23
 
24
24
  - Steps in TS and JS should end with `.step.ts` and `.step.js` respectively.
25
25
  - Steps in Python should end with `_step.py`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Middlewares are used to execute code before and after the handler is called
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py,middlewares/**/*.middleware.ts,middlewares/**/*.middleware.js,middlewares/**/*_middleware.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py,middlewares/**/*.middleware.ts,middlewares/**/*.middleware.js,middlewares/**/*_middleware.py
4
4
  alwaysApply: false
5
5
  ---
6
6
  # Middlewares Guide
@@ -196,7 +196,7 @@ export default config({
196
196
  **Project structure:**
197
197
  ```
198
198
  project/
199
- ├── src/ # Steps can be in /src or /steps
199
+ ├── src/ # Steps can be placed anywhere within /src
200
200
  │ └── api/
201
201
  │ └── example.step.ts
202
202
  ├── plugins/
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Real-time streaming
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py,steps/**/*.stream.ts,steps/**/*.stream.js,steps/**/*_stream.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py,src/**/*.stream.ts,src/**/*.stream.js,src/**/*_stream.py
4
4
  alwaysApply: false
5
5
  ---
6
6
  # Real-time Streaming
@@ -56,7 +56,7 @@ export interface StreamConfig {
56
56
  ### TypeScript Example
57
57
 
58
58
  ```typescript
59
- // steps/streams/chat-messages.stream.ts
59
+ // src/streams/chat-messages.stream.ts
60
60
  import { StreamConfig } from 'motia'
61
61
  import { z } from 'zod'
62
62
 
@@ -81,7 +81,7 @@ export const config: StreamConfig = {
81
81
  #### With Pydantic (Optional)
82
82
 
83
83
  ```python
84
- # steps/streams/chat_messages_stream.py
84
+ # src/streams/chat_messages_stream.py
85
85
  from pydantic import BaseModel
86
86
 
87
87
  class ChatMessage(BaseModel):
@@ -100,7 +100,7 @@ config = {
100
100
  #### Without Pydantic (Pure JSON Schema)
101
101
 
102
102
  ```python
103
- # steps/streams/chat_messages_stream.py
103
+ # src/streams/chat_messages_stream.py
104
104
 
105
105
  config = {
106
106
  "name": "chatMessage",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Managing state across Steps
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
4
4
  alwaysApply: false
5
5
  ---
6
6
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Overriding the UI of Steps in Motia
3
- globs: steps/**/*.step.tsx,steps/**/*.step.jsx,steps/**/*_step.tsx,steps/**/*_step.jsx
3
+ globs: src/**/*.step.tsx,src/**/*.step.jsx,src/**/*_step.tsx,src/**/*_step.jsx
4
4
  alwaysApply: true
5
5
  ---
6
6
 
@@ -15,7 +15,7 @@ With UI Steps, you can enhance the user experience by designing intuitive, conte
15
15
  To create a custom UI for a step, create a .tsx or .jsx file next to your step file with the same base name:
16
16
 
17
17
  ```
18
- steps/
18
+ src/
19
19
  └── myStep/
20
20
  ├── myStep.step.ts # Step definition
21
21
  └── myStep.step.tsx # Visual override
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Connecting nodes virtually and creating a smooth flow in Workbench
3
- globs: steps/**/*.step.ts,steps/**/*.step.js,steps/**/*_step.py
3
+ globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
4
4
  alwaysApply: false
5
5
  ---
6
6
 
@@ -15,7 +15,7 @@ or without NOOP Steps.
15
15
 
16
16
  ## Creating NOOP Steps
17
17
 
18
- Steps need to be created in the `steps` folder, it can be in subfolders.
18
+ Steps need to be created in the `src` folder, it can be in subfolders.
19
19
 
20
20
  - Steps in TS and JS should end with `.step.ts` and `.step.js` respectively.
21
21
  - Steps in Python should end with `_step.py`.
@@ -63,9 +63,9 @@ Architecture guides in `.cursor/architecture/`:
63
63
 
64
64
  ### Project Structure
65
65
 
66
- Motia discovers steps from both `/src` and `/steps` folders. Modern projects typically use `/src`:
66
+ Motia discovers steps from the `/src` folder:
67
67
 
68
- **Recommended Structure (using `/src`):**
68
+ **Recommended Structure:**
69
69
  ```
70
70
  project/
71
71
  ├── .cursor/rules/ # DETAILED GUIDES - Read these first!
@@ -88,19 +88,6 @@ project/
88
88
  └── types.d.ts # Auto-generated types
89
89
  ```
90
90
 
91
- **Alternative Structure (using `/steps`):**
92
- ```
93
- project/
94
- ├── steps/ # Step definitions
95
- │ ├── api/
96
- │ ├── events/
97
- │ └── cron/
98
- ├── src/
99
- │ ├── services/
100
- │ └── utils/
101
- └── motia.config.ts
102
- ```
103
-
104
91
  ### Step Naming Conventions
105
92
 
106
93
  **TypeScript/JavaScript:** `my-step.step.ts` (kebab-case)
@@ -48,7 +48,7 @@ All guides in `.cursor/rules/` with **TypeScript, JavaScript, and Python** examp
48
48
 
49
49
  See `AGENTS.md` in this directory for a quick overview and links to specific guides.
50
50
 
51
- **Important**: Motia discovers steps from both `/src` and `/steps` folders. Modern projects use `/src` for a familiar structure.
51
+ **Important**: Motia discovers steps from the `/src` folder.
52
52
 
53
53
  ## Key Commands
54
54
 
package/dist/install.mjs CHANGED
@@ -2,13 +2,13 @@ import { getStepFiles, getStreamFiles } from "./generate-locked-data.mjs";
2
2
  import { internalLogger } from "./utils/internal-logger.mjs";
3
3
  import { executeCommand } from "./utils/execute-command.mjs";
4
4
  import { getPythonCommand } from "./utils/python-version-utils.mjs";
5
- import { activatePythonVenv } from "./utils/activate-python-env.mjs";
5
+ import { activatePythonVenv, getSitePackagesPath } from "./utils/activate-python-env.mjs";
6
6
  import { getInstallCommand } from "./utils/validate-python-environment.mjs";
7
7
  import { ensureUvInstalled } from "./utils/ensure-uv.mjs";
8
8
  import { installLambdaPythonPackages } from "./utils/install-lambda-python-packages.mjs";
9
- import fs from "fs";
10
- import path from "path";
11
9
  import pc from "picocolors";
10
+ import fs from "node:fs";
11
+ import path from "node:path";
12
12
 
13
13
  //#region src/install.ts
14
14
  const pythonInstall = async ({ baseDir, isVerbose = false, pythonVersion = "3.13" }) => {
@@ -22,9 +22,21 @@ const pythonInstall = async ({ baseDir, isVerbose = false, pythonVersion = "3.13
22
22
  try {
23
23
  const pythonCmd = await getPythonCommand(pythonVersion, baseDir);
24
24
  if (isVerbose) console.log(`🐍 Using Python command: ${pythonCmd}`);
25
- if (!fs.existsSync(venvPath)) {
26
- console.log("📦 Creating Python virtual environment...");
27
- await executeCommand(`${pythonCmd} -m venv python_modules`, baseDir);
25
+ if (fs.existsSync(venvPath)) fs.rmSync(venvPath, {
26
+ recursive: true,
27
+ force: true
28
+ });
29
+ console.log("📦 Creating Python virtual environment...");
30
+ await executeCommand(`${pythonCmd} -m venv python_modules`, baseDir);
31
+ const sitePackagesPath = getSitePackagesPath({
32
+ baseDir,
33
+ pythonVersion
34
+ });
35
+ if (!sitePackagesPath || !fs.existsSync(sitePackagesPath)) {
36
+ const installCmd = getInstallCommand(baseDir);
37
+ internalLogger.error("Python virtual environment was not created");
38
+ internalLogger.info(`Please try running ${pc.cyan(installCmd)} or manually create the venv with: ${pc.cyan("python3 -m venv python_modules")}`);
39
+ process.exit(1);
28
40
  }
29
41
  activatePythonVenv({
30
42
  baseDir,
@@ -43,13 +55,6 @@ const pythonInstall = async ({ baseDir, isVerbose = false, pythonVersion = "3.13
43
55
  if (isVerbose) console.log("📄 Using requirements from:", requirement);
44
56
  await executeCommand(`pip install -r "${requirement}" --only-binary=:all:`, baseDir);
45
57
  }
46
- const sitePackagesPath = process.env.PYTHON_SITE_PACKAGES;
47
- if (!sitePackagesPath || !fs.existsSync(sitePackagesPath)) {
48
- const installCmd = getInstallCommand(baseDir);
49
- internalLogger.error("Python virtual environment was not created");
50
- internalLogger.info(`Please try running ${pc.cyan(installCmd)} or manually create the venv with: ${pc.cyan("python3 -m venv python_modules")}`);
51
- process.exit(1);
52
- }
53
58
  } catch (error) {
54
59
  const errorMessage = error instanceof Error ? error.message : String(error);
55
60
  internalLogger.error("Installation failed:", errorMessage);
@@ -1 +1 @@
1
- {"version":3,"file":"install.mjs","names":[],"sources":["../src/install.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport pc from 'picocolors'\nimport { getStepFiles, getStreamFiles } from './generate-locked-data'\nimport { activatePythonVenv } from './utils/activate-python-env'\nimport { ensureUvInstalled } from './utils/ensure-uv'\nimport { executeCommand } from './utils/execute-command'\nimport { installLambdaPythonPackages } from './utils/install-lambda-python-packages'\nimport { internalLogger } from './utils/internal-logger'\nimport { getPythonCommand } from './utils/python-version-utils'\nimport { getInstallCommand } from './utils/validate-python-environment'\n\ninterface InstallConfig {\n isVerbose?: boolean\n pythonVersion?: string\n}\n\ntype PythonInstallConfig = InstallConfig & { baseDir: string }\n\nexport const pythonInstall = async ({\n baseDir,\n isVerbose = false,\n pythonVersion = '3.13',\n}: PythonInstallConfig): Promise<void> => {\n const venvPath = path.join(baseDir, 'python_modules')\n console.log('📦 Installing Python dependencies...', venvPath)\n\n const coreRequirementsPath = path.join(baseDir, 'node_modules', 'motia', 'dist', 'requirements-core.txt')\n const snapRequirementsPath = path.join(baseDir, 'node_modules', 'motia', 'dist', 'requirements-snap.txt')\n const localRequirements = path.join(baseDir, 'requirements.txt')\n\n const requirementsList = [coreRequirementsPath, snapRequirementsPath, localRequirements]\n\n try {\n // Get the appropriate Python command\n const pythonCmd = await getPythonCommand(pythonVersion, baseDir)\n if (isVerbose) {\n console.log(`🐍 Using Python command: ${pythonCmd}`)\n }\n\n // Check if virtual environment exists\n if (!fs.existsSync(venvPath)) {\n console.log('📦 Creating Python virtual environment...')\n await executeCommand(`${pythonCmd} -m venv python_modules`, baseDir)\n }\n\n activatePythonVenv({ baseDir, isVerbose, pythonVersion })\n\n // Ensure UV is installed\n console.log('🔧 Checking UV installation...')\n await ensureUvInstalled()\n console.log('✅ UV is available')\n\n installLambdaPythonPackages({ isVerbose, requirementsList })\n\n // Install requirements\n console.log('📥 Installing Python dependencies...')\n\n // Core requirements\n\n for (const requirement of requirementsList) {\n if (fs.existsSync(requirement)) {\n if (isVerbose) {\n console.log('📄 Using requirements from:', requirement)\n }\n await executeCommand(`pip install -r \"${requirement}\" --only-binary=:all:`, baseDir)\n }\n }\n\n const sitePackagesPath = process.env.PYTHON_SITE_PACKAGES\n\n if (!sitePackagesPath || !fs.existsSync(sitePackagesPath)) {\n const installCmd = getInstallCommand(baseDir)\n internalLogger.error('Python virtual environment was not created')\n internalLogger.info(\n `Please try running ${pc.cyan(installCmd)} or manually create the venv with: ${pc.cyan('python3 -m venv python_modules')}`,\n )\n process.exit(1)\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n internalLogger.error('Installation failed:', errorMessage)\n process.exit(1)\n }\n}\n\nexport const install = async ({ isVerbose = false, pythonVersion = '3.13' }: InstallConfig): Promise<void> => {\n const baseDir = process.cwd()\n\n const steps = getStepFiles(baseDir)\n const streams = getStreamFiles(baseDir)\n if (steps.some((file) => file.endsWith('.py')) || streams.some((file) => file.endsWith('.py'))) {\n await pythonInstall({ baseDir, isVerbose, pythonVersion })\n }\n\n console.info('✅ Installation completed successfully!')\n\n process.exit(0)\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,gBAAgB,OAAO,EAClC,SACA,YAAY,OACZ,gBAAgB,aACwB;CACxC,MAAM,WAAW,KAAK,KAAK,SAAS,iBAAiB;AACrD,SAAQ,IAAI,wCAAwC,SAAS;CAM7D,MAAM,mBAAmB;EAJI,KAAK,KAAK,SAAS,gBAAgB,SAAS,QAAQ,wBAAwB;EAC5E,KAAK,KAAK,SAAS,gBAAgB,SAAS,QAAQ,wBAAwB;EAC/E,KAAK,KAAK,SAAS,mBAAmB;EAEwB;AAExF,KAAI;EAEF,MAAM,YAAY,MAAM,iBAAiB,eAAe,QAAQ;AAChE,MAAI,UACF,SAAQ,IAAI,4BAA4B,YAAY;AAItD,MAAI,CAAC,GAAG,WAAW,SAAS,EAAE;AAC5B,WAAQ,IAAI,4CAA4C;AACxD,SAAM,eAAe,GAAG,UAAU,0BAA0B,QAAQ;;AAGtE,qBAAmB;GAAE;GAAS;GAAW;GAAe,CAAC;AAGzD,UAAQ,IAAI,iCAAiC;AAC7C,QAAM,mBAAmB;AACzB,UAAQ,IAAI,oBAAoB;AAEhC,8BAA4B;GAAE;GAAW;GAAkB,CAAC;AAG5D,UAAQ,IAAI,uCAAuC;AAInD,OAAK,MAAM,eAAe,iBACxB,KAAI,GAAG,WAAW,YAAY,EAAE;AAC9B,OAAI,UACF,SAAQ,IAAI,+BAA+B,YAAY;AAEzD,SAAM,eAAe,mBAAmB,YAAY,wBAAwB,QAAQ;;EAIxF,MAAM,mBAAmB,QAAQ,IAAI;AAErC,MAAI,CAAC,oBAAoB,CAAC,GAAG,WAAW,iBAAiB,EAAE;GACzD,MAAM,aAAa,kBAAkB,QAAQ;AAC7C,kBAAe,MAAM,6CAA6C;AAClE,kBAAe,KACb,sBAAsB,GAAG,KAAK,WAAW,CAAC,qCAAqC,GAAG,KAAK,iCAAiC,GACzH;AACD,WAAQ,KAAK,EAAE;;UAEV,OAAO;EACd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,iBAAe,MAAM,wBAAwB,aAAa;AAC1D,UAAQ,KAAK,EAAE;;;AAInB,MAAa,UAAU,OAAO,EAAE,YAAY,OAAO,gBAAgB,aAA2C;CAC5G,MAAM,UAAU,QAAQ,KAAK;CAE7B,MAAM,QAAQ,aAAa,QAAQ;CACnC,MAAM,UAAU,eAAe,QAAQ;AACvC,KAAI,MAAM,MAAM,SAAS,KAAK,SAAS,MAAM,CAAC,IAAI,QAAQ,MAAM,SAAS,KAAK,SAAS,MAAM,CAAC,CAC5F,OAAM,cAAc;EAAE;EAAS;EAAW;EAAe,CAAC;AAG5D,SAAQ,KAAK,yCAAyC;AAEtD,SAAQ,KAAK,EAAE"}
1
+ {"version":3,"file":"install.mjs","names":[],"sources":["../src/install.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport pc from 'picocolors'\nimport { getStepFiles, getStreamFiles } from './generate-locked-data'\nimport { activatePythonVenv, getSitePackagesPath } from './utils/activate-python-env'\nimport { ensureUvInstalled } from './utils/ensure-uv'\nimport { executeCommand } from './utils/execute-command'\nimport { installLambdaPythonPackages } from './utils/install-lambda-python-packages'\nimport { internalLogger } from './utils/internal-logger'\nimport { getPythonCommand } from './utils/python-version-utils'\nimport { getInstallCommand } from './utils/validate-python-environment'\n\ninterface InstallConfig {\n isVerbose?: boolean\n pythonVersion?: string\n}\n\ntype PythonInstallConfig = InstallConfig & { baseDir: string }\n\nexport const pythonInstall = async ({\n baseDir,\n isVerbose = false,\n pythonVersion = '3.13',\n}: PythonInstallConfig): Promise<void> => {\n const venvPath = path.join(baseDir, 'python_modules')\n console.log('📦 Installing Python dependencies...', venvPath)\n\n const coreRequirementsPath = path.join(baseDir, 'node_modules', 'motia', 'dist', 'requirements-core.txt')\n const snapRequirementsPath = path.join(baseDir, 'node_modules', 'motia', 'dist', 'requirements-snap.txt')\n const localRequirements = path.join(baseDir, 'requirements.txt')\n\n const requirementsList = [coreRequirementsPath, snapRequirementsPath, localRequirements]\n\n try {\n // Get the appropriate Python command\n const pythonCmd = await getPythonCommand(pythonVersion, baseDir)\n if (isVerbose) {\n console.log(`🐍 Using Python command: ${pythonCmd}`)\n }\n\n // Check if virtual environment exists\n if (fs.existsSync(venvPath)) {\n fs.rmSync(venvPath, { recursive: true, force: true })\n }\n\n console.log('📦 Creating Python virtual environment...')\n await executeCommand(`${pythonCmd} -m venv python_modules`, baseDir)\n\n const sitePackagesPath = getSitePackagesPath({ baseDir, pythonVersion })\n\n if (!sitePackagesPath || !fs.existsSync(sitePackagesPath)) {\n const installCmd = getInstallCommand(baseDir)\n internalLogger.error('Python virtual environment was not created')\n internalLogger.info(\n `Please try running ${pc.cyan(installCmd)} or manually create the venv with: ${pc.cyan('python3 -m venv python_modules')}`,\n )\n process.exit(1)\n }\n\n activatePythonVenv({ baseDir, isVerbose, pythonVersion })\n\n // Ensure UV is installed\n console.log('🔧 Checking UV installation...')\n await ensureUvInstalled()\n console.log('✅ UV is available')\n\n installLambdaPythonPackages({ isVerbose, requirementsList })\n\n // Install requirements\n console.log('📥 Installing Python dependencies...')\n\n // Core requirements\n\n for (const requirement of requirementsList) {\n if (fs.existsSync(requirement)) {\n if (isVerbose) {\n console.log('📄 Using requirements from:', requirement)\n }\n await executeCommand(`pip install -r \"${requirement}\" --only-binary=:all:`, baseDir)\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n internalLogger.error('Installation failed:', errorMessage)\n process.exit(1)\n }\n}\n\nexport const install = async ({ isVerbose = false, pythonVersion = '3.13' }: InstallConfig): Promise<void> => {\n const baseDir = process.cwd()\n\n const steps = getStepFiles(baseDir)\n const streams = getStreamFiles(baseDir)\n if (steps.some((file) => file.endsWith('.py')) || streams.some((file) => file.endsWith('.py'))) {\n await pythonInstall({ baseDir, isVerbose, pythonVersion })\n }\n\n console.info('✅ Installation completed successfully!')\n\n process.exit(0)\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,gBAAgB,OAAO,EAClC,SACA,YAAY,OACZ,gBAAgB,aACwB;CACxC,MAAM,WAAW,KAAK,KAAK,SAAS,iBAAiB;AACrD,SAAQ,IAAI,wCAAwC,SAAS;CAM7D,MAAM,mBAAmB;EAJI,KAAK,KAAK,SAAS,gBAAgB,SAAS,QAAQ,wBAAwB;EAC5E,KAAK,KAAK,SAAS,gBAAgB,SAAS,QAAQ,wBAAwB;EAC/E,KAAK,KAAK,SAAS,mBAAmB;EAEwB;AAExF,KAAI;EAEF,MAAM,YAAY,MAAM,iBAAiB,eAAe,QAAQ;AAChE,MAAI,UACF,SAAQ,IAAI,4BAA4B,YAAY;AAItD,MAAI,GAAG,WAAW,SAAS,CACzB,IAAG,OAAO,UAAU;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;AAGvD,UAAQ,IAAI,4CAA4C;AACxD,QAAM,eAAe,GAAG,UAAU,0BAA0B,QAAQ;EAEpE,MAAM,mBAAmB,oBAAoB;GAAE;GAAS;GAAe,CAAC;AAExE,MAAI,CAAC,oBAAoB,CAAC,GAAG,WAAW,iBAAiB,EAAE;GACzD,MAAM,aAAa,kBAAkB,QAAQ;AAC7C,kBAAe,MAAM,6CAA6C;AAClE,kBAAe,KACb,sBAAsB,GAAG,KAAK,WAAW,CAAC,qCAAqC,GAAG,KAAK,iCAAiC,GACzH;AACD,WAAQ,KAAK,EAAE;;AAGjB,qBAAmB;GAAE;GAAS;GAAW;GAAe,CAAC;AAGzD,UAAQ,IAAI,iCAAiC;AAC7C,QAAM,mBAAmB;AACzB,UAAQ,IAAI,oBAAoB;AAEhC,8BAA4B;GAAE;GAAW;GAAkB,CAAC;AAG5D,UAAQ,IAAI,uCAAuC;AAInD,OAAK,MAAM,eAAe,iBACxB,KAAI,GAAG,WAAW,YAAY,EAAE;AAC9B,OAAI,UACF,SAAQ,IAAI,+BAA+B,YAAY;AAEzD,SAAM,eAAe,mBAAmB,YAAY,wBAAwB,QAAQ;;UAGjF,OAAO;EACd,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAC3E,iBAAe,MAAM,wBAAwB,aAAa;AAC1D,UAAQ,KAAK,EAAE;;;AAInB,MAAa,UAAU,OAAO,EAAE,YAAY,OAAO,gBAAgB,aAA2C;CAC5G,MAAM,UAAU,QAAQ,KAAK;CAE7B,MAAM,QAAQ,aAAa,QAAQ;CACnC,MAAM,UAAU,eAAe,QAAQ;AACvC,KAAI,MAAM,MAAM,SAAS,KAAK,SAAS,MAAM,CAAC,IAAI,QAAQ,MAAM,SAAS,KAAK,SAAS,MAAM,CAAC,CAC5F,OAAM,cAAc;EAAE;EAAS;EAAW;EAAe,CAAC;AAG5D,SAAQ,KAAK,yCAAyC;AAEtD,SAAQ,KAAK,EAAE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "motia",
3
3
  "description": "Build production-grade backends with a single primitive. APIs, background jobs, Queues, Workflows, and AI agents - unified in one system with built-in State management, Streaming, and Observability.",
4
- "version": "0.17.11-beta.193",
4
+ "version": "0.17.12-beta.194",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
7
7
  "repository": {
@@ -46,13 +46,13 @@
46
46
  "table": "^6.9.0",
47
47
  "ts-node": "^10.9.2",
48
48
  "zod": "^4.1.13",
49
- "@motiadev/adapter-bullmq-events": "0.17.11-beta.193",
50
- "@motiadev/adapter-redis-streams": "0.17.11-beta.193",
51
- "@motiadev/adapter-redis-cron": "0.17.11-beta.193",
52
- "@motiadev/adapter-redis-state": "0.17.11-beta.193",
53
- "@motiadev/core": "0.17.11-beta.193",
54
- "@motiadev/stream-client-node": "0.17.11-beta.193",
55
- "@motiadev/workbench": "0.17.11-beta.193"
49
+ "@motiadev/adapter-redis-cron": "0.17.12-beta.194",
50
+ "@motiadev/adapter-bullmq-events": "0.17.12-beta.194",
51
+ "@motiadev/adapter-redis-streams": "0.17.12-beta.194",
52
+ "@motiadev/adapter-redis-state": "0.17.12-beta.194",
53
+ "@motiadev/stream-client-node": "0.17.12-beta.194",
54
+ "@motiadev/workbench": "0.17.12-beta.194",
55
+ "@motiadev/core": "0.17.12-beta.194"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@amplitude/analytics-types": "^2.9.2",