@willjackson/claude-code-bridge 0.2.4 → 0.4.1
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 +83 -185
- package/dist/{chunk-5HWFDZKH.js → chunk-MHUQYPTB.js} +409 -359
- package/dist/chunk-MHUQYPTB.js.map +1 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +245 -159
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +108 -290
- package/dist/index.js +9 -81
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/dist/chunk-5HWFDZKH.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@ A bidirectional communication system that enables two separate Claude Code insta
|
|
|
10
10
|
- [Quick Start](#quick-start)
|
|
11
11
|
- [CLI Reference](#cli-reference)
|
|
12
12
|
- [Configuration](#configuration)
|
|
13
|
-
- [Environment Setup](#environment-setup)
|
|
14
13
|
- [Programmatic Usage](#programmatic-usage)
|
|
15
14
|
- [Troubleshooting](#troubleshooting)
|
|
16
15
|
- [Development](#development)
|
|
@@ -18,7 +17,7 @@ A bidirectional communication system that enables two separate Claude Code insta
|
|
|
18
17
|
|
|
19
18
|
## Overview
|
|
20
19
|
|
|
21
|
-
Claude Code Bridge connects
|
|
20
|
+
Claude Code Bridge connects two Claude Code instances running on different machines, containers, or networks via WebSocket.
|
|
22
21
|
|
|
23
22
|
### Architecture
|
|
24
23
|
|
|
@@ -47,7 +46,6 @@ Claude Code Bridge connects a native macOS/Linux Claude Code instance with a Cla
|
|
|
47
46
|
## Features
|
|
48
47
|
|
|
49
48
|
- **WebSocket-based communication** with automatic reconnection
|
|
50
|
-
- **Environment auto-detection** for Docksal, DDEV, Lando, and Docker
|
|
51
49
|
- **Context synchronization** with configurable file patterns
|
|
52
50
|
- **Task delegation** with timeout handling
|
|
53
51
|
- **Remote file operations** - read, write, and delete files on connected peers
|
|
@@ -64,13 +62,15 @@ Claude Code Bridge connects a native macOS/Linux Claude Code instance with a Cla
|
|
|
64
62
|
### Global Installation (Recommended)
|
|
65
63
|
|
|
66
64
|
```bash
|
|
67
|
-
npm install -g claude-code-bridge
|
|
65
|
+
npm install -g @willjackson/claude-code-bridge
|
|
68
66
|
```
|
|
69
67
|
|
|
68
|
+
After installation, the `claude-bridge` command will be available globally.
|
|
69
|
+
|
|
70
70
|
### Run Without Installing
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
npx claude-code-bridge start
|
|
73
|
+
npx @willjackson/claude-code-bridge start
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
### Install from Source
|
|
@@ -93,56 +93,44 @@ npm link # Makes 'claude-bridge' available globally
|
|
|
93
93
|
claude-bridge start --port 8766
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
**Step 2: Start the bridge
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# Inside the container (Docksal, DDEV, or Docker)
|
|
100
|
-
claude-bridge start --port 8765 --connect ws://host.docker.internal:8766
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Scenario 2: Auto-Detection Mode
|
|
104
|
-
|
|
105
|
-
Let the bridge automatically detect your environment and configure itself:
|
|
96
|
+
**Step 2: Start the bridge on the remote machine and connect**
|
|
106
97
|
|
|
107
98
|
```bash
|
|
108
|
-
# On
|
|
109
|
-
claude-bridge start --
|
|
110
|
-
|
|
111
|
-
# In container (auto-detects Docker environment, uses port 8765)
|
|
112
|
-
claude-bridge start --auto --connect ws://host.docker.internal:8766
|
|
99
|
+
# On remote machine (replace MACHINE_A_IP with actual IP)
|
|
100
|
+
claude-bridge start --port 8765 --connect ws://MACHINE_A_IP:8766
|
|
113
101
|
```
|
|
114
102
|
|
|
115
|
-
### Scenario
|
|
103
|
+
### Scenario 2: Peer-to-Peer Mode
|
|
116
104
|
|
|
117
105
|
Both instances can initiate communication:
|
|
118
106
|
|
|
119
|
-
**
|
|
107
|
+
**Machine A:**
|
|
120
108
|
```bash
|
|
121
109
|
claude-bridge start --port 8766
|
|
122
110
|
```
|
|
123
111
|
|
|
124
|
-
**
|
|
112
|
+
**Machine B:**
|
|
125
113
|
```bash
|
|
126
|
-
claude-bridge start --port 8765 --connect ws://
|
|
114
|
+
claude-bridge start --port 8765 --connect ws://MACHINE_A_IP:8766
|
|
127
115
|
```
|
|
128
116
|
|
|
129
117
|
Once connected, either side can send context or delegate tasks to the other.
|
|
130
118
|
|
|
131
|
-
### Scenario
|
|
119
|
+
### Scenario 3: Remote File Operations
|
|
132
120
|
|
|
133
121
|
Enable file operations on the remote to allow reading, writing, and deleting files:
|
|
134
122
|
|
|
135
|
-
**
|
|
123
|
+
**Machine A (relay mode, no handlers):**
|
|
136
124
|
```bash
|
|
137
125
|
claude-bridge start --port 8766
|
|
138
126
|
```
|
|
139
127
|
|
|
140
|
-
**
|
|
128
|
+
**Machine B (with file handlers):**
|
|
141
129
|
```bash
|
|
142
|
-
claude-bridge start --with-handlers --connect ws://
|
|
130
|
+
claude-bridge start --with-handlers --connect ws://MACHINE_A_IP:8766
|
|
143
131
|
```
|
|
144
132
|
|
|
145
|
-
Now you can read, write, and edit files on
|
|
133
|
+
Now you can read, write, and edit files on Machine B from Machine A.
|
|
146
134
|
|
|
147
135
|
## CLI Reference
|
|
148
136
|
|
|
@@ -166,10 +154,9 @@ Options:
|
|
|
166
154
|
claude-bridge start [options]
|
|
167
155
|
|
|
168
156
|
Options:
|
|
169
|
-
-p, --port <port> Port to listen on (default: 8765
|
|
157
|
+
-p, --port <port> Port to listen on (default: 8765)
|
|
170
158
|
-h, --host <host> Host to bind to (default: 0.0.0.0)
|
|
171
159
|
-c, --connect <url> URL to connect to on startup (e.g., ws://localhost:8765)
|
|
172
|
-
-a, --auto Auto-detect environment and configure
|
|
173
160
|
-d, --daemon Run in background
|
|
174
161
|
--with-handlers Enable file operations and task handling (read/write/delete files)
|
|
175
162
|
```
|
|
@@ -190,9 +177,65 @@ claude-bridge start --connect ws://192.168.1.100:8765
|
|
|
190
177
|
claude-bridge start --daemon
|
|
191
178
|
|
|
192
179
|
# Start with file operation handlers enabled
|
|
193
|
-
claude-bridge start --with-handlers --connect ws://
|
|
180
|
+
claude-bridge start --with-handlers --connect ws://192.168.1.100:8766
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Daemon Mode
|
|
184
|
+
|
|
185
|
+
Daemon mode runs the bridge as a background process, allowing you to close your terminal while the bridge continues running.
|
|
186
|
+
|
|
187
|
+
#### Starting in Daemon Mode
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Start bridge in background
|
|
191
|
+
claude-bridge start --daemon
|
|
192
|
+
|
|
193
|
+
# Start with additional options
|
|
194
|
+
claude-bridge start --daemon --port 8766 --with-handlers
|
|
195
|
+
|
|
196
|
+
# Start daemon and connect to remote
|
|
197
|
+
claude-bridge start --daemon --connect ws://192.168.1.100:8765
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
When started in daemon mode, the bridge:
|
|
201
|
+
- Detaches from the terminal and runs in the background
|
|
202
|
+
- Writes its PID and status to `~/.claude-bridge/status.json`
|
|
203
|
+
- Continues running until explicitly stopped
|
|
204
|
+
|
|
205
|
+
#### Checking Daemon Status
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
claude-bridge status
|
|
194
209
|
```
|
|
195
210
|
|
|
211
|
+
This shows whether a daemon is running, its PID, listening port, and connected peers.
|
|
212
|
+
|
|
213
|
+
#### Stopping the Daemon
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
claude-bridge stop
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
This reads the PID from the status file and gracefully shuts down the background process.
|
|
220
|
+
|
|
221
|
+
#### Status File
|
|
222
|
+
|
|
223
|
+
The daemon writes its status to `~/.claude-bridge/status.json`:
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"running": true,
|
|
228
|
+
"pid": 12345,
|
|
229
|
+
"port": 8766,
|
|
230
|
+
"host": "0.0.0.0",
|
|
231
|
+
"instanceName": "bridge-12345",
|
|
232
|
+
"startedAt": "2024-01-15T10:30:00.000Z",
|
|
233
|
+
"peers": []
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
This file is automatically removed when the daemon stops cleanly.
|
|
238
|
+
|
|
196
239
|
#### `stop` - Stop the Running Bridge
|
|
197
240
|
|
|
198
241
|
```bash
|
|
@@ -228,30 +271,18 @@ Arguments:
|
|
|
228
271
|
|
|
229
272
|
```bash
|
|
230
273
|
claude-bridge connect ws://localhost:8765
|
|
231
|
-
claude-bridge connect ws://
|
|
274
|
+
claude-bridge connect ws://192.168.1.100:8766
|
|
232
275
|
```
|
|
233
276
|
|
|
234
|
-
#### `
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
claude-bridge discover
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
Searches for:
|
|
241
|
-
- Docker containers with `claude.bridge.enabled=true` label
|
|
242
|
-
- Running Docksal projects
|
|
243
|
-
- Running DDEV projects
|
|
244
|
-
|
|
245
|
-
#### `info` - Show Environment Information
|
|
277
|
+
#### `info` - Show System Information
|
|
246
278
|
|
|
247
279
|
```bash
|
|
248
280
|
claude-bridge info
|
|
249
281
|
```
|
|
250
282
|
|
|
251
283
|
Displays:
|
|
252
|
-
-
|
|
253
|
-
-
|
|
254
|
-
- Network configuration
|
|
284
|
+
- System information (Node version, OS, platform)
|
|
285
|
+
- Network interfaces
|
|
255
286
|
- Current configuration settings
|
|
256
287
|
|
|
257
288
|
## Configuration
|
|
@@ -278,7 +309,6 @@ listen:
|
|
|
278
309
|
# Connection to remote bridge
|
|
279
310
|
connect:
|
|
280
311
|
url: ws://localhost:8765
|
|
281
|
-
hostGateway: true # Use host.docker.internal
|
|
282
312
|
|
|
283
313
|
# Context sharing settings
|
|
284
314
|
contextSharing:
|
|
@@ -310,7 +340,6 @@ interaction:
|
|
|
310
340
|
| `listen.port` | number | 8765 | Port to listen on |
|
|
311
341
|
| `listen.host` | string | 0.0.0.0 | Host to bind to |
|
|
312
342
|
| `connect.url` | string | - | WebSocket URL of remote bridge |
|
|
313
|
-
| `connect.hostGateway` | boolean | false | Use `host.docker.internal` |
|
|
314
343
|
| `contextSharing.autoSync` | boolean | true | Automatically sync context |
|
|
315
344
|
| `contextSharing.syncInterval` | number | 5000 | Sync interval in ms |
|
|
316
345
|
| `contextSharing.maxChunkTokens` | number | 4000 | Max tokens per context chunk |
|
|
@@ -320,95 +349,6 @@ interaction:
|
|
|
320
349
|
| `interaction.notifyOnActivity` | boolean | true | Show notifications on activity |
|
|
321
350
|
| `interaction.taskTimeout` | number | 300000 | Task timeout in ms |
|
|
322
351
|
|
|
323
|
-
## Environment Setup
|
|
324
|
-
|
|
325
|
-
### DDEV
|
|
326
|
-
|
|
327
|
-
**Option 1: Using the DDEV Addon**
|
|
328
|
-
|
|
329
|
-
Copy the addon files to your DDEV project:
|
|
330
|
-
|
|
331
|
-
```bash
|
|
332
|
-
cp -r addons/ddev/* .ddev/
|
|
333
|
-
ddev restart
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
Then start the bridge:
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
ddev exec claude-bridge start --connect ws://host.docker.internal:8766
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
**Option 2: Add to docker-compose**
|
|
343
|
-
|
|
344
|
-
Create `.ddev/docker-compose.claude-bridge.yaml`:
|
|
345
|
-
|
|
346
|
-
```yaml
|
|
347
|
-
services:
|
|
348
|
-
web:
|
|
349
|
-
labels:
|
|
350
|
-
- "claude.bridge.enabled=true"
|
|
351
|
-
- "claude.bridge.port=8765"
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### Docksal
|
|
355
|
-
|
|
356
|
-
**Option 1: Using the Docksal Addon**
|
|
357
|
-
|
|
358
|
-
```bash
|
|
359
|
-
# Copy addon to Docksal
|
|
360
|
-
cp -r addons/docksal/* ~/.docksal/addons/claude-bridge/
|
|
361
|
-
|
|
362
|
-
# Install in your project
|
|
363
|
-
fin addon install claude-bridge
|
|
364
|
-
|
|
365
|
-
# Start the bridge
|
|
366
|
-
fin claude-bridge start
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
**Option 2: Manual Setup**
|
|
370
|
-
|
|
371
|
-
Add to your project's `.docksal/docksal.yml`:
|
|
372
|
-
|
|
373
|
-
```yaml
|
|
374
|
-
services:
|
|
375
|
-
cli:
|
|
376
|
-
labels:
|
|
377
|
-
- "claude.bridge.enabled=true"
|
|
378
|
-
- "claude.bridge.port=8765"
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Lando
|
|
382
|
-
|
|
383
|
-
Lando support is coming soon. For now, you can manually install the bridge in your Lando container:
|
|
384
|
-
|
|
385
|
-
```bash
|
|
386
|
-
lando ssh
|
|
387
|
-
npm install -g claude-code-bridge
|
|
388
|
-
claude-bridge start --connect ws://host.docker.internal:8766
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
### Plain Docker
|
|
392
|
-
|
|
393
|
-
Add to your `docker-compose.yml`:
|
|
394
|
-
|
|
395
|
-
```yaml
|
|
396
|
-
services:
|
|
397
|
-
app:
|
|
398
|
-
labels:
|
|
399
|
-
- "claude.bridge.enabled=true"
|
|
400
|
-
- "claude.bridge.port=8765"
|
|
401
|
-
environment:
|
|
402
|
-
- NODE_ENV=development
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
Then inside the container:
|
|
406
|
-
|
|
407
|
-
```bash
|
|
408
|
-
npm install -g claude-code-bridge
|
|
409
|
-
claude-bridge start --auto
|
|
410
|
-
```
|
|
411
|
-
|
|
412
352
|
## Programmatic Usage
|
|
413
353
|
|
|
414
354
|
### Basic Usage
|
|
@@ -577,20 +517,6 @@ await bridge.delegateTask({
|
|
|
577
517
|
|
|
578
518
|
> **Security Note:** All file operations are restricted to the project directory where the bridge is running. Paths outside the project root are rejected.
|
|
579
519
|
|
|
580
|
-
### Environment Detection
|
|
581
|
-
|
|
582
|
-
```typescript
|
|
583
|
-
import { detectEnvironment, getHostGateway } from 'claude-code-bridge';
|
|
584
|
-
|
|
585
|
-
const env = detectEnvironment();
|
|
586
|
-
console.log('Environment:', env.type); // 'native', 'docksal', 'ddev', 'lando', 'docker'
|
|
587
|
-
console.log('Is Container:', env.isContainer);
|
|
588
|
-
console.log('Project Name:', env.projectName);
|
|
589
|
-
|
|
590
|
-
const gateway = getHostGateway();
|
|
591
|
-
console.log('Host Gateway:', gateway); // 'host.docker.internal' or IP address
|
|
592
|
-
```
|
|
593
|
-
|
|
594
520
|
### Context Manager
|
|
595
521
|
|
|
596
522
|
```typescript
|
|
@@ -623,13 +549,13 @@ for (const change of delta.changes) {
|
|
|
623
549
|
|
|
624
550
|
### Connection Issues
|
|
625
551
|
|
|
626
|
-
**Problem:** Cannot connect to bridge from
|
|
552
|
+
**Problem:** Cannot connect to bridge from remote machine
|
|
627
553
|
|
|
628
554
|
**Solutions:**
|
|
629
555
|
1. Ensure the host bridge is running: `claude-bridge status`
|
|
630
556
|
2. Check firewall settings allow the port
|
|
631
|
-
3. Verify
|
|
632
|
-
4. Try using the
|
|
557
|
+
3. Verify the IP address is correct and reachable: `ping MACHINE_IP`
|
|
558
|
+
4. Try using the full URL: `claude-bridge connect ws://192.168.1.100:8766`
|
|
633
559
|
|
|
634
560
|
**Problem:** Connection keeps dropping
|
|
635
561
|
|
|
@@ -638,18 +564,6 @@ for (const change of delta.changes) {
|
|
|
638
564
|
2. Increase timeout settings in config
|
|
639
565
|
3. Enable verbose logging: `claude-bridge start -v`
|
|
640
566
|
|
|
641
|
-
### Environment Detection Issues
|
|
642
|
-
|
|
643
|
-
**Problem:** Bridge doesn't detect my environment correctly
|
|
644
|
-
|
|
645
|
-
**Solutions:**
|
|
646
|
-
1. Run `claude-bridge info` to see detected environment
|
|
647
|
-
2. Check environment variables are set correctly:
|
|
648
|
-
- Docksal: `DOCKSAL_STACK` should be set
|
|
649
|
-
- DDEV: `IS_DDEV_PROJECT=true` should be set
|
|
650
|
-
- Lando: `LANDO=ON` should be set
|
|
651
|
-
3. Use explicit configuration instead of auto-detection
|
|
652
|
-
|
|
653
567
|
### Port Conflicts
|
|
654
568
|
|
|
655
569
|
**Problem:** Port already in use
|
|
@@ -719,13 +633,7 @@ claude-code-bridge/
|
|
|
719
633
|
│ │ └── context.ts # Context manager
|
|
720
634
|
│ ├── transport/
|
|
721
635
|
│ │ ├── interface.ts # Transport abstraction
|
|
722
|
-
│ │
|
|
723
|
-
│ │ └── discovery.ts # Peer discovery
|
|
724
|
-
│ ├── environment/
|
|
725
|
-
│ │ ├── detect.ts # Environment detection
|
|
726
|
-
│ │ ├── docksal.ts # Docksal helpers
|
|
727
|
-
│ │ ├── ddev.ts # DDEV helpers
|
|
728
|
-
│ │ └── lando.ts # Lando helpers
|
|
636
|
+
│ │ └── websocket.ts # WebSocket implementation
|
|
729
637
|
│ ├── cli/
|
|
730
638
|
│ │ ├── index.ts # CLI entry point
|
|
731
639
|
│ │ └── commands/ # CLI commands
|
|
@@ -737,10 +645,6 @@ claude-code-bridge/
|
|
|
737
645
|
│ ├── unit/ # Unit tests
|
|
738
646
|
│ ├── integration/ # Integration tests
|
|
739
647
|
│ └── e2e/ # End-to-end tests
|
|
740
|
-
└── addons/
|
|
741
|
-
├── ddev/ # DDEV addon
|
|
742
|
-
├── docksal/ # Docksal addon
|
|
743
|
-
└── lando/ # Lando plugin
|
|
744
648
|
```
|
|
745
649
|
|
|
746
650
|
### Running Tests
|
|
@@ -759,12 +663,6 @@ npm test -- tests/unit/bridge/protocol.test.ts
|
|
|
759
663
|
npm test -- --grep "WebSocket"
|
|
760
664
|
```
|
|
761
665
|
|
|
762
|
-
## Documentation
|
|
763
|
-
|
|
764
|
-
- [CLAUDE.md](./CLAUDE.md) - Detailed project specification and architecture
|
|
765
|
-
- [AGENTS.md](./AGENTS.md) - Guidelines for AI agents working on this codebase
|
|
766
|
-
- [instructions.md](./instructions.md) - Development phases and testing strategy
|
|
767
|
-
|
|
768
666
|
## License
|
|
769
667
|
|
|
770
668
|
MIT License - see [LICENSE](./LICENSE) for details.
|