@ha-bits/cortex 1.1.0 → 1.1.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 +64 -27
- package/pack/index.cjs +2275 -2151
- package/package.json +1 -1
- package/ui/package.json +0 -22
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ha-bits/cortex
|
|
2
2
|
|
|
3
|
-
Cortex - Habits Workflow Executor CLI
|
|
3
|
+
Cortex - Habits Workflow Executor Server and CLI
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -12,61 +12,98 @@ npx @ha-bits/cortex
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
Run the CLI:
|
|
16
|
-
|
|
17
15
|
```bash
|
|
18
|
-
cortex
|
|
16
|
+
npx cortex <command> [options]
|
|
19
17
|
# or
|
|
20
|
-
npx @ha-bits/cortex
|
|
18
|
+
npx @ha-bits/cortex <command> [options]
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
###
|
|
21
|
+
### Commands
|
|
22
|
+
|
|
23
|
+
#### Start Server
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Start the workflow execution server:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
|
|
28
|
+
npx cortex server --config ./stack.yaml
|
|
29
|
+
npx cortex server -c ./config.json -p 8080
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
Options:
|
|
33
|
+
- `--config, -c` - Path to config file (looks for config.json in cwd if not specified)
|
|
34
|
+
- `--port, -p` - Server port (priority: args > config.json > .env > 3000)
|
|
35
|
+
- `--host, -h` - Server host (default: 0.0.0.0)
|
|
36
|
+
|
|
37
|
+
#### Execute Workflow
|
|
38
|
+
|
|
39
|
+
Execute a workflow directly without starting a server:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Execute from workflow file
|
|
43
|
+
cortex execute ./workflow.json
|
|
44
|
+
|
|
45
|
+
# Execute by ID from config
|
|
46
|
+
cortex execute --config ./stack.yaml --id my-workflow
|
|
47
|
+
|
|
48
|
+
# Execute all workflows
|
|
49
|
+
cortex execute --config ./stack.yaml --all
|
|
32
50
|
|
|
33
|
-
|
|
51
|
+
# Execute with input data
|
|
52
|
+
cortex execute --config ./stack.yaml --id my-workflow --input '{"prompt": "Hello"}'
|
|
53
|
+
```
|
|
34
54
|
|
|
35
|
-
|
|
36
|
-
- `--config` - Specify a config file path
|
|
55
|
+
#### Convert Workflow
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
Convert n8n, Activepieces, or Script workflows to Habits format:
|
|
39
58
|
|
|
40
59
|
```bash
|
|
41
|
-
|
|
42
|
-
cortex
|
|
60
|
+
cortex convert --input ./n8n-workflow.json --output ./habits.yaml
|
|
61
|
+
cortex convert -i ./workflow.json -o ./habits.yaml --env # Generate .env template
|
|
62
|
+
```
|
|
43
63
|
|
|
44
|
-
|
|
45
|
-
|
|
64
|
+
### Local Development
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm nx dev @ha-bits/cortex --config examples/mixed/stack.yaml
|
|
46
68
|
```
|
|
47
69
|
|
|
48
|
-
##
|
|
70
|
+
## API Endpoints
|
|
49
71
|
|
|
50
|
-
|
|
72
|
+
### Workflow Management
|
|
73
|
+
- `GET /misc/workflows` - List all loaded workflows
|
|
74
|
+
- `GET /misc/workflow/:workflowId` - Get workflow details
|
|
75
|
+
|
|
76
|
+
### Workflow Execution
|
|
77
|
+
- `POST /api/:workflowId` - Execute a workflow
|
|
78
|
+
- Query params: `?stream=true` for streaming response (NDJSON)
|
|
79
|
+
- `GET /misc/execution/:id` - Get execution status
|
|
80
|
+
- `GET /misc/executions` - List all executions
|
|
81
|
+
- `DELETE /misc/execution/:id` - Cancel execution
|
|
82
|
+
|
|
83
|
+
### Webhooks
|
|
84
|
+
- `GET /webhook/health` - Webhook subsystem health
|
|
85
|
+
- `GET /webhook/list` - List registered webhook endpoints
|
|
86
|
+
- `ALL /webhook/:workflowId/:nodeId` - Webhook trigger endpoints
|
|
87
|
+
|
|
88
|
+
### Health
|
|
89
|
+
- `GET /health` - Server health check
|
|
90
|
+
- `GET /misc/health` - Alternative health endpoint
|
|
51
91
|
|
|
52
92
|
## Technical Notes
|
|
53
93
|
|
|
54
94
|
### Dynamic Module Loading
|
|
55
95
|
|
|
56
|
-
Cortex uses `createRequire` from Node.js's `module` API instead of
|
|
96
|
+
Cortex uses `createRequire` from Node.js's `module` API instead of standard `require()` for loading modules at runtime. This is necessary because:
|
|
57
97
|
|
|
58
|
-
1. **Bundler Compatibility**: When
|
|
98
|
+
1. **Bundler Compatibility**: When bundled with esbuild/webpack/ncc, the bundler transforms `require()` calls and creates a static context that can't resolve runtime paths.
|
|
59
99
|
|
|
60
|
-
2. **Dynamic Path Resolution**:
|
|
100
|
+
2. **Dynamic Path Resolution**: Modules are downloaded to `/tmp/habits-nodes/` (or `HABITS_NODES_PATH`) at runtime, and their paths aren't known at build time.
|
|
61
101
|
|
|
62
|
-
3. **Production Environment**: In production
|
|
102
|
+
3. **Production Environment**: In bundled production code, regular `require()` would throw "Cannot find module" errors.
|
|
63
103
|
|
|
64
104
|
```typescript
|
|
65
105
|
// Instead of: require(dynamicPath) // ❌ Fails in bundled code
|
|
66
|
-
//
|
|
67
|
-
customRequire(__filename, dynamicPath)
|
|
68
|
-
|
|
69
|
-
//OR
|
|
106
|
+
// Use:
|
|
70
107
|
import { createRequire } from 'module';
|
|
71
108
|
const dynamicRequire = createRequire(__filename);
|
|
72
109
|
const loadedModule = dynamicRequire(dynamicPath); // ✅ Works in bundled code
|