@ha-bits/cortex
v1.0.6
Published
Cortex - Habits Workflow Executor CLI
Maintainers
Readme
@ha-bits/cortex
Cortex - Habits Workflow Executor CLI
Installation
npm install -g @ha-bits/cortex
# or
npx @ha-bits/cortexUsage
Run the CLI:
cortex [command] [options]
# or
npx @ha-bits/cortex [command] [options]Available Commands
server- Start the Cortex server--config- Specify a config file path
Example
# Start server with config
cortex server --config ./config.json
# Or with npx
npx @ha-bits/cortex server --config ./config.jsonConfiguration
The CLI requires a configuration file. See the documentation for configuration options.
Technical Notes
Dynamic Module Loading
Cortex uses createRequire from Node.js's module API instead of the standard require() for loading modules at runtime. This is necessary because:
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.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. UsingcreateRequire(__filename)creates a fresh require function that bypasses the bundler's static analysis.Production Environment: In production (
/app/dist/pack/index.cjs), the bundled code would throw "Cannot find module" errors with regularrequire()because webpack'swebpackEmptyContextcan't resolve dynamic paths.
// Instead of: require(dynamicPath) // ❌ Fails in bundled code
// We use:
import { createRequire } from 'module';
const dynamicRequire = createRequire(__filename);
const loadedModule = dynamicRequire(dynamicPath); // ✅ Works in bundled codeLicense
Apache-2.0
Repository
https://github.com/codenteam/habits
