@willjackson/claude-code-bridge 0.5.1 → 0.6.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/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,64 @@ 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**
115
-
116
- ```bash
117
- # On remote machine (replace YOUR_MAC_IP with actual IP)
118
- claude-bridge start --with-handlers --connect ws://YOUR_MAC_IP:8766
119
- ```
120
-
121
- Now Claude Code on your Mac can read/write files on the remote machine.
117
+ This starts the bridge daemon and launches Claude Code with access to the remote bridge MCP tools.
122
118
 
123
- ### Scenario 3: Peer-to-Peer Mode
119
+ ### Step 4: Start the Client on Remote Machine
124
120
 
125
- Both instances can initiate communication:
121
+ On the **remote machine** (server, container, VM):
126
122
 
127
- **Machine A:**
128
123
  ```bash
129
- claude-bridge start --port 8766
124
+ # Replace HOST_IP with your local machine's IP address
125
+ claude-bridge start --with-handlers --connect ws://HOST_IP:8766
130
126
  ```
131
127
 
132
- **Machine B:**
133
- ```bash
134
- claude-bridge start --port 8765 --connect ws://MACHINE_A_IP:8766
135
- ```
136
-
137
- Once connected, either side can send context or delegate tasks to the other.
138
-
139
- ### Scenario 3: Remote File Operations
128
+ The client will show incoming commands in the console:
140
129
 
141
- Enable file operations on the remote to allow reading, writing, and deleting files:
142
-
143
- **Machine A (relay mode, no handlers):**
144
- ```bash
145
- claude-bridge start --port 8766
146
130
  ```
131
+ ┌─────────────────────────────────────────────────────────────
132
+ │ 📥 INCOMING TASK: Read config file
133
+ │ ID: task-123
134
+ │ Scope: execute
135
+ │ Action: read_file
136
+ │ Path: config/settings.json
137
+ └─────────────────────────────────────────────────────────────
147
138
 
148
- **Machine B (with file handlers):**
149
- ```bash
150
- claude-bridge start --with-handlers --connect ws://MACHINE_A_IP:8766
139
+ RESULT: Read 1234 chars from config/settings.json
151
140
  ```
152
141
 
153
- Now you can read, write, and edit files on Machine B from Machine A.
142
+ ### Available MCP Tools
143
+
144
+ Once connected, Claude Code on your host has access to these tools:
145
+
146
+ | Tool | Description |
147
+ |------|-------------|
148
+ | `bridge_read_file` | Read a file from the remote client |
149
+ | `bridge_write_file` | Write/create a file on the remote client |
150
+ | `bridge_delete_file` | Delete a file on the remote client |
151
+ | `bridge_list_directory` | List directory contents on the remote client |
152
+ | `bridge_delegate_task` | Delegate a custom task to the client |
153
+ | `bridge_request_context` | Request files matching a query |
154
+ | `bridge_status` | Check connection status |
154
155
 
155
156
  ## CLI Reference
156
157
 
@@ -323,16 +324,16 @@ Create a configuration file at one of these locations:
323
324
  ```yaml
324
325
  # Instance identification
325
326
  instanceName: my-mac-desktop
326
- mode: peer # host, client, or peer
327
+ mode: host # 'host' for local machine, 'client' for remote
327
328
 
328
- # Server settings
329
+ # Server settings (host mode)
329
330
  listen:
330
331
  port: 8766
331
332
  host: 0.0.0.0
332
333
 
333
- # Connection to remote bridge
334
+ # Connection to host (client mode)
334
335
  connect:
335
- url: ws://localhost:8765
336
+ url: ws://192.168.1.100:8766
336
337
 
337
338
  # Context sharing settings
338
339
  contextSharing:
@@ -360,10 +361,10 @@ interaction:
360
361
  | Setting | Type | Default | Description |
361
362
  |---------|------|---------|-------------|
362
363
  | `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 |
364
+ | `mode` | string | - | Operation mode: `host` or `client` |
365
+ | `listen.port` | number | 8765 | Port to listen on (host mode) |
366
+ | `listen.host` | string | 0.0.0.0 | Host to bind to (host mode) |
367
+ | `connect.url` | string | - | WebSocket URL of host (client mode) |
367
368
  | `contextSharing.autoSync` | boolean | true | Automatically sync context |
368
369
  | `contextSharing.syncInterval` | number | 5000 | Sync interval in ms |
369
370
  | `contextSharing.maxChunkTokens` | number | 4000 | Max tokens per context chunk |
@@ -375,38 +376,50 @@ interaction:
375
376
 
376
377
  ## Programmatic Usage
377
378
 
378
- ### Basic Usage
379
+ ### Basic Usage (Host)
379
380
 
380
381
  ```typescript
381
382
  import { Bridge, BridgeConfig } from 'claude-code-bridge';
382
383
 
383
- // Create bridge configuration
384
+ // Create host bridge configuration
384
385
  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
- },
386
+ mode: 'host',
387
+ instanceName: 'my-host',
388
+ listen: { port: 8766, host: '0.0.0.0' },
389
+ taskTimeout: 300000,
390
+ };
391
+
392
+ // Create and start bridge
393
+ const bridge = new Bridge(config);
394
+ await bridge.start();
395
+
396
+ // Get connected clients
397
+ const clients = bridge.getPeers();
398
+ console.log('Connected clients:', clients);
399
+ ```
400
+
401
+ ### Basic Usage (Client)
402
+
403
+ ```typescript
404
+ import { Bridge, BridgeConfig } from 'claude-code-bridge';
405
+
406
+ // Create client bridge configuration
407
+ const config: BridgeConfig = {
408
+ mode: 'client',
409
+ instanceName: 'my-client',
410
+ connect: { url: 'ws://192.168.1.100:8766' },
401
411
  };
402
412
 
403
413
  // Create and start bridge
404
414
  const bridge = new Bridge(config);
405
415
  await bridge.start();
406
416
 
407
- // Get connected peers
408
- const peers = bridge.getPeers();
409
- console.log('Connected peers:', peers);
417
+ // Register task handler for file operations
418
+ bridge.onTaskReceived(async (task, peerId) => {
419
+ console.log('Received task:', task.description);
420
+ // Handle the task...
421
+ return { success: true, data: { message: 'Done' } };
422
+ });
410
423
  ```
411
424
 
412
425
  ### Context Synchronization
@@ -573,21 +586,28 @@ for (const change of delta.changes) {
573
586
 
574
587
  ### Connection Issues
575
588
 
576
- **Problem:** Cannot connect to bridge from remote machine
589
+ **Problem:** Client cannot connect to host
577
590
 
578
591
  **Solutions:**
579
592
  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`
593
+ 2. Check firewall settings allow the port (default: 8766)
594
+ 3. Verify the IP address is correct and reachable: `ping HOST_IP`
595
+ 4. Ensure you're using the correct WebSocket URL format: `ws://HOST_IP:8766`
583
596
 
584
597
  **Problem:** Connection keeps dropping
585
598
 
586
599
  **Solutions:**
587
- 1. Check network stability
600
+ 1. Check network stability between host and client
588
601
  2. Increase timeout settings in config
589
602
  3. Enable verbose logging: `claude-bridge start -v`
590
603
 
604
+ **Problem:** Commands not showing on client
605
+
606
+ **Solutions:**
607
+ 1. Ensure client is started with `--with-handlers` flag
608
+ 2. Check the client console for connection status
609
+ 3. Verify the host shows the client as connected: `claude-bridge status`
610
+
591
611
  ### Port Conflicts
592
612
 
593
613
  **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