@willjackson/claude-code-bridge 0.5.1 → 0.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Claude Code Bridge
2
2
 
3
- A bidirectional communication system that enables two separate Claude Code instances to collaborate across different environments.
3
+ Control and interact with remote environments from your local Claude Code instance via WebSocket.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -17,40 +17,49 @@ A bidirectional communication system that enables two separate Claude Code insta
17
17
 
18
18
  ## Overview
19
19
 
20
- Claude Code Bridge connects two Claude Code instances running on different machines, containers, or networks via WebSocket.
20
+ Claude Code Bridge enables your local Claude Code instance to read, write, and manage files on remote machines, containers, or servers. The **host** runs on your local machine with Claude Code, while the **client** runs on the remote machine and executes commands.
21
21
 
22
22
  ### Architecture
23
23
 
24
24
  ```
25
- ┌─────────────────────────┐ ┌─────────────────────────┐
26
- Local Mac │ Container (CLI/Web) │
27
- ┌───────────────────┐ │ ┌───────────────────┐ │
28
- │ │ Claude Code │ │ Claude Code │ │
29
- │ │ (Desktop App) │ │ │ (Server App)
30
- └─────────┬─────────┘ │ └─────────┬─────────┘ │
31
- │ │
32
- ┌─────────┴─────────┐ │ WebSocket ┌─────────┴─────────┐ │
33
- │ │ Bridge Plugin │◄─┼────────────────────┼─►│ Bridge Plugin
34
- │ │ (port 8766) │ │ (port 8765) │ │
35
- └───────────────────┘ │ └───────────────────┘ │
36
- └─────────────────────────┘ └─────────────────────────┘
25
+ ┌─────────────────────────────────────────┐
26
+ HOST (Local Machine)
27
+ ┌─────────────────────────────────┐
28
+ │ │ Claude Code
29
+ │ │ (with MCP tools enabled) │ │
30
+ └──────────────┬──────────────────┘
31
+ MCP
32
+ ┌──────────────┴──────────────────┐
33
+ │ │ Bridge (host mode)
34
+ │ │ port 8766
35
+ └──────────────┬──────────────────┘
36
+ └─────────────────┼───────────────────────┘
37
+ │ WebSocket
38
+ ┌─────────────────┼───────────────────────┐
39
+ │ CLIENT (Remote Machine) │
40
+ │ ┌──────────────┴──────────────────┐ │
41
+ │ │ Bridge (client mode) │ │
42
+ │ │ --with-handlers │ │
43
+ │ │ Executes: read/write/delete │ │
44
+ │ └─────────────────────────────────┘ │
45
+ └─────────────────────────────────────────┘
37
46
  ```
38
47
 
39
48
  ### Use Cases
40
49
 
41
- - **Cross-environment refactoring**: Coordinate changes between API client (desktop) and API server (container)
42
- - **Context sharing**: Share code snippets, project structure, and summaries between instances
43
- - **Task delegation**: Delegate tasks from one Claude Code instance to another
44
- - **Multi-project coordination**: Work on related projects in different environments simultaneously
50
+ - **Remote file editing**: Read, write, and delete files on remote servers from your local Claude Code
51
+ - **Cross-environment development**: Work on a Docker container or VM from your local machine
52
+ - **Server management**: Manage configuration files on remote servers
53
+ - **Multi-machine workflows**: Control multiple remote environments from one Claude Code instance
45
54
 
46
55
  ## Features
47
56
 
48
- - **WebSocket-based communication** with automatic reconnection
49
- - **Context synchronization** with configurable file patterns
50
- - **Task delegation** with timeout handling
51
- - **Remote file operations** - read, write, and delete files on connected peers
52
- - **Peer-to-peer mode** allowing bidirectional communication
53
- - **CLI and programmatic API** for flexible integration
57
+ - **Host-Client architecture** - Control remote environments from your local machine
58
+ - **Remote file operations** - read, write, delete, and list files on connected clients
59
+ - **Real-time command logging** - See incoming commands on the client console
60
+ - **WebSocket communication** with automatic reconnection
61
+ - **MCP integration** - Use remote bridge tools directly in Claude Code
62
+ - **Daemon mode** - Run the host bridge in the background
54
63
 
55
64
  ## Installation
56
65
 
@@ -85,72 +94,72 @@ npm link # Makes 'claude-bridge' available globally
85
94
 
86
95
  ## Quick Start
87
96
 
88
- ### Scenario 1: Start Bridge and Launch Claude Code
89
-
90
- The easiest way to get started - start the bridge and launch Claude Code in one command:
91
-
92
- **Step 1: Configure the MCP server (one-time setup)**
97
+ ### Step 1: Install
93
98
 
94
99
  ```bash
95
- claude mcp add remote-bridge -- npx @willjackson/claude-code-bridge mcp-server --connect ws://localhost:8766
100
+ npm install -g @willjackson/claude-code-bridge
96
101
  ```
97
102
 
98
- **Step 2: Start bridge and launch Claude Code**
103
+ ### Step 2: Configure MCP (one-time setup on host)
99
104
 
100
105
  ```bash
101
- claude-bridge start --port 8766 --launch-claude
106
+ claude mcp add remote-bridge -- npx @willjackson/claude-code-bridge mcp-server --connect ws://localhost:8766
102
107
  ```
103
108
 
104
- This starts the bridge daemon in the background and launches Claude Code with access to the remote bridge tools.
105
-
106
- ### Scenario 2: Mac to Remote Server
109
+ ### Step 3: Start the Host and Launch Claude Code
107
110
 
108
- **Step 1: Start the bridge on your Mac**
111
+ On your **local machine** (the host):
109
112
 
110
113
  ```bash
111
114
  claude-bridge start --port 8766 --launch-claude
112
115
  ```
113
116
 
114
- **Step 2: Start the bridge on the remote machine and connect**
117
+ This starts the bridge daemon and launches Claude Code with access to the remote bridge MCP tools.
118
+
119
+ **With Claude flags** (e.g., skip permissions):
115
120
 
116
121
  ```bash
117
- # On remote machine (replace YOUR_MAC_IP with actual IP)
118
- claude-bridge start --with-handlers --connect ws://YOUR_MAC_IP:8766
122
+ claude-bridge start --port 8766 --launch-claude -- --dangerously-skip-permissions
119
123
  ```
120
124
 
121
- Now Claude Code on your Mac can read/write files on the remote machine.
125
+ Any arguments after `--` are passed directly to the `claude` command.
122
126
 
123
- ### Scenario 3: Peer-to-Peer Mode
127
+ ### Step 4: Start the Client on Remote Machine
124
128
 
125
- Both instances can initiate communication:
126
-
127
- **Machine A:**
128
- ```bash
129
- claude-bridge start --port 8766
130
- ```
129
+ On the **remote machine** (server, container, VM):
131
130
 
132
- **Machine B:**
133
131
  ```bash
134
- claude-bridge start --port 8765 --connect ws://MACHINE_A_IP:8766
132
+ # Replace HOST_IP with your local machine's IP address
133
+ claude-bridge start --with-handlers --connect ws://HOST_IP:8766
135
134
  ```
136
135
 
137
- Once connected, either side can send context or delegate tasks to the other.
138
-
139
- ### Scenario 3: Remote File Operations
140
-
141
- Enable file operations on the remote to allow reading, writing, and deleting files:
136
+ The client will show incoming commands in the console:
142
137
 
143
- **Machine A (relay mode, no handlers):**
144
- ```bash
145
- claude-bridge start --port 8766
146
138
  ```
139
+ ┌─────────────────────────────────────────────────────────────
140
+ │ 📥 INCOMING TASK: Read config file
141
+ │ ID: task-123
142
+ │ Scope: execute
143
+ │ Action: read_file
144
+ │ Path: config/settings.json
145
+ └─────────────────────────────────────────────────────────────
147
146
 
148
- **Machine B (with file handlers):**
149
- ```bash
150
- claude-bridge start --with-handlers --connect ws://MACHINE_A_IP:8766
147
+ RESULT: Read 1234 chars from config/settings.json
151
148
  ```
152
149
 
153
- Now you can read, write, and edit files on Machine B from Machine A.
150
+ ### Available MCP Tools
151
+
152
+ Once connected, Claude Code on your host has access to these tools:
153
+
154
+ | Tool | Description |
155
+ |------|-------------|
156
+ | `bridge_read_file` | Read a file from the remote client |
157
+ | `bridge_write_file` | Write/create a file on the remote client |
158
+ | `bridge_delete_file` | Delete a file on the remote client |
159
+ | `bridge_list_directory` | List directory contents on the remote client |
160
+ | `bridge_delegate_task` | Delegate a custom task to the client |
161
+ | `bridge_request_context` | Request files matching a query |
162
+ | `bridge_status` | Check connection status |
154
163
 
155
164
  ## CLI Reference
156
165
 
@@ -171,7 +180,7 @@ Options:
171
180
  #### `start` - Start the Bridge Server
172
181
 
173
182
  ```bash
174
- claude-bridge start [options]
183
+ claude-bridge start [options] [-- claude-args...]
175
184
 
176
185
  Options:
177
186
  -p, --port <port> Port to listen on (default: 8765)
@@ -180,6 +189,8 @@ Options:
180
189
  -d, --daemon Run in background
181
190
  --with-handlers Enable file operations and task handling (read/write/delete files)
182
191
  --launch-claude Start bridge daemon and launch Claude Code
192
+
193
+ Arguments after -- are passed to the claude command when using --launch-claude.
183
194
  ```
184
195
 
185
196
  **Examples:**
@@ -188,19 +199,22 @@ Options:
188
199
  # Start bridge and launch Claude Code (recommended for local use)
189
200
  claude-bridge start --port 8766 --launch-claude
190
201
 
202
+ # Start bridge and launch Claude with --dangerously-skip-permissions
203
+ claude-bridge start --port 8766 --launch-claude -- --dangerously-skip-permissions
204
+
191
205
  # Start with default settings
192
206
  claude-bridge start
193
207
 
194
208
  # Start on specific port
195
209
  claude-bridge start --port 9000
196
210
 
197
- # Start and connect to remote bridge
198
- claude-bridge start --connect ws://192.168.1.100:8765
211
+ # Start and connect to host (client mode)
212
+ claude-bridge start --connect ws://192.168.1.100:8766
199
213
 
200
214
  # Start in daemon mode
201
215
  claude-bridge start --daemon
202
216
 
203
- # Start with file operation handlers enabled (for remote machines)
217
+ # Start with file operation handlers enabled (for remote/client machines)
204
218
  claude-bridge start --with-handlers --connect ws://192.168.1.100:8766
205
219
  ```
206
220
 
@@ -323,16 +337,16 @@ Create a configuration file at one of these locations:
323
337
  ```yaml
324
338
  # Instance identification
325
339
  instanceName: my-mac-desktop
326
- mode: peer # host, client, or peer
340
+ mode: host # 'host' for local machine, 'client' for remote
327
341
 
328
- # Server settings
342
+ # Server settings (host mode)
329
343
  listen:
330
344
  port: 8766
331
345
  host: 0.0.0.0
332
346
 
333
- # Connection to remote bridge
347
+ # Connection to host (client mode)
334
348
  connect:
335
- url: ws://localhost:8765
349
+ url: ws://192.168.1.100:8766
336
350
 
337
351
  # Context sharing settings
338
352
  contextSharing:
@@ -360,10 +374,10 @@ interaction:
360
374
  | Setting | Type | Default | Description |
361
375
  |---------|------|---------|-------------|
362
376
  | `instanceName` | string | - | Unique name for this bridge instance |
363
- | `mode` | string | - | Operation mode: `host`, `client`, or `peer` |
364
- | `listen.port` | number | 8765 | Port to listen on |
365
- | `listen.host` | string | 0.0.0.0 | Host to bind to |
366
- | `connect.url` | string | - | WebSocket URL of remote bridge |
377
+ | `mode` | string | - | Operation mode: `host` or `client` |
378
+ | `listen.port` | number | 8765 | Port to listen on (host mode) |
379
+ | `listen.host` | string | 0.0.0.0 | Host to bind to (host mode) |
380
+ | `connect.url` | string | - | WebSocket URL of host (client mode) |
367
381
  | `contextSharing.autoSync` | boolean | true | Automatically sync context |
368
382
  | `contextSharing.syncInterval` | number | 5000 | Sync interval in ms |
369
383
  | `contextSharing.maxChunkTokens` | number | 4000 | Max tokens per context chunk |
@@ -375,38 +389,50 @@ interaction:
375
389
 
376
390
  ## Programmatic Usage
377
391
 
378
- ### Basic Usage
392
+ ### Basic Usage (Host)
379
393
 
380
394
  ```typescript
381
395
  import { Bridge, BridgeConfig } from 'claude-code-bridge';
382
396
 
383
- // Create bridge configuration
397
+ // Create host bridge configuration
384
398
  const config: BridgeConfig = {
385
- mode: 'peer',
386
- instanceName: 'my-bridge',
387
- listen: { port: 8765, host: '0.0.0.0' },
388
- connect: { url: 'ws://localhost:8766' },
389
- contextSharing: {
390
- autoSync: true,
391
- syncInterval: 5000,
392
- maxChunkTokens: 4000,
393
- includePatterns: ['src/**/*.ts'],
394
- excludePatterns: ['node_modules/**'],
395
- },
396
- interaction: {
397
- requireConfirmation: false,
398
- notifyOnActivity: true,
399
- taskTimeout: 300000,
400
- },
399
+ mode: 'host',
400
+ instanceName: 'my-host',
401
+ listen: { port: 8766, host: '0.0.0.0' },
402
+ taskTimeout: 300000,
401
403
  };
402
404
 
403
405
  // Create and start bridge
404
406
  const bridge = new Bridge(config);
405
407
  await bridge.start();
406
408
 
407
- // Get connected peers
408
- const peers = bridge.getPeers();
409
- console.log('Connected peers:', peers);
409
+ // Get connected clients
410
+ const clients = bridge.getPeers();
411
+ console.log('Connected clients:', clients);
412
+ ```
413
+
414
+ ### Basic Usage (Client)
415
+
416
+ ```typescript
417
+ import { Bridge, BridgeConfig } from 'claude-code-bridge';
418
+
419
+ // Create client bridge configuration
420
+ const config: BridgeConfig = {
421
+ mode: 'client',
422
+ instanceName: 'my-client',
423
+ connect: { url: 'ws://192.168.1.100:8766' },
424
+ };
425
+
426
+ // Create and start bridge
427
+ const bridge = new Bridge(config);
428
+ await bridge.start();
429
+
430
+ // Register task handler for file operations
431
+ bridge.onTaskReceived(async (task, peerId) => {
432
+ console.log('Received task:', task.description);
433
+ // Handle the task...
434
+ return { success: true, data: { message: 'Done' } };
435
+ });
410
436
  ```
411
437
 
412
438
  ### Context Synchronization
@@ -573,21 +599,28 @@ for (const change of delta.changes) {
573
599
 
574
600
  ### Connection Issues
575
601
 
576
- **Problem:** Cannot connect to bridge from remote machine
602
+ **Problem:** Client cannot connect to host
577
603
 
578
604
  **Solutions:**
579
605
  1. Ensure the host bridge is running: `claude-bridge status`
580
- 2. Check firewall settings allow the port
581
- 3. Verify the IP address is correct and reachable: `ping MACHINE_IP`
582
- 4. Try using the full URL: `claude-bridge connect ws://192.168.1.100:8766`
606
+ 2. Check firewall settings allow the port (default: 8766)
607
+ 3. Verify the IP address is correct and reachable: `ping HOST_IP`
608
+ 4. Ensure you're using the correct WebSocket URL format: `ws://HOST_IP:8766`
583
609
 
584
610
  **Problem:** Connection keeps dropping
585
611
 
586
612
  **Solutions:**
587
- 1. Check network stability
613
+ 1. Check network stability between host and client
588
614
  2. Increase timeout settings in config
589
615
  3. Enable verbose logging: `claude-bridge start -v`
590
616
 
617
+ **Problem:** Commands not showing on client
618
+
619
+ **Solutions:**
620
+ 1. Ensure client is started with `--with-handlers` flag
621
+ 2. Check the client console for connection status
622
+ 3. Verify the host shows the client as connected: `claude-bridge status`
623
+
591
624
  ### Port Conflicts
592
625
 
593
626
  **Problem:** Port already in use
@@ -688,15 +688,11 @@ var Bridge = class {
688
688
  if (mode === "client" && !connect) {
689
689
  throw new Error("'client' mode requires 'connect' configuration");
690
690
  }
691
- if (mode === "peer" && !listen && !connect) {
692
- throw new Error("'peer' mode requires either 'listen' or 'connect' configuration (or both)");
693
- }
694
691
  }
695
692
  /**
696
693
  * Start the bridge based on configured mode
697
- * - 'host': Starts WebSocket server
698
- * - 'client': Connects to remote bridge
699
- * - 'peer': Both starts server and connects to remote
694
+ * - 'host': Starts WebSocket server, sends commands via MCP
695
+ * - 'client': Connects to host, receives and executes commands
700
696
  */
701
697
  async start() {
702
698
  if (this.started) {
@@ -705,10 +701,10 @@ var Bridge = class {
705
701
  const { mode } = this.config;
706
702
  logger2.info({ mode }, "Starting bridge");
707
703
  try {
708
- if ((mode === "host" || mode === "peer") && this.config.listen) {
704
+ if (mode === "host" && this.config.listen) {
709
705
  await this.startServer();
710
706
  }
711
- if ((mode === "client" || mode === "peer") && this.config.connect) {
707
+ if (mode === "client" && this.config.connect) {
712
708
  await this.connectToRemote();
713
709
  }
714
710
  this.started = true;
@@ -2151,4 +2147,4 @@ export {
2151
2147
  BridgeMcpServer,
2152
2148
  startMcpServer
2153
2149
  };
2154
- //# sourceMappingURL=chunk-MHUQYPTB.js.map
2150
+ //# sourceMappingURL=chunk-XOAR3DQB.js.map