@ha-bits/cortex 1.0.6 → 1.1.7

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
@@ -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,48 +12,98 @@ npx @ha-bits/cortex
12
12
 
13
13
  ## Usage
14
14
 
15
- Run the CLI:
16
-
17
15
  ```bash
18
- cortex [command] [options]
16
+ npx cortex <command> [options]
19
17
  # or
20
- npx @ha-bits/cortex [command] [options]
18
+ npx @ha-bits/cortex <command> [options]
21
19
  ```
22
20
 
23
- ### Available Commands
21
+ ### Commands
22
+
23
+ #### Start Server
24
+
25
+ Start the workflow execution server:
26
+
27
+ ```bash
28
+ npx cortex server --config ./stack.yaml
29
+ npx cortex server -c ./config.json -p 8080
30
+ ```
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
50
+
51
+ # Execute with input data
52
+ cortex execute --config ./stack.yaml --id my-workflow --input '{"prompt": "Hello"}'
53
+ ```
24
54
 
25
- - `server` - Start the Cortex server
26
- - `--config` - Specify a config file path
55
+ #### Convert Workflow
27
56
 
28
- ### Example
57
+ Convert n8n, Activepieces, or Script workflows to Habits format:
29
58
 
30
59
  ```bash
31
- # Start server with config
32
- cortex server --config ./config.json
60
+ cortex convert --input ./n8n-workflow.json --output ./habits.yaml
61
+ cortex convert -i ./workflow.json -o ./habits.yaml --env # Generate .env template
62
+ ```
63
+
64
+ ### Local Development
33
65
 
34
- # Or with npx
35
- npx @ha-bits/cortex server --config ./config.json
66
+ ```bash
67
+ pnpm nx dev @ha-bits/cortex --config examples/mixed/stack.yaml
36
68
  ```
37
69
 
38
- ## Configuration
70
+ ## API Endpoints
71
+
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
39
82
 
40
- The CLI requires a configuration file. See the documentation for configuration options.
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
41
91
 
42
92
  ## Technical Notes
43
93
 
44
94
  ### Dynamic Module Loading
45
95
 
46
- Cortex uses `createRequire` from Node.js's `module` API instead of the standard `require()` for loading modules at runtime. This is necessary because:
96
+ Cortex uses `createRequire` from Node.js's `module` API instead of standard `require()` for loading modules at runtime. This is necessary because:
47
97
 
48
- 1. **Bundler Compatibility**: When the code is bundled with esbuild/webpack then ncc, the bundler transforms `require()` calls and creates a static context that can't resolve paths determined at runtime.
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.
49
99
 
50
- 2. **Dynamic Path Resolution**: Activepieces modules are downloaded to `/tmp/habits-nodes/` or wherever the env points to at runtime (HABITS_NODES_PATH) and their paths aren't known at build time. Using `createRequire(__filename)` creates a fresh require function that bypasses the bundler's static analysis.
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.
51
101
 
52
- 3. **Production Environment**: In production (`/app/dist/pack/index.cjs`), the bundled code would throw "Cannot find module" errors with regular `require()` because webpack's `webpackEmptyContext` can't resolve dynamic paths.
102
+ 3. **Production Environment**: In bundled production code, regular `require()` would throw "Cannot find module" errors.
53
103
 
54
104
  ```typescript
55
105
  // Instead of: require(dynamicPath) // ❌ Fails in bundled code
56
- // We use:
106
+ // Use:
57
107
  import { createRequire } from 'module';
58
108
  const dynamicRequire = createRequire(__filename);
59
109
  const loadedModule = dynamicRequire(dynamicPath); // ✅ Works in bundled code
@@ -66,3 +116,4 @@ Apache-2.0
66
116
  ## Repository
67
117
 
68
118
  https://github.com/codenteam/habits
119
+