@lhi/n8m 0.1.0
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/LICENSE +21 -0
- package/README.md +247 -0
- package/bin/dev.js +5 -0
- package/bin/run.js +6 -0
- package/dist/agentic/checkpointer.d.ts +2 -0
- package/dist/agentic/checkpointer.js +14 -0
- package/dist/agentic/graph.d.ts +483 -0
- package/dist/agentic/graph.js +100 -0
- package/dist/agentic/nodes/architect.d.ts +6 -0
- package/dist/agentic/nodes/architect.js +51 -0
- package/dist/agentic/nodes/engineer.d.ts +11 -0
- package/dist/agentic/nodes/engineer.js +182 -0
- package/dist/agentic/nodes/qa.d.ts +5 -0
- package/dist/agentic/nodes/qa.js +151 -0
- package/dist/agentic/nodes/reviewer.d.ts +5 -0
- package/dist/agentic/nodes/reviewer.js +111 -0
- package/dist/agentic/nodes/supervisor.d.ts +6 -0
- package/dist/agentic/nodes/supervisor.js +18 -0
- package/dist/agentic/state.d.ts +51 -0
- package/dist/agentic/state.js +26 -0
- package/dist/commands/config.d.ts +13 -0
- package/dist/commands/config.js +47 -0
- package/dist/commands/create.d.ts +14 -0
- package/dist/commands/create.js +182 -0
- package/dist/commands/deploy.d.ts +13 -0
- package/dist/commands/deploy.js +68 -0
- package/dist/commands/modify.d.ts +13 -0
- package/dist/commands/modify.js +276 -0
- package/dist/commands/prune.d.ts +9 -0
- package/dist/commands/prune.js +98 -0
- package/dist/commands/resume.d.ts +8 -0
- package/dist/commands/resume.js +39 -0
- package/dist/commands/test.d.ts +27 -0
- package/dist/commands/test.js +619 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/ai.service.d.ts +51 -0
- package/dist/services/ai.service.js +421 -0
- package/dist/services/n8n.service.d.ts +17 -0
- package/dist/services/n8n.service.js +81 -0
- package/dist/services/node-definitions.service.d.ts +36 -0
- package/dist/services/node-definitions.service.js +102 -0
- package/dist/utils/config.d.ts +15 -0
- package/dist/utils/config.js +25 -0
- package/dist/utils/multilinePrompt.d.ts +1 -0
- package/dist/utils/multilinePrompt.js +52 -0
- package/dist/utils/n8nClient.d.ts +97 -0
- package/dist/utils/n8nClient.js +440 -0
- package/dist/utils/sandbox.d.ts +13 -0
- package/dist/utils/sandbox.js +34 -0
- package/dist/utils/theme.d.ts +23 -0
- package/dist/utils/theme.js +92 -0
- package/oclif.manifest.json +331 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lee Holdings International
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# n8m: The Agentic CLI for n8n
|
|
2
|
+
|
|
3
|
+
> Generate, modify, test, and deploy n8n workflows from the command line using AI.
|
|
4
|
+
|
|
5
|
+
[](https://typescriptlang.org/)
|
|
6
|
+
[](https://oclif.io/)
|
|
7
|
+
[](https://n8n.io)
|
|
8
|
+
|
|
9
|
+
**Stop clicking. Start shipping.** `n8m` is an open-source CLI that wraps your n8n instance with an agentic AI layer. Describe what you want in plain English — the agent designs, builds, validates, and deploys it.
|
|
10
|
+
|
|
11
|
+
No account. No server. Bring your own AI key and your n8n instance.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Option A: Run without installing (npx)
|
|
19
|
+
npx n8m <command>
|
|
20
|
+
|
|
21
|
+
# Option B: Install globally
|
|
22
|
+
npm install -g n8m
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Setup
|
|
26
|
+
|
|
27
|
+
### 1. Configure your AI provider
|
|
28
|
+
|
|
29
|
+
`n8m` stores credentials in `~/.n8m/config.json` so they persist across sessions — including `npx` invocations.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# OpenAI
|
|
33
|
+
npx n8m config --ai-provider openai --ai-key sk-...
|
|
34
|
+
|
|
35
|
+
# Anthropic (Claude)
|
|
36
|
+
npx n8m config --ai-provider anthropic --ai-key sk-ant-...
|
|
37
|
+
|
|
38
|
+
# Google Gemini
|
|
39
|
+
npx n8m config --ai-provider gemini --ai-key AIza...
|
|
40
|
+
|
|
41
|
+
# Any OpenAI-compatible API (Ollama, Groq, Together, LM Studio, etc.)
|
|
42
|
+
npx n8m config --ai-base-url http://localhost:11434/v1 --ai-key ollama --ai-model llama3
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You can also use environment variables or a `.env` file — env vars take priority over stored config:
|
|
46
|
+
|
|
47
|
+
| Variable | Description |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `AI_PROVIDER` | Preset: `openai`, `anthropic`, or `gemini` |
|
|
50
|
+
| `AI_API_KEY` | API key for your provider |
|
|
51
|
+
| `AI_MODEL` | Override the model (optional) |
|
|
52
|
+
| `AI_BASE_URL` | Custom base URL for any OpenAI-compatible API (optional) |
|
|
53
|
+
|
|
54
|
+
Default models per provider: `gpt-4o` · `claude-sonnet-4-6` · `gemini-2.5-flash`
|
|
55
|
+
|
|
56
|
+
### 2. Configure your n8n instance
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx n8m config --n8n-url https://your-n8n.example.com --n8n-key <your-n8n-api-key>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Credentials are saved locally to `~/.n8m/config.json`. You can also use environment variables `N8N_API_URL` and `N8N_API_KEY` instead.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
### `n8m create` — Generate a workflow
|
|
69
|
+
|
|
70
|
+
Describe what you want and the agentic pipeline designs, builds, and validates it.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
n8m create "Send a Slack message whenever a new row is added to a Google Sheet"
|
|
74
|
+
|
|
75
|
+
# Save to a specific file
|
|
76
|
+
n8m create "Daily weather summary email" --output ./workflows/weather.json
|
|
77
|
+
|
|
78
|
+
# Open a multiline editor for complex descriptions
|
|
79
|
+
n8m create --multiline
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The agent runs through three stages:
|
|
83
|
+
1. **Architect** — designs the blueprint and identifies required nodes
|
|
84
|
+
2. **Engineer** — generates the workflow JSON
|
|
85
|
+
3. **QA** — validates the result; loops back to Engineer if issues are found
|
|
86
|
+
|
|
87
|
+
The finished workflow is saved as a local JSON file (default: `./workflows/`).
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### `n8m modify` — Modify an existing workflow
|
|
92
|
+
|
|
93
|
+
Modify a local file or a live workflow on your instance using natural language.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Modify a local file
|
|
97
|
+
n8m modify ./workflows/slack-notifier.json "Add error handling to the HTTP node"
|
|
98
|
+
|
|
99
|
+
# Browse and select from local files + remote instance
|
|
100
|
+
n8m modify
|
|
101
|
+
|
|
102
|
+
# Multiline instructions
|
|
103
|
+
n8m modify --multiline
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
After modification you'll be prompted to save locally, deploy to your instance, or run a test.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### `n8m test` — Validate and auto-repair a workflow
|
|
111
|
+
|
|
112
|
+
Deploys a workflow ephemerally to your instance, validates it, and purges it when done. If validation fails, the repair loop kicks in automatically.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Test a local file
|
|
116
|
+
n8m test ./workflows/my-flow.json
|
|
117
|
+
|
|
118
|
+
# Browse and pick from local files + instance workflows
|
|
119
|
+
n8m test
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- Resolves and deploys sub-workflow dependencies automatically
|
|
123
|
+
- Patches node IDs after ephemeral deployment
|
|
124
|
+
- After a passing test, prompts to deploy or save the validated/repaired version
|
|
125
|
+
- All temporary assets are deleted on exit
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### `n8m deploy` — Push a workflow to n8n
|
|
130
|
+
|
|
131
|
+
Deploy a local workflow JSON directly to your n8n instance.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
n8m deploy ./workflows/my-flow.json
|
|
135
|
+
|
|
136
|
+
# Activate the workflow immediately after deployment
|
|
137
|
+
n8m deploy ./workflows/my-flow.json --activate
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### `n8m resume` — Resume a paused session
|
|
143
|
+
|
|
144
|
+
The agent can pause mid-run for human review (HITL). Resume it with its thread ID.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
n8m resume <thread-id>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Sessions are persisted to a local SQLite database, so they survive crashes and restarts.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### `n8m prune` — Clean up your instance
|
|
155
|
+
|
|
156
|
+
Removes duplicate workflows and leftover test artifacts (`[n8m:test:*]` prefixed names).
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Preview what would be deleted
|
|
160
|
+
n8m prune --dry-run
|
|
161
|
+
|
|
162
|
+
# Delete without confirmation
|
|
163
|
+
n8m prune --force
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### `n8m config` — Manage configuration
|
|
169
|
+
|
|
170
|
+
All credentials are saved to `~/.n8m/config.json` and persist across sessions (including `npx` invocations).
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Set AI provider
|
|
174
|
+
n8m config --ai-provider openai --ai-key sk-...
|
|
175
|
+
n8m config --ai-provider anthropic --ai-key sk-ant-...
|
|
176
|
+
n8m config --ai-provider gemini --ai-key AIza...
|
|
177
|
+
|
|
178
|
+
# Override model or set a custom OpenAI-compatible endpoint
|
|
179
|
+
n8m config --ai-model gpt-4o-mini
|
|
180
|
+
n8m config --ai-base-url http://localhost:11434/v1 --ai-key ollama --ai-model llama3
|
|
181
|
+
|
|
182
|
+
# Set n8n instance
|
|
183
|
+
n8m config --n8n-url https://your-n8n.example.com --n8n-key <key>
|
|
184
|
+
|
|
185
|
+
# Show current config
|
|
186
|
+
n8m config
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Architecture
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
Developer → n8m create "..."
|
|
195
|
+
│
|
|
196
|
+
▼
|
|
197
|
+
┌─────────────┐
|
|
198
|
+
│ Architect │ Designs the workflow blueprint
|
|
199
|
+
└──────┬──────┘
|
|
200
|
+
│
|
|
201
|
+
▼
|
|
202
|
+
┌─────────────┐
|
|
203
|
+
│ Engineer │◄──────────────┐
|
|
204
|
+
└──────┬──────┘ │ repair loop
|
|
205
|
+
│ │
|
|
206
|
+
▼ │
|
|
207
|
+
┌─────────────┐ ┌───────┴─────┐
|
|
208
|
+
│ QA │──────►│ (failed) │
|
|
209
|
+
└──────┬──────┘ └─────────────┘
|
|
210
|
+
│ passed
|
|
211
|
+
▼
|
|
212
|
+
./workflows/output.json
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- **Local first**: credentials and workflow files live on your machine
|
|
216
|
+
- **SQLite persistence**: session state survives interruptions
|
|
217
|
+
- **HITL pauses**: the agent stops for your review before committing
|
|
218
|
+
- **Bring your own AI**: works with OpenAI, Claude, Gemini, Ollama, or any OpenAI-compatible API
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Local Development
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
git clone https://github.com/lcanady/n8m.git
|
|
226
|
+
cd n8m
|
|
227
|
+
npm install
|
|
228
|
+
|
|
229
|
+
# Watch mode
|
|
230
|
+
npm run dev
|
|
231
|
+
|
|
232
|
+
# Run directly
|
|
233
|
+
./bin/run.js help
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Roadmap
|
|
239
|
+
|
|
240
|
+
- [x] Agentic graph (Architect → Engineer → QA)
|
|
241
|
+
- [x] SQLite session persistence
|
|
242
|
+
- [x] HITL interrupts and resume
|
|
243
|
+
- [x] Sub-workflow dependency resolution in tests
|
|
244
|
+
- [x] Open source — no account required
|
|
245
|
+
- [x] Multi-provider AI support (OpenAI, Claude, Gemini, Ollama, any OpenAI-compatible API)
|
|
246
|
+
- [ ] Native n8n canvas integration
|
|
247
|
+
- [ ] Multi-agent collaboration on a single goal
|
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SqliteSaver } from "@langchain/langgraph-checkpoint-sqlite";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import os from "os";
|
|
5
|
+
// Ensure the local storage directory exists
|
|
6
|
+
const HOME_DIR = os.homedir();
|
|
7
|
+
const CONFIG_DIR = path.join(HOME_DIR, ".n8m");
|
|
8
|
+
const DB_PATH = path.join(CONFIG_DIR, "state.db");
|
|
9
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
10
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
// Create a singleton checkpointer instance
|
|
13
|
+
// Using simple string path is supported by the library
|
|
14
|
+
export const checkpointer = SqliteSaver.fromConnString(DB_PATH);
|