@agentrix/cli 0.3.2

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 ADDED
@@ -0,0 +1,249 @@
1
+ # Agentrix CLI
2
+
3
+ A daemon-based CLI for managing AI agent workers (Claude Code and Codex) in isolated workspaces with git integration.
4
+
5
+ ## Overview
6
+
7
+ Agentrix CLI enables you to run AI agents (Claude or Codex) as background workers that operate in isolated workspaces. Each worker maintains its own git state and communicates with the Agentrix backend server via WebSocket.
8
+
9
+ ## Installation
10
+
11
+ ### Install from npm (Recommended)
12
+
13
+ ```bash
14
+ npm install -g @agentrix/cli
15
+ ```
16
+
17
+ Or with yarn:
18
+
19
+ ```bash
20
+ yarn global add @agentrix/cli
21
+ ```
22
+
23
+ ### Install from source
24
+
25
+ ```bash
26
+ git clone https://github.com/xmz-ai/agentrix-cli.git
27
+ cd agentrix-cli
28
+ yarn install
29
+ yarn build
30
+ ```
31
+
32
+ ## Upgrading
33
+
34
+ ### Automatic Update Check
35
+
36
+ When you run `agentrix start`, the CLI automatically checks for updates and notifies you if a newer version is available.
37
+
38
+ To disable automatic update checks, set the environment variable:
39
+
40
+ ```bash
41
+ export AGENTRIX_DISABLE_UPDATE_CHECK=true
42
+ ```
43
+
44
+ Or add it to your shell profile (`~/.bashrc`, `~/.zshrc`, etc.):
45
+
46
+ ```bash
47
+ echo 'export AGENTRIX_DISABLE_UPDATE_CHECK=true' >> ~/.zshrc
48
+ ```
49
+
50
+ ### Manual Upgrade Command
51
+
52
+ You can also trigger an upgrade manually at any time:
53
+
54
+ ```bash
55
+ agentrix upgrade
56
+ ```
57
+
58
+ This command will:
59
+ - Upgrade to the latest version using npm
60
+ - Automatically restart the daemon if it was running
61
+
62
+ ### Using npm Directly
63
+
64
+ You can also upgrade using npm directly:
65
+
66
+ ```bash
67
+ # Upgrade to latest version (fastest)
68
+ npm install -g @agentrix/cli@latest
69
+
70
+ # Check installed version
71
+ agentrix --version
72
+ ```
73
+
74
+ **Note**: After manual upgrade, restart the daemon:
75
+
76
+ ```bash
77
+ agentrix stop
78
+ agentrix start
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ ```bash
84
+ # Start the daemon
85
+ agentrix start
86
+
87
+ # Check status
88
+ agentrix status
89
+
90
+ # List active sessions
91
+ agentrix ls
92
+
93
+ # Stop a session
94
+ agentrix kill <sessionId>
95
+
96
+ # Stop the daemon
97
+ agentrix stop
98
+ ```
99
+
100
+ ## Commands
101
+
102
+ ### Core Commands
103
+
104
+ - `agentrix start` - Start the daemon (if not running) and show status
105
+ - `agentrix stop` - Stop the daemon
106
+ - `agentrix status` - Show daemon and authentication status
107
+ - `agentrix upgrade` - Upgrade CLI to the latest version (auto-restarts daemon)
108
+ - `agentrix ls` - List active worker sessions
109
+ - `agentrix kill <sessionId>` - Stop a specific worker session
110
+ - `agentrix killall` - Clean up all runaway agentrix processes
111
+ - `agentrix logout` - Logout from Agentrix
112
+
113
+ ### Diagnostic Commands
114
+
115
+ - `agentrix doctor` - Run system diagnostics
116
+
117
+ ## Architecture
118
+
119
+ ### Process Model
120
+
121
+ ```
122
+ CLI Entry (bin/agentrix.mjs)
123
+
124
+ Daemon Process (src/daemon/run.ts)
125
+
126
+ Worker Processes (src/worker/)
127
+ ├── ClaudeWorker
128
+ └── CodexWorker
129
+ ```
130
+
131
+ - **Daemon**: Long-running background service that manages worker sessions
132
+ - **Workers**: Isolated agent execution environments that run in separate processes
133
+ - **Communication**: Workers connect to backend via WebSocket for real-time interaction
134
+
135
+ ### Key Components
136
+
137
+ - **Machine** (`src/machine.ts`) - Manages machine identity, credentials, and state
138
+ - **Control Server** (`src/daemon/controlServer.ts`) - HTTP server for daemon management
139
+ - **TaskWorkerManager** (`src/daemon/sessions.ts`) - Manages worker process lifecycle
140
+ - **WorkerClient** (`src/worker/workerClient.ts`) - WebSocket client for backend communication
141
+ - **Git State Manager** (`src/worker/gitStateManager.ts`) - Handles git operations for workers
142
+
143
+ ## Configuration
144
+
145
+ ### Environment Variables
146
+
147
+ | Variable | Default | Description |
148
+ |----------|---------|-------------|
149
+ | `AGENTRIX_SERVER_URL` | `https://agentrix.xmz.ai` | Backend server URL |
150
+ | `AGENTRIX_WEBAPP_URL` | `https://agentrix.xmz.ai` | Web app URL |
151
+ | `AGENTRIX_HOME_DIR` | `~/.agentrix` | State directory |
152
+ | `AGENTRIX_WORKSPACE_HOME_DIR` | `~/.agentrix/workspaces` | Workspace directory |
153
+ | `AGENTRIX_AGENTS_HOME_DIR` | `~/.agentrix/agents` | Agent configs directory |
154
+ | `AGENTRIX_DISABLE_CAFFEINATE` | `false` | Disable sleep prevention |
155
+ | `AGENTRIX_DISABLE_UPDATE_CHECK` | `false` | Disable automatic update check on start |
156
+ | `DEBUG` | - | Enable debug logging |
157
+
158
+ ### State Files
159
+
160
+ All state is stored in `~/.agentrix/` (configurable via `AGENTRIX_HOME_DIR`):
161
+
162
+ - `credentials.json` - Authentication token and machine credentials
163
+ - `daemon.state.json` - Daemon PID, port, version info
164
+ - `daemon.state.json.lock` - Lock file for daemon process
165
+ - `machine.key` / `machine.key.pub` - Machine keypair for encryption
166
+ - `settings.json` - User settings
167
+ - `logs/` - Daemon and worker log files
168
+
169
+ ## Development
170
+
171
+ ### Build Commands
172
+
173
+ ```bash
174
+ # Type-check and build
175
+ yarn build
176
+
177
+ # Type-check only
178
+ yarn typecheck
179
+
180
+ # Run with development environment
181
+ yarn dev
182
+
183
+ # Run with production environment
184
+ yarn prod
185
+
186
+ # Run linter
187
+ yarn lint
188
+ ```
189
+
190
+ ### Testing
191
+
192
+ ```bash
193
+ # Run all tests
194
+ yarn test
195
+
196
+ # Run a single test file
197
+ yarn build && npx vitest run src/utils/hmac_sha512.test.ts
198
+ ```
199
+
200
+ **Note**: Tests require building first because daemon commands directly execute the binary.
201
+
202
+ ### Path Aliases
203
+
204
+ TypeScript path alias `@/*` maps to `src/*`.
205
+
206
+ ## Worker Types
207
+
208
+ ### ClaudeWorker
209
+ - Uses `@anthropic-ai/claude-agent-sdk`
210
+ - Supports all Claude Code capabilities
211
+ - Auto-commits changes on completion
212
+
213
+ ### CodexWorker
214
+ - Uses `@openai/codex-sdk`
215
+ - Supports special commands (merge-request)
216
+ - Auto-generates diffs and commits
217
+
218
+ Both workers:
219
+ - Setup workspace and handle git state on start
220
+ - Connect to backend via WebSocket
221
+ - Process user messages and stream responses
222
+ - Clean up git state on exit
223
+
224
+ ## Monorepo Structure
225
+
226
+ This CLI is part of the Agentrix monorepo:
227
+
228
+ ```
229
+ agentrix/
230
+ ├── api/ - Backend API server
231
+ ├── app/ - Frontend web/mobile app
232
+ ├── shared/ - Shared types and utilities
233
+ └── cli/ - This package
234
+ ```
235
+
236
+ Main development branch: `develop`
237
+
238
+ ## Dependencies
239
+
240
+ - `@anthropic-ai/claude-agent-sdk` - Claude agent integration
241
+ - `@openai/codex-sdk` - Codex agent integration
242
+ - `@agentrix/shared` - Shared types and utilities (monorepo sibling)
243
+ - `ws` - WebSocket client
244
+ - `yargs` - CLI framework
245
+ - `effect` - Functional programming utilities
246
+
247
+ ## License
248
+
249
+ [License information to be added]
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execFileSync } from 'child_process';
4
+ import { fileURLToPath } from 'url';
5
+ import { join, dirname } from 'path';
6
+
7
+ // Check if we're already running with the flags
8
+ const hasNoWarnings = process.execArgv.includes('--no-warnings');
9
+ const hasNoDeprecation = process.execArgv.includes('--no-deprecation');
10
+
11
+ if (!hasNoWarnings || !hasNoDeprecation) {
12
+ // Get path to the actual CLI entrypoint
13
+ const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
14
+ const entrypoint = join(projectRoot, 'dist', 'index.mjs');
15
+
16
+ // Execute the actual CLI directly with the correct flags
17
+ try {
18
+ execFileSync(process.execPath, [
19
+ '--no-warnings',
20
+ '--no-deprecation',
21
+ entrypoint,
22
+ ...process.argv.slice(2)
23
+ ], {
24
+ stdio: 'inherit',
25
+ env: process.env
26
+ });
27
+ } catch (error) {
28
+ // execFileSync throws if the process exits with non-zero
29
+ process.exit(error.status || 1);
30
+ }
31
+ } else {
32
+ // We're running Node with the flags we wanted, import the CLI entrypoint
33
+ // module to avoid creating a new process.
34
+ await import("../dist/index.mjs");
35
+ }