@willjackson/claude-code-bridge 0.2.4 → 0.3.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/dist/index.d.ts CHANGED
@@ -1306,84 +1306,6 @@ declare class WebSocketTransport implements Transport {
1306
1306
  getReconnectAttempts(): number;
1307
1307
  }
1308
1308
 
1309
- /**
1310
- * Peer Discovery Module
1311
- *
1312
- * Provides functions to discover bridge-enabled Docker containers
1313
- * and development environment projects.
1314
- */
1315
- /**
1316
- * Discovered peer information
1317
- */
1318
- interface DiscoveredPeer {
1319
- name: string;
1320
- source: 'docker' | 'docksal' | 'ddev' | 'lando';
1321
- url: string;
1322
- containerId?: string;
1323
- status?: string;
1324
- }
1325
- /**
1326
- * Bridge label configuration parsed from Docker container labels
1327
- */
1328
- interface BridgeLabelConfig {
1329
- enabled: boolean;
1330
- port?: number;
1331
- name?: string;
1332
- }
1333
- /**
1334
- * Parse Docker container labels to extract bridge configuration
1335
- *
1336
- * @param labels - Comma-separated label string from Docker
1337
- * @returns Parsed bridge configuration or null if bridge not enabled
1338
- */
1339
- declare function parseDockerLabels(labels: string): BridgeLabelConfig | null;
1340
- /**
1341
- * Check if Docker daemon is available and running
1342
- */
1343
- declare function isDockerAvailable(): boolean;
1344
- /**
1345
- * Discover Docker containers with bridge labels
1346
- *
1347
- * Searches for running containers that have the claude.bridge.enabled=true label
1348
- * and extracts connection information from their labels.
1349
- *
1350
- * @returns Array of discovered peers with connection URLs
1351
- */
1352
- declare function discoverDockerPeers(): DiscoveredPeer[];
1353
- /**
1354
- * Discover Docksal projects with bridges
1355
- *
1356
- * Uses the `fin project list` command to find running Docksal projects.
1357
- *
1358
- * @returns Array of discovered peers with connection URLs
1359
- */
1360
- declare function discoverDocksalProjects(): DiscoveredPeer[];
1361
- /**
1362
- * Discover DDEV projects with bridges
1363
- *
1364
- * Uses the `ddev list` command to find running DDEV projects.
1365
- *
1366
- * @returns Array of discovered peers with connection URLs
1367
- */
1368
- declare function discoverDdevProjects(): DiscoveredPeer[];
1369
- /**
1370
- * Discover Lando projects with bridges
1371
- *
1372
- * Uses the `lando list` command to find running Lando apps.
1373
- *
1374
- * @returns Array of discovered peers with connection URLs
1375
- */
1376
- declare function discoverLandoProjects(): DiscoveredPeer[];
1377
- /**
1378
- * Discover all peers from all sources
1379
- *
1380
- * Aggregates peers from Docker containers and all supported development
1381
- * environments (Docksal, DDEV, Lando).
1382
- *
1383
- * @returns Array of all discovered peers
1384
- */
1385
- declare function discoverAllPeers(): DiscoveredPeer[];
1386
-
1387
1309
  /**
1388
1310
  * Transport module exports
1389
1311
  */
@@ -1405,6 +1327,38 @@ interface CreateTransportOptions {
1405
1327
  */
1406
1328
  declare function createTransport(type: TransportType, options?: CreateTransportOptions): Transport;
1407
1329
 
1330
+ /**
1331
+ * Log levels supported by the logger
1332
+ */
1333
+ type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
1334
+ /**
1335
+ * Logger interface (subset of pino.Logger for public API)
1336
+ */
1337
+ type Logger = pino.Logger;
1338
+ /**
1339
+ * Creates a logger instance with the given component name
1340
+ *
1341
+ * @param name - Component name to include in log output
1342
+ * @param level - Optional log level override (defaults to LOG_LEVEL env var or 'info')
1343
+ * @returns A pino logger instance configured for the component
1344
+ *
1345
+ * @example
1346
+ * ```typescript
1347
+ * const logger = createLogger('bridge');
1348
+ * logger.info('Bridge started');
1349
+ * logger.error({ err }, 'Connection failed');
1350
+ * ```
1351
+ */
1352
+ declare function createLogger(name: string, level?: LogLevel): Logger;
1353
+ /**
1354
+ * Creates a child logger from an existing logger with additional context
1355
+ *
1356
+ * @param parent - Parent logger instance
1357
+ * @param bindings - Additional context to include in all log messages
1358
+ * @returns A child logger instance
1359
+ */
1360
+ declare function createChildLogger(parent: Logger, bindings: Record<string, unknown>): Logger;
1361
+
1408
1362
  /**
1409
1363
  * Configuration for the bridge's listening socket
1410
1364
  */
@@ -1489,214 +1443,6 @@ declare function loadConfig(configPath?: string): Promise<BridgeConfig>;
1489
1443
  */
1490
1444
  declare function loadConfigSync(configPath?: string): BridgeConfig;
1491
1445
 
1492
- /**
1493
- * Environment detection utilities for Claude Code Bridge
1494
- *
1495
- * Detects the runtime environment (Docksal, DDEV, Lando, Docker, or native)
1496
- * and provides appropriate configuration defaults.
1497
- */
1498
-
1499
- /**
1500
- * Supported Docker environment types
1501
- */
1502
- type DockerEnvironment = 'docksal' | 'ddev' | 'lando' | 'docker-compose' | 'docker' | 'native';
1503
- /**
1504
- * Information about the detected runtime environment
1505
- */
1506
- interface EnvironmentInfo {
1507
- /** The type of environment detected */
1508
- type: DockerEnvironment;
1509
- /** Whether running inside a container */
1510
- isContainer: boolean;
1511
- /** Project name (if applicable) */
1512
- projectName?: string;
1513
- /** Project root path (if applicable) */
1514
- projectRoot?: string;
1515
- /** Host gateway address for container-to-host communication */
1516
- hostGateway?: string;
1517
- /** Operating system platform */
1518
- platform: NodeJS.Platform;
1519
- /** Additional environment-specific metadata */
1520
- meta?: Record<string, string>;
1521
- }
1522
- /**
1523
- * Detect the current runtime environment
1524
- *
1525
- * Detection order (first match wins):
1526
- * 1. Docksal (DOCKSAL_STACK env var)
1527
- * 2. DDEV (IS_DDEV_PROJECT=true env var)
1528
- * 3. Lando (LANDO=ON env var)
1529
- * 4. Docker Compose (COMPOSE_PROJECT_NAME env var)
1530
- * 5. Generic Docker (/.dockerenv file exists)
1531
- * 6. Native (fallback)
1532
- *
1533
- * @returns EnvironmentInfo object with detected environment details
1534
- */
1535
- declare function detectEnvironment(): EnvironmentInfo;
1536
- /**
1537
- * Get the host gateway address for container-to-host communication
1538
- *
1539
- * - macOS and Windows: Use host.docker.internal (provided by Docker Desktop)
1540
- * - Linux: May need to use bridge gateway IP or host-gateway flag
1541
- *
1542
- * @returns The hostname or IP to reach the Docker host from inside a container
1543
- */
1544
- declare function getHostGateway(): string;
1545
- /**
1546
- * Get default bridge configuration based on the detected environment
1547
- *
1548
- * Different environments may have different port defaults or connection
1549
- * preferences.
1550
- *
1551
- * @param env - The detected environment info
1552
- * @returns Partial BridgeConfig with environment-specific defaults
1553
- */
1554
- declare function getDefaultConfig(env: EnvironmentInfo): Partial<BridgeConfig>;
1555
-
1556
- /**
1557
- * Docksal-specific helper functions for Claude Code Bridge
1558
- *
1559
- * Provides utilities to extract project information from the Docksal environment.
1560
- * Docksal is a Docker-based development environment primarily used for
1561
- * Drupal and other PHP projects.
1562
- *
1563
- * @see https://docksal.io/
1564
- */
1565
- /**
1566
- * Information about a Docksal project
1567
- */
1568
- interface DocksalProjectInfo {
1569
- /** Project name from DOCKSAL_PROJECT env var */
1570
- projectName: string;
1571
- /** Project root path from PROJECT_ROOT env var */
1572
- projectRoot: string;
1573
- /** Docksal stack name from DOCKSAL_STACK env var */
1574
- stack: string;
1575
- }
1576
- /**
1577
- * Get Docksal project information from environment variables
1578
- *
1579
- * Extracts project details from the standard Docksal environment variables:
1580
- * - DOCKSAL_PROJECT: The project name
1581
- * - PROJECT_ROOT: The project root directory
1582
- * - DOCKSAL_STACK: The Docksal stack being used (e.g., 'default', 'acquia')
1583
- *
1584
- * @returns DocksalProjectInfo if in Docksal environment, null otherwise
1585
- *
1586
- * @example
1587
- * ```typescript
1588
- * const info = getDocksalProjectInfo();
1589
- * if (info) {
1590
- * console.log(`Project: ${info.projectName}`);
1591
- * console.log(`Root: ${info.projectRoot}`);
1592
- * console.log(`Stack: ${info.stack}`);
1593
- * }
1594
- * ```
1595
- */
1596
- declare function getDocksalProjectInfo(): DocksalProjectInfo | null;
1597
-
1598
- /**
1599
- * DDEV-specific helper functions for Claude Code Bridge
1600
- *
1601
- * Provides utilities to extract project information from the DDEV environment.
1602
- * DDEV is a Docker-based development environment for PHP and other projects.
1603
- *
1604
- * @see https://ddev.readthedocs.io/
1605
- */
1606
- /**
1607
- * Information about a DDEV project
1608
- */
1609
- interface DdevProjectInfo {
1610
- /** Project name from DDEV_PROJECT env var */
1611
- projectName: string;
1612
- /** Project document root from DDEV_DOCROOT env var */
1613
- projectRoot: string;
1614
- }
1615
- /**
1616
- * Get DDEV project information from environment variables
1617
- *
1618
- * Extracts project details from the standard DDEV environment variables:
1619
- * - DDEV_PROJECT: The project name
1620
- * - DDEV_DOCROOT: The document root directory (web root)
1621
- *
1622
- * @returns DdevProjectInfo if in DDEV environment, null otherwise
1623
- *
1624
- * @example
1625
- * ```typescript
1626
- * const info = getDdevProjectInfo();
1627
- * if (info) {
1628
- * console.log(`Project: ${info.projectName}`);
1629
- * console.log(`Root: ${info.projectRoot}`);
1630
- * }
1631
- * ```
1632
- */
1633
- declare function getDdevProjectInfo(): DdevProjectInfo | null;
1634
-
1635
- /**
1636
- * Lando-specific helper functions for Claude Code Bridge
1637
- *
1638
- * Provides utilities to extract project information from the Lando environment.
1639
- * Lando is a Docker-based development environment for PHP, Node.js, and other projects.
1640
- *
1641
- * @see https://docs.lando.dev/
1642
- */
1643
- /**
1644
- * Information about a Lando project
1645
- */
1646
- interface LandoProjectInfo {
1647
- /** Project name (app name) from LANDO_APP_NAME env var */
1648
- projectName: string;
1649
- }
1650
- /**
1651
- * Get Lando project information from environment variables
1652
- *
1653
- * Extracts project details from the standard Lando environment variables:
1654
- * - LANDO_APP_NAME: The application/project name
1655
- *
1656
- * @returns LandoProjectInfo if in Lando environment, null otherwise
1657
- *
1658
- * @example
1659
- * ```typescript
1660
- * const info = getLandoProjectInfo();
1661
- * if (info) {
1662
- * console.log(`Project: ${info.projectName}`);
1663
- * }
1664
- * ```
1665
- */
1666
- declare function getLandoProjectInfo(): LandoProjectInfo | null;
1667
-
1668
- /**
1669
- * Log levels supported by the logger
1670
- */
1671
- type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
1672
- /**
1673
- * Logger interface (subset of pino.Logger for public API)
1674
- */
1675
- type Logger = pino.Logger;
1676
- /**
1677
- * Creates a logger instance with the given component name
1678
- *
1679
- * @param name - Component name to include in log output
1680
- * @param level - Optional log level override (defaults to LOG_LEVEL env var or 'info')
1681
- * @returns A pino logger instance configured for the component
1682
- *
1683
- * @example
1684
- * ```typescript
1685
- * const logger = createLogger('bridge');
1686
- * logger.info('Bridge started');
1687
- * logger.error({ err }, 'Connection failed');
1688
- * ```
1689
- */
1690
- declare function createLogger(name: string, level?: LogLevel): Logger;
1691
- /**
1692
- * Creates a child logger from an existing logger with additional context
1693
- *
1694
- * @param parent - Parent logger instance
1695
- * @param bindings - Additional context to include in all log messages
1696
- * @returns A child logger instance
1697
- */
1698
- declare function createChildLogger(parent: Logger, bindings: Record<string, unknown>): Logger;
1699
-
1700
1446
  /**
1701
1447
  * Token counting utilities for context chunking.
1702
1448
  * Uses word-based approximation since exact token counting requires
@@ -1864,12 +1610,11 @@ declare function isErrorCode(error: unknown, code: ErrorCode): boolean;
1864
1610
  * Claude Code Bridge
1865
1611
  *
1866
1612
  * A bidirectional communication system that enables two separate Claude Code instances
1867
- * to collaborate across different environments. The primary use case is connecting a
1868
- * native macOS Claude Code instance with a Claude Code instance running inside a
1869
- * Docker-based development environment (Docksal, DDEV, Lando, or plain Docker).
1613
+ * to collaborate across different environments. Connect instances running on different
1614
+ * machines, containers, or networks via WebSocket.
1870
1615
  *
1871
1616
  * @packageDocumentation
1872
1617
  */
1873
1618
  declare const VERSION = "0.1.0";
1874
1619
 
1875
- export { type Artifact, ArtifactSchema, Bridge, type BridgeConfig$1 as BridgeConfig, type BridgeConnectConfig, BridgeError, type BridgeLabelConfig, BridgeLifecycleError, type BridgeListenConfig, type BridgeMessage, BridgeMessageSchema, type BridgeMode, type BuildDirectoryTreeOptions, ConfigurationError, type ConnectConfig, type ConnectionConfig, ConnectionError, ConnectionState, type Context, type ContextDelta, ContextError, ContextManager, type ContextManagerOptions, type ContextReceivedHandler, type ContextRequestedHandler, ContextSchema, type ContextSharingConfig$1 as ContextSharingConfig, DEFAULT_CONFIG, type DdevProjectInfo, type DirectoryTree, DirectoryTreeSchema, type DiscoveredPeer, type DockerEnvironment, type DocksalProjectInfo, type EnvironmentInfo, type ErrorCode, ErrorCodes, type FileChange, type FileChunk, FileChunkSchema, type InteractionConfig, type LandoProjectInfo, type ListenConfig, type LogLevel, type Logger, type MessageReceivedHandler, MessageType, type NotificationData, type PeerConnectedHandler, type PeerDisconnectedHandler, PeerError, type PeerInfo, type ProjectSnapshot, ProtocolError, TaskError, type TaskReceivedHandler, type TaskRequest, TaskRequestSchema, type TaskResult, TaskResultSchema, type Transport, type BridgeConfig as UtilsBridgeConfig, type ContextSharingConfig as UtilsContextSharingConfig, VERSION, WebSocketTransport, buildDirectoryTree, createChildLogger, createContextRequestMessage, createContextSyncMessage, createLogger, createMessage, createNotificationMessage, createTaskDelegateMessage, createTaskResponseMessage, createTransport, deserializeMessage, detectEnvironment, discoverAllPeers, discoverDdevProjects, discoverDockerPeers, discoverDocksalProjects, discoverLandoProjects, estimateTokens, formatErrorForLogging, getDdevProjectInfo, getDefaultConfig, getDocksalProjectInfo, getHostGateway, getLandoProjectInfo, isDockerAvailable, isErrorCode, loadConfig, loadConfigSync, mergeConfig, parseDockerLabels, safeDeserializeMessage, safeValidateMessage, serializeMessage, truncateToTokenLimit, validateMessage, wrapError };
1620
+ export { type Artifact, ArtifactSchema, Bridge, type BridgeConfig$1 as BridgeConfig, type BridgeConnectConfig, BridgeError, BridgeLifecycleError, type BridgeListenConfig, type BridgeMessage, BridgeMessageSchema, type BridgeMode, type BuildDirectoryTreeOptions, ConfigurationError, type ConnectConfig, type ConnectionConfig, ConnectionError, ConnectionState, type Context, type ContextDelta, ContextError, ContextManager, type ContextManagerOptions, type ContextReceivedHandler, type ContextRequestedHandler, ContextSchema, type ContextSharingConfig$1 as ContextSharingConfig, DEFAULT_CONFIG, type DirectoryTree, DirectoryTreeSchema, type ErrorCode, ErrorCodes, type FileChange, type FileChunk, FileChunkSchema, type InteractionConfig, type ListenConfig, type LogLevel, type Logger, type MessageReceivedHandler, MessageType, type NotificationData, type PeerConnectedHandler, type PeerDisconnectedHandler, PeerError, type PeerInfo, type ProjectSnapshot, ProtocolError, TaskError, type TaskReceivedHandler, type TaskRequest, TaskRequestSchema, type TaskResult, TaskResultSchema, type Transport, type BridgeConfig as UtilsBridgeConfig, type ContextSharingConfig as UtilsContextSharingConfig, VERSION, WebSocketTransport, buildDirectoryTree, createChildLogger, createContextRequestMessage, createContextSyncMessage, createLogger, createMessage, createNotificationMessage, createTaskDelegateMessage, createTaskResponseMessage, createTransport, deserializeMessage, estimateTokens, formatErrorForLogging, isErrorCode, loadConfig, loadConfigSync, mergeConfig, safeDeserializeMessage, safeValidateMessage, serializeMessage, truncateToTokenLimit, validateMessage, wrapError };
package/dist/index.js CHANGED
@@ -20,24 +20,14 @@ import {
20
20
  createTaskDelegateMessage,
21
21
  createTaskResponseMessage,
22
22
  deserializeMessage,
23
- detectEnvironment,
24
- discoverAllPeers,
25
- discoverDdevProjects,
26
- discoverDockerPeers,
27
- discoverDocksalProjects,
28
- discoverLandoProjects,
29
- getDefaultConfig,
30
- getHostGateway,
31
- isDockerAvailable,
32
23
  loadConfig,
33
24
  loadConfigSync,
34
25
  mergeConfig,
35
- parseDockerLabels,
36
26
  safeDeserializeMessage,
37
27
  safeValidateMessage,
38
28
  serializeMessage,
39
29
  validateMessage
40
- } from "./chunk-5HWFDZKH.js";
30
+ } from "./chunk-LUL3SX2F.js";
41
31
 
42
32
  // src/bridge/context.ts
43
33
  import { readdirSync, readFileSync, statSync, realpathSync } from "fs";
@@ -546,63 +536,6 @@ function createTransport(type, options) {
546
536
  }
547
537
  }
548
538
 
549
- // src/environment/docksal.ts
550
- function isDocksalEnvironment() {
551
- return !!process.env.DOCKSAL_STACK;
552
- }
553
- function getDocksalProjectInfo() {
554
- if (!isDocksalEnvironment()) {
555
- return null;
556
- }
557
- const projectName = process.env.DOCKSAL_PROJECT;
558
- const projectRoot = process.env.PROJECT_ROOT;
559
- const stack = process.env.DOCKSAL_STACK;
560
- if (!projectName || !projectRoot || !stack) {
561
- return null;
562
- }
563
- return {
564
- projectName,
565
- projectRoot,
566
- stack
567
- };
568
- }
569
-
570
- // src/environment/ddev.ts
571
- function isDdevEnvironment() {
572
- return process.env.IS_DDEV_PROJECT === "true";
573
- }
574
- function getDdevProjectInfo() {
575
- if (!isDdevEnvironment()) {
576
- return null;
577
- }
578
- const projectName = process.env.DDEV_PROJECT;
579
- const projectRoot = process.env.DDEV_DOCROOT;
580
- if (!projectName || !projectRoot) {
581
- return null;
582
- }
583
- return {
584
- projectName,
585
- projectRoot
586
- };
587
- }
588
-
589
- // src/environment/lando.ts
590
- function isLandoEnvironment() {
591
- return process.env.LANDO === "ON";
592
- }
593
- function getLandoProjectInfo() {
594
- if (!isLandoEnvironment()) {
595
- return null;
596
- }
597
- const projectName = process.env.LANDO_APP_NAME;
598
- if (!projectName) {
599
- return null;
600
- }
601
- return {
602
- projectName
603
- };
604
- }
605
-
606
539
  // src/utils/errors.ts
607
540
  var BridgeError = class extends Error {
608
541
  code;
@@ -947,25 +880,12 @@ export {
947
880
  createTaskResponseMessage,
948
881
  createTransport,
949
882
  deserializeMessage,
950
- detectEnvironment,
951
- discoverAllPeers,
952
- discoverDdevProjects,
953
- discoverDockerPeers,
954
- discoverDocksalProjects,
955
- discoverLandoProjects,
956
883
  estimateTokens,
957
884
  formatErrorForLogging,
958
- getDdevProjectInfo,
959
- getDefaultConfig,
960
- getDocksalProjectInfo,
961
- getHostGateway,
962
- getLandoProjectInfo,
963
- isDockerAvailable,
964
885
  isErrorCode,
965
886
  loadConfig,
966
887
  loadConfigSync,
967
888
  mergeConfig,
968
- parseDockerLabels,
969
889
  safeDeserializeMessage,
970
890
  safeValidateMessage,
971
891
  serializeMessage,