@agiflowai/agent-cli 0.0.9 → 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/CHANGELOG.md +8 -0
- package/README.md +8 -347
- package/dist/claudeNotification.js +13653 -24
- package/dist/claudePermissionRequest.js +13675 -0
- package/dist/claudePostToolUse.js +13661 -17
- package/dist/claudePreToolUse.js +13773 -20
- package/dist/claudeSessionStart.js +13667 -17
- package/dist/claudeStop.js +13525 -0
- package/dist/cli.js +2298 -1
- package/dist/cli.js.map +1 -1
- package/dist/codex.md +386 -0
- package/dist/daemon.js +847 -0
- package/dist/daemon.js.map +1 -0
- package/dist/index-7uB_UKC1.mjs +31 -0
- package/dist/index-7uB_UKC1.mjs.map +1 -0
- package/dist/index-BQL-MgGG.mjs +122 -0
- package/dist/index-BQL-MgGG.mjs.map +1 -0
- package/dist/index-CVYu2Dkh.mjs +40977 -0
- package/dist/index-CVYu2Dkh.mjs.map +1 -0
- package/dist/index-DDi9orhQ.mjs +57 -0
- package/dist/index-DDi9orhQ.mjs.map +1 -0
- package/dist/index.js +319 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +20 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -5
- package/dist/AgentHttpService-Cz0DO3Zx.js +0 -28
- package/dist/AgentHttpService-Cz0DO3Zx.js.map +0 -1
- package/dist/cli-9RY_AMH5.js +0 -104
- package/dist/cli-9RY_AMH5.js.map +0 -1
- package/dist/networkLog.js +0 -435
- package/dist/networkLog.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
@agiflowai/agent-cli - Command-line interface for connecting and managing AI agents (Claude Code, Gemini) with Agiflow remotely.
|
|
8
8
|
|
|
9
|
-
**Note**:
|
|
10
|
-
- For `agent-cli claude` and `agent-cli router` you don't need to authenticate with Agiflow server.
|
|
11
|
-
- Use `agent-cli claude --standalone` to run Claude Code locally without any backend connection.
|
|
12
|
-
|
|
13
9
|
**🔗 Related Project**: Check out the [AgiFlow AI Code Toolkit](https://github.com/AgiFlow/aicode-toolkit) - an open-source collection of AI development tools and utilities.
|
|
14
10
|
|
|
15
11
|
## Quick Start
|
|
@@ -26,281 +22,16 @@ npm install @agiflowai/agent-cli
|
|
|
26
22
|
|
|
27
23
|
### Available Commands
|
|
28
24
|
|
|
29
|
-
The CLI provides
|
|
25
|
+
The CLI provides two main commands:
|
|
30
26
|
|
|
31
|
-
#### 1. `agent-cli
|
|
27
|
+
#### 1. `agent-cli daemon` - Connect Daemon
|
|
32
28
|
Connect your local machine to the Agiflow platform to receive remote commands.
|
|
33
29
|
|
|
34
30
|
```bash
|
|
35
|
-
|
|
36
|
-
agent-cli connect
|
|
37
|
-
|
|
38
|
-
# With custom server URL
|
|
39
|
-
agent-cli connect --server-url wss://your-server.com
|
|
40
|
-
|
|
41
|
-
# With verbose logging
|
|
42
|
-
agent-cli connect --verbose
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**Options:**
|
|
46
|
-
- `-u, --server-url <url>` - WebSocket server URL to connect to
|
|
47
|
-
- `--api-url <url>` - HTTP API base URL for daemon registration
|
|
48
|
-
- `-v, --verbose` - Enable verbose logging
|
|
49
|
-
- `--reconnect-interval <ms>` - Reconnection interval in milliseconds (default: 5000)
|
|
50
|
-
- `--unique-instance` - Create unique daemon instance
|
|
51
|
-
|
|
52
|
-
#### 2. `agent-cli claude` - Launch Claude Agent
|
|
53
|
-
Launch a Claude Code agent with full functionality.
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# Basic Claude agent launch in standalone mode (no backend)
|
|
57
|
-
agent-cli claude --standalone
|
|
58
|
-
|
|
59
|
-
# With backend connection (requires session ID)
|
|
60
|
-
agent-cli claude --agent-session-id your-session-id
|
|
61
|
-
|
|
62
|
-
# With custom alias for easy identification
|
|
63
|
-
agent-cli claude \
|
|
64
|
-
--agent-session-id your-session-id \
|
|
65
|
-
--alias "my-dev-session"
|
|
66
|
-
|
|
67
|
-
# With custom configuration
|
|
68
|
-
agent-cli claude \
|
|
69
|
-
--agent-session-id your-session-id \
|
|
70
|
-
--server-url wss://your-server.com \
|
|
71
|
-
--working-directory /path/to/project \
|
|
72
|
-
--verbose
|
|
73
|
-
|
|
74
|
-
# With LLM routing to GPT-5
|
|
75
|
-
agent-cli claude \
|
|
76
|
-
--llm-provider chatgpt \
|
|
77
|
-
--llm-model gpt-5 \
|
|
78
|
-
--alias "gpt5-experiment"
|
|
79
|
-
|
|
80
|
-
# Standalone mode (no backend connection)
|
|
81
|
-
agent-cli claude --standalone --verbose
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**Options:**
|
|
85
|
-
- `-s, --server-url <url>` - WebSocket server URL
|
|
86
|
-
- `-a, --api-url <url>` - HTTP API URL
|
|
87
|
-
- `-k, --api-key <key>` - API key for authentication
|
|
88
|
-
- `-o, --organization-id <id>` - Organization ID
|
|
89
|
-
- `-i, --agent-session-id <id>` - **Required** Agent session ID
|
|
90
|
-
- `-p, --claude-path <path>` - Path to Claude executable (default: 'claude')
|
|
91
|
-
- `-w, --working-directory <dir>` - Working directory (default: current directory)
|
|
92
|
-
- `-c, --agent-config <json>` - Agent configuration as JSON string
|
|
93
|
-
- `--args <args...>` - Additional arguments to pass to Claude
|
|
94
|
-
- `-v, --verbose` - Enable verbose logging
|
|
95
|
-
- `--alias <alias>` - Custom session alias for easy identification
|
|
96
|
-
- `--standalone` - Run in standalone mode without backend connection
|
|
97
|
-
|
|
98
|
-
**LLM Routing Options:**
|
|
99
|
-
- `--llm-provider <provider>` - LLM provider to route requests to (e.g., `chatgpt`, `openai`)
|
|
100
|
-
- `--llm-model <model>` - LLM model to use (e.g., `gpt-5`, `gpt-5-codex`)
|
|
101
|
-
|
|
102
|
-
**Note:** LLM routing configuration is saved to `~/.agiflow/sessions.json` and can be changed later using the `agent-cli router` command without restarting the agent.
|
|
103
|
-
|
|
104
|
-
##### Standalone Mode
|
|
105
|
-
|
|
106
|
-
Run Claude Code agent locally without connecting to the Agiflow backend server. This is useful for:
|
|
107
|
-
- Development and testing
|
|
108
|
-
- Running in environments without backend access
|
|
109
|
-
- Privacy-focused local-only usage
|
|
110
|
-
|
|
111
|
-
**Usage:**
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
# Explicit standalone mode
|
|
115
|
-
agent-cli claude --standalone
|
|
116
|
-
|
|
117
|
-
# Standalone mode with verbose logging
|
|
118
|
-
agent-cli claude --standalone --verbose
|
|
119
|
-
|
|
120
|
-
# Standalone mode with custom working directory
|
|
121
|
-
agent-cli claude --standalone --working-directory /path/to/project
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**How It Works:**
|
|
125
|
-
|
|
126
|
-
When `--standalone` is enabled:
|
|
127
|
-
- ✅ Claude Code launches normally with full functionality
|
|
128
|
-
- ✅ All local features work (file operations, code analysis, etc.)
|
|
129
|
-
- ❌ No WebSocket connection to Agiflow backend
|
|
130
|
-
- ❌ No remote session management
|
|
131
|
-
- ❌ No backend authentication required
|
|
132
|
-
|
|
133
|
-
**Automatic Standalone Detection:**
|
|
134
|
-
|
|
135
|
-
If no server URL is configured (via `--server-url` or environment variables), the agent automatically runs in standalone mode even without the `--standalone` flag.
|
|
136
|
-
|
|
137
|
-
##### Running Claude with ChatGPT/OpenAI
|
|
138
|
-
|
|
139
|
-
You can route Claude Code requests to ChatGPT/OpenAI using the LLM routing feature. This allows you to use GPT models while keeping the Claude Code interface.
|
|
140
|
-
|
|
141
|
-
**Prerequisites:**
|
|
142
|
-
|
|
143
|
-
1. **Authenticate with Codex CLI** (required for ChatGPT access):
|
|
144
|
-
```bash
|
|
145
|
-
# Install Codex CLI
|
|
146
|
-
npm install -g @openai/codex
|
|
147
|
-
|
|
148
|
-
# Authenticate (opens browser for OAuth login)
|
|
149
|
-
codex auth login
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
This stores your ChatGPT credentials in `~/.codex/auth.json`
|
|
153
|
-
|
|
154
|
-
**Usage Examples:**
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
# Start with default Claude (no routing)
|
|
158
|
-
agent-cli claude --alias "claude-session"
|
|
159
|
-
|
|
160
|
-
# Start with GPT-5 routing
|
|
161
|
-
agent-cli claude \
|
|
162
|
-
--alias "gpt5-session" \
|
|
163
|
-
--llm-provider chatgpt \
|
|
164
|
-
--llm-model gpt-5
|
|
165
|
-
|
|
166
|
-
# Start with GPT-5 Codex
|
|
167
|
-
agent-cli claude \
|
|
168
|
-
--alias "codex-session" \
|
|
169
|
-
--llm-provider chatgpt \
|
|
170
|
-
--llm-model gpt-5-codex
|
|
31
|
+
agent-cli daemon
|
|
171
32
|
```
|
|
172
33
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
When routing is enabled:
|
|
176
|
-
1. Claude Code requests are intercepted before reaching Anthropic's API
|
|
177
|
-
2. Requests are transformed from Claude Messages API format → ChatGPT Responses API format
|
|
178
|
-
3. The request is sent to ChatGPT with proper authentication (via Codex CLI)
|
|
179
|
-
4. ChatGPT's streaming response is transformed back to Claude's format
|
|
180
|
-
5. Claude Code receives responses as if they came from Anthropic
|
|
181
|
-
|
|
182
|
-
**Supported Models:**
|
|
183
|
-
|
|
184
|
-
- `gpt-5` - GPT-5 with reasoning (supports reasoning effort levels)
|
|
185
|
-
- `gpt-5-codex` - GPT-5 optimized for coding tasks
|
|
186
|
-
- More models may be added in the future
|
|
187
|
-
|
|
188
|
-
**Dynamic Model Switching:**
|
|
189
|
-
|
|
190
|
-
You can change the LLM routing configuration for an active session without restarting using the `agent-cli router` command (see below).
|
|
191
|
-
|
|
192
|
-
#### 3. `agent-cli router` - Manage LLM Routing
|
|
193
|
-
|
|
194
|
-
Manage LLM routing configuration for active Claude sessions. This allows you to switch between different LLM models without restarting your agent.
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
# Configure routing for a session (interactive)
|
|
198
|
-
agent-cli router
|
|
199
|
-
|
|
200
|
-
# Clear all session routing configurations
|
|
201
|
-
agent-cli router --clear
|
|
202
|
-
|
|
203
|
-
# With verbose logging
|
|
204
|
-
agent-cli router --verbose
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
**Options:**
|
|
208
|
-
- `-v, --verbose` - Enable verbose logging
|
|
209
|
-
- `--clear` - Clear all session routing configurations
|
|
210
|
-
|
|
211
|
-
**Interactive Workflow:**
|
|
212
|
-
|
|
213
|
-
1. **Select a session** - The command shows all active sessions with their current routing:
|
|
214
|
-
```
|
|
215
|
-
? Select a session to configure routing:
|
|
216
|
-
❯ my-dev-session [chatgpt/gpt-5 (high)]
|
|
217
|
-
gpt5-experiment [chatgpt/gpt-5-codex (medium)]
|
|
218
|
-
claude-session [default]
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
2. **Select routing configuration** - Choose from available options:
|
|
222
|
-
```
|
|
223
|
-
? Select LLM routing configuration:
|
|
224
|
-
❯ Default (Claude)
|
|
225
|
-
GPT-5 (Reasoning: High)
|
|
226
|
-
GPT-5 (Reasoning: Medium)
|
|
227
|
-
GPT-5 (Reasoning: Low)
|
|
228
|
-
GPT-5 (Reasoning: Minimal)
|
|
229
|
-
GPT-5 Codex (Reasoning: High)
|
|
230
|
-
GPT-5 Codex (Reasoning: Medium)
|
|
231
|
-
GPT-5 Codex (Reasoning: Low)
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
3. **Configuration saved** - The routing configuration is updated in `~/.agiflow/sessions.json`
|
|
235
|
-
|
|
236
|
-
**Available Routing Options:**
|
|
237
|
-
|
|
238
|
-
- **Default (Claude)** - Remove routing, use native Claude
|
|
239
|
-
- **GPT-5 (Reasoning: High)** - GPT-5 with maximum reasoning effort (best for complex problems)
|
|
240
|
-
- **GPT-5 (Reasoning: Medium)** - GPT-5 with balanced reasoning (default)
|
|
241
|
-
- **GPT-5 (Reasoning: Low)** - GPT-5 with minimal reasoning (faster responses)
|
|
242
|
-
- **GPT-5 (Reasoning: Minimal)** - GPT-5 with no reasoning (fastest)
|
|
243
|
-
- **GPT-5 Codex** - GPT-5 optimized for coding with reasoning levels
|
|
244
|
-
|
|
245
|
-
**Reasoning Effort Levels:**
|
|
246
|
-
|
|
247
|
-
The reasoning effort parameter controls how much computational reasoning the model uses:
|
|
248
|
-
- **High** - Maximum reasoning, best for complex problems, slowest
|
|
249
|
-
- **Medium** - Balanced reasoning, good for most tasks
|
|
250
|
-
- **Low** - Light reasoning, faster responses
|
|
251
|
-
- **Minimal** - No extra reasoning, fastest responses
|
|
252
|
-
|
|
253
|
-
**Session Settings Location:**
|
|
254
|
-
|
|
255
|
-
All session routing configurations are stored in `~/.agiflow/sessions.json`:
|
|
256
|
-
|
|
257
|
-
```json
|
|
258
|
-
{
|
|
259
|
-
"session-id-1": {
|
|
260
|
-
"provider": "chatgpt",
|
|
261
|
-
"model": "gpt-5",
|
|
262
|
-
"reasoningEffort": "high",
|
|
263
|
-
"alias": "my-dev-session"
|
|
264
|
-
},
|
|
265
|
-
"session-id-2": {
|
|
266
|
-
"provider": "chatgpt",
|
|
267
|
-
"model": "gpt-5-codex",
|
|
268
|
-
"reasoningEffort": "medium",
|
|
269
|
-
"alias": "gpt5-experiment"
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
**Example Workflow:**
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# 1. Start Claude with default routing
|
|
278
|
-
agent-cli claude --alias "dev-session"
|
|
279
|
-
|
|
280
|
-
# 2. Switch to GPT-5 with high reasoning (while agent is running)
|
|
281
|
-
agent-cli router
|
|
282
|
-
# Select "dev-session" → "GPT-5 (Reasoning: High)"
|
|
283
|
-
|
|
284
|
-
# 3. Switch to GPT-5 Codex with medium reasoning
|
|
285
|
-
agent-cli router
|
|
286
|
-
# Select "dev-session" → "GPT-5 Codex (Reasoning: Medium)"
|
|
287
|
-
|
|
288
|
-
# 4. Switch back to default Claude
|
|
289
|
-
agent-cli router
|
|
290
|
-
# Select "dev-session" → "Default (Claude)"
|
|
291
|
-
|
|
292
|
-
# 5. Clear all routing configurations
|
|
293
|
-
agent-cli router --clear
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
**Tips:**
|
|
297
|
-
|
|
298
|
-
- Use `--alias` when launching Claude to give your sessions meaningful names
|
|
299
|
-
- Session routing is dynamic - changes take effect immediately without restart
|
|
300
|
-
- Clear routing with `agent-cli router --clear` to reset all sessions to default Claude
|
|
301
|
-
- Reasoning effort only applies to GPT models (not Claude)
|
|
302
|
-
|
|
303
|
-
#### 4. `agent-cli logout` - Clean Up Credentials
|
|
34
|
+
#### 2. `agent-cli logout` - Clean Up Credentials
|
|
304
35
|
Log out and clean up stored credentials.
|
|
305
36
|
|
|
306
37
|
```bash
|
|
@@ -320,80 +51,10 @@ agent-cli logout --verbose
|
|
|
320
51
|
|
|
321
52
|
### Authentication Flow
|
|
322
53
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
2. **Claude Command**: Requires valid session ID
|
|
329
|
-
- Can use stored credentials from connect flow
|
|
330
|
-
- Or provide API key and organization ID directly
|
|
331
|
-
|
|
332
|
-
### Troubleshooting
|
|
333
|
-
|
|
334
|
-
**Common Issues:**
|
|
335
|
-
|
|
336
|
-
1. **Missing Agent Session ID**
|
|
337
|
-
```
|
|
338
|
-
Error: Agent session ID is required
|
|
339
|
-
```
|
|
340
|
-
Solution: Provide `--agent-session-id` or set `CLAUDE_AGENT_SESSION_ID` environment variable
|
|
341
|
-
|
|
342
|
-
2. **Invalid Server URL**
|
|
343
|
-
```
|
|
344
|
-
Error: Invalid server URL
|
|
345
|
-
```
|
|
346
|
-
Solution: Ensure URL is valid WebSocket format (ws:// or wss://)
|
|
347
|
-
|
|
348
|
-
3. **Authentication Failed**
|
|
349
|
-
```
|
|
350
|
-
Error: Authentication failed
|
|
351
|
-
```
|
|
352
|
-
Solution: Run `agent-cli connect` first or provide valid API credentials
|
|
353
|
-
|
|
354
|
-
4. **Connection Issues**
|
|
355
|
-
- Check network connectivity
|
|
356
|
-
- Verify server URL is accessible
|
|
357
|
-
- Use `--verbose` flag for detailed logging
|
|
358
|
-
- Use `--standalone` flag to run without backend connection
|
|
359
|
-
|
|
360
|
-
5. **WebSocket 401 Unauthorized (Production)**
|
|
361
|
-
```
|
|
362
|
-
Error: Unexpected server response: 401
|
|
363
|
-
```
|
|
364
|
-
Solution: Use `--standalone` flag to run without backend authentication:
|
|
365
|
-
```bash
|
|
366
|
-
agent-cli claude --standalone --verbose
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
**LLM Routing Issues:**
|
|
370
|
-
|
|
371
|
-
1. **Codex Auth Not Found**
|
|
372
|
-
```
|
|
373
|
-
Warning: Failed to read Codex auth
|
|
374
|
-
```
|
|
375
|
-
Solutions:
|
|
376
|
-
- Install Codex CLI: `npm install -g @openai/codex`
|
|
377
|
-
- Authenticate: `codex auth login`
|
|
378
|
-
- Verify `~/.codex/auth.json` exists
|
|
379
|
-
|
|
380
|
-
2. **ChatGPT Token Expired**
|
|
381
|
-
```
|
|
382
|
-
Error: 401 Unauthorized
|
|
383
|
-
```
|
|
384
|
-
Solution: Re-authenticate with Codex: `codex auth login`
|
|
385
|
-
|
|
386
|
-
3. **Routing Not Working**
|
|
387
|
-
- Verify routing is configured via `agent-cli router` command
|
|
388
|
-
- Use `--verbose` to see routing status
|
|
389
|
-
- Check that Codex credentials are valid (`codex auth login`)
|
|
390
|
-
- Ensure network can reach ChatGPT API
|
|
391
|
-
|
|
392
|
-
4. **Session Not Found in Router**
|
|
393
|
-
If your session doesn't appear in `agent-cli router`:
|
|
394
|
-
- Restart Claude agent with `--alias` to give it a meaningful name
|
|
395
|
-
- Check `~/.agiflow/sessions.json` to see saved sessions
|
|
396
|
-
- Use `agent-cli router --clear` to reset all configurations
|
|
54
|
+
**Daemon Command**: Uses device code authentication flow
|
|
55
|
+
- Prompts for browser-based authentication
|
|
56
|
+
- Stores credentials in `~/.agiflow/` directory
|
|
57
|
+
- Maintains persistent connection to Agiflow platform
|
|
397
58
|
|
|
398
59
|
### Global Options
|
|
399
60
|
|