JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 670
  • Score
    100M100P100Q96799F
  • License MIT

Centralized, runtime-agnostic library for real-time collaboration and synchronization

Package Exports

  • @principal-ai/control-tower-core

Readme

Control Tower Core

Centralized, runtime-agnostic library for real-time collaboration and synchronization.

Installation

npm install @principal-ai/control-tower-core

Quick Start

import {
  ServerBuilder,
  DefaultRoomManager,
  DefaultLockManager,
  MockTransportAdapter
} from '@principal-ai/control-tower-core';

// Create a server with default implementations
const server = new ServerBuilder()
  .withTransport(new MockTransportAdapter())
  .withRoomManager(new DefaultRoomManager())
  .withLockManager(new DefaultLockManager())
  .build();

await server.start(8080);
console.log('Server started on port 8080');

Features

  • Room Management: Create, join, and manage collaborative rooms
  • Lock Management: File/directory locking with queue support
  • Real-time Events: Event broadcasting and history
  • Extensible: Abstract interfaces for custom implementations
  • TypeScript: Full type safety with generated declarations

API Reference

ServerBuilder

The main entry point for creating servers:

const server = new ServerBuilder()
  .withTransport(transportAdapter)
  .withRoomManager(roomManager)
  .withLockManager(lockManager)
  .withAuth(authAdapter) // optional
  .withStorage(storageAdapter) // optional
  .withDefaultRoomConfig({
    maxUsers: 50,
    maxHistory: 100,
    permissions: ['read', 'write']
  })
  .build();

Default Implementations

  • DefaultRoomManager: In-memory room management
  • DefaultLockManager: In-memory locking with queue support
  • MockTransportAdapter: Mock transport for testing

Custom Implementations

Implement the abstract interfaces to create custom adapters:

import { RoomManager } from '@principal-ai/control-tower-core';

class CustomRoomManager extends RoomManager {
  async createRoom(id: string, config: RoomConfig): Promise<Room> {
    // Your implementation
  }
  // ... implement other methods
}

License

MIT