@agiflowai/agent-cli 0.0.6 → 0.0.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/CHANGELOG.md +10 -0
- package/README.md +289 -28
- package/dist/AgentHttpService-MFVF-74l.js +6 -0
- package/dist/AgentHttpService-MFVF-74l.js.map +1 -0
- package/dist/claudePostToolUse.js +5 -5
- package/dist/cli-4pvA3zg9.js +129 -0
- package/dist/cli-4pvA3zg9.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/networkLog.js +411 -16
- package/dist/networkLog.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/AgentHttpService-CYYuD3Wj.js +0 -6
- package/dist/AgentHttpService-CYYuD3Wj.js.map +0 -1
- package/dist/cli-DiglQoZ5.js +0 -129
- package/dist/cli-DiglQoZ5.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
Update:
|
|
5
|
+
- Add `claude --standalone` command to support launching claude without backend connection.
|
|
6
|
+
|
|
7
|
+
## 0.0.7
|
|
8
|
+
Add:
|
|
9
|
+
- Add `router` command to enable switching provider to openai chatgpt sub.
|
|
10
|
+
Update:
|
|
11
|
+
- Launch `claude` command independently which can be dynamically switch model between gpt and claude.
|
|
12
|
+
|
|
3
13
|
## 0.0.6
|
|
4
14
|
- Launch Claude code npm package instead of native binary.
|
|
5
15
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
# Agiflow Agent CLI
|
|
2
2
|
|
|
3
|
+
[](https://github.com/AgiFlow/aicode-toolkit)
|
|
4
|
+
[](https://www.npmjs.com/package/@agiflowai/agent-cli)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
3
7
|
@agiflowai/agent-cli - Command-line interface for connecting and managing AI agents (Claude Code, Gemini) with Agiflow remotely.
|
|
4
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
|
+
**🔗 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
|
+
|
|
5
15
|
## Quick Start
|
|
6
16
|
|
|
7
17
|
### Installation
|
|
@@ -18,18 +28,18 @@ npm install @agiflowai/agent-cli
|
|
|
18
28
|
|
|
19
29
|
The CLI provides three main commands:
|
|
20
30
|
|
|
21
|
-
#### 1. `
|
|
31
|
+
#### 1. `agent-cli connect` - Connect Daemon
|
|
22
32
|
Connect your local machine to the Agiflow platform to receive remote commands.
|
|
23
33
|
|
|
24
34
|
```bash
|
|
25
35
|
# Basic connection
|
|
26
|
-
|
|
36
|
+
agent-cli connect
|
|
27
37
|
|
|
28
38
|
# With custom server URL
|
|
29
|
-
|
|
39
|
+
agent-cli connect --server-url wss://your-server.com
|
|
30
40
|
|
|
31
41
|
# With verbose logging
|
|
32
|
-
|
|
42
|
+
agent-cli connect --verbose
|
|
33
43
|
```
|
|
34
44
|
|
|
35
45
|
**Options:**
|
|
@@ -39,19 +49,36 @@ agiflow connect --verbose
|
|
|
39
49
|
- `--reconnect-interval <ms>` - Reconnection interval in milliseconds (default: 5000)
|
|
40
50
|
- `--unique-instance` - Create unique daemon instance
|
|
41
51
|
|
|
42
|
-
#### 2. `
|
|
52
|
+
#### 2. `agent-cli claude` - Launch Claude Agent
|
|
43
53
|
Launch a Claude Code agent with full functionality.
|
|
44
54
|
|
|
45
55
|
```bash
|
|
46
|
-
# Basic Claude agent launch (
|
|
47
|
-
|
|
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"
|
|
48
66
|
|
|
49
67
|
# With custom configuration
|
|
50
|
-
|
|
68
|
+
agent-cli claude \
|
|
51
69
|
--agent-session-id your-session-id \
|
|
52
70
|
--server-url wss://your-server.com \
|
|
53
71
|
--working-directory /path/to/project \
|
|
54
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
|
|
55
82
|
```
|
|
56
83
|
|
|
57
84
|
**Options:**
|
|
@@ -65,41 +92,232 @@ agiflow claude \
|
|
|
65
92
|
- `-c, --agent-config <json>` - Agent configuration as JSON string
|
|
66
93
|
- `--args <args...>` - Additional arguments to pass to Claude
|
|
67
94
|
- `-v, --verbose` - Enable verbose logging
|
|
95
|
+
- `--alias <alias>` - Custom session alias for easy identification
|
|
96
|
+
- `--standalone` - Run in standalone mode without backend connection
|
|
68
97
|
|
|
69
|
-
|
|
70
|
-
|
|
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:**
|
|
71
112
|
|
|
72
113
|
```bash
|
|
73
|
-
#
|
|
74
|
-
|
|
114
|
+
# Explicit standalone mode
|
|
115
|
+
agent-cli claude --standalone
|
|
75
116
|
|
|
76
|
-
#
|
|
77
|
-
|
|
117
|
+
# Standalone mode with verbose logging
|
|
118
|
+
agent-cli claude --standalone --verbose
|
|
78
119
|
|
|
79
|
-
#
|
|
80
|
-
|
|
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
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**How It Works:**
|
|
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
|
|
81
205
|
```
|
|
82
206
|
|
|
83
207
|
**Options:**
|
|
84
208
|
- `-v, --verbose` - Enable verbose logging
|
|
85
|
-
- `--
|
|
209
|
+
- `--clear` - Clear all session routing configurations
|
|
86
210
|
|
|
87
|
-
|
|
211
|
+
**Interactive Workflow:**
|
|
88
212
|
|
|
89
|
-
|
|
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:**
|
|
90
275
|
|
|
91
276
|
```bash
|
|
92
|
-
#
|
|
93
|
-
|
|
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)"
|
|
94
283
|
|
|
95
|
-
#
|
|
96
|
-
|
|
97
|
-
|
|
284
|
+
# 3. Switch to GPT-5 Codex with medium reasoning
|
|
285
|
+
agent-cli router
|
|
286
|
+
# Select "dev-session" → "GPT-5 Codex (Reasoning: Medium)"
|
|
98
287
|
|
|
99
|
-
#
|
|
100
|
-
|
|
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
|
|
101
294
|
```
|
|
102
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
|
|
304
|
+
Log out and clean up stored credentials.
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Remove credential files only
|
|
308
|
+
agent-cli logout
|
|
309
|
+
|
|
310
|
+
# Remove entire .agiflow directory
|
|
311
|
+
agent-cli logout --remove-all
|
|
312
|
+
|
|
313
|
+
# With verbose output
|
|
314
|
+
agent-cli logout --verbose
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Options:**
|
|
318
|
+
- `-v, --verbose` - Enable verbose logging
|
|
319
|
+
- `--remove-all` - Remove entire .agiflow directory (default: remove only credential files)
|
|
320
|
+
|
|
103
321
|
### Authentication Flow
|
|
104
322
|
|
|
105
323
|
1. **Connect Command**: Uses device code authentication flow
|
|
@@ -131,12 +349,51 @@ VITE_INJECT_AGIFLOW_APP_ENDPOINT=wss://your-server.com
|
|
|
131
349
|
```
|
|
132
350
|
Error: Authentication failed
|
|
133
351
|
```
|
|
134
|
-
Solution: Run `
|
|
352
|
+
Solution: Run `agent-cli connect` first or provide valid API credentials
|
|
135
353
|
|
|
136
354
|
4. **Connection Issues**
|
|
137
355
|
- Check network connectivity
|
|
138
356
|
- Verify server URL is accessible
|
|
139
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
|
|
140
397
|
|
|
141
398
|
### Global Options
|
|
142
399
|
|
|
@@ -144,7 +401,11 @@ All commands support these global options:
|
|
|
144
401
|
- `-v, --verbose` - Enable verbose logging
|
|
145
402
|
- `--debug` - Enable debug mode
|
|
146
403
|
|
|
147
|
-
Use `
|
|
404
|
+
Use `agent-cli --help` or `agent-cli <command> --help` for detailed command information.
|
|
405
|
+
|
|
406
|
+
## Related Projects
|
|
407
|
+
|
|
408
|
+
🔗 **[AgiFlow AI Code Toolkit](https://github.com/AgiFlow/aicode-toolkit)** - An open-source collection of AI development tools and utilities for building with AI coding assistants.
|
|
148
409
|
|
|
149
410
|
## License
|
|
150
411
|
|