NTM (Named Tmux Manager)

repository·main·Indexed 19 days ago

https://github.com/dicklesworthstone/ntm

A local control plane for multi-agent software development that extends tmux to provide session orchestration, work triage, and safety policies. NTM enables human-agent coordination through features like agent swarms (supporting Claude Code, Codex, Antigravity, and Grok Build), work graph integration with Beads (br/bv), recoverable checkpoints, and a local REST/WebSocket API for machine-readable automation.

Tokens
210.3K
Snippets
466
Records
695
Agent score
64%

What's inside ntm

  1. What is NTM (Named Tmux Manager)?

    main

    NTM is a Go CLI tool designed to orchestrate multiple AI coding agents (such as Claude Code, OpenAI Codex, and Gemini CLI) within tmux sessions. It transforms tmux into a multi-agent command center by providing:

    • Session Orchestration: Creates predictable tmux pane grids with deterministic naming (e.g., myproj__cc_1).
    • Multi-agent Control: Spawns and manages agents across panes, allowing users to send prompts to specific types (using --cc, --cod, or --gmi flags) or all agents simultaneously.
    • Rich UX: Includes an interactive dashboard, command palette, and output capture tools (copy, save, grep, diff, extract).
    • Automation: Provides a machine-readable "robot mode" via --robot-* flags that return structured JSON.
    • Ecosystem Integration: Works with Agent Mail (messaging/locks), Beads/bv (planning), and cass/cm (memory/search).
  2. What is NTM (Neural Terminal Manager)?

    main

    NTM is a Go-based command-line tool designed to orchestrate multiple AI coding agents (such as Claude Code, Codex CLI, and Gemini CLI) in parallel within tmux sessions. It acts as a 'cockpit' or orchestration layer, allowing developers to manage agent workloads, monitor status, and coordinate work distribution.

    Core Capabilities

    • Spawn sessions: Create tmux sessions with specific counts of different agent types.
    • List sessions: View all active NTM sessions and their agent counts.
    • Monitor status: Use a real-time TUI to see agent states (idle, working, error, waiting for input).
    • Robot output: Generate JSON output for programmatic integration with other tools.
    • Kill sessions: Terminate a session and all associated agents.
    • Dashboard: (Planned) Web-based monitoring.
    # Example: Spawn a session with 3 Claude agents and 2 Codex agents
    ntm spawn myproject --cc=3 --cod=2
    
    # Example: List active sessions
    ntm list
    
    # Example: Monitor real-time status of a project
    ntm status myproject
    
    # Example: Get JSON status for programmatic use
    ntm --robot-status
    
    # Example: Terminate a session
    ntm kill myproject
  3. Overview of NTM Integration Maturity and Gaps

    main

    The NTM project is transitioning from a basic agent spawning and monitoring system to a highly coordinated environment. Current gaps in the system focus on agent communication, file safety, and command efficiency.

    Key areas of improvement include:

    • Agent Coordination: Moving from manual macro calls to a single-call bootstrap (macro_start_session) and implementing BD messaging for agent-to-agent coordination.
    • File Safety: Implementing a File Reservation Lifecycle (reserve/release/force-release) to prevent multiple agents from editing the same file simultaneously.
    • Command Efficiency: Utilizing the full range of bv robot modes (specifically -robot-triage) and moving CM from subprocess calls to an HTTP daemon for faster memory queries.
    • Safety & Protection: Adding auto-installed hooks for Destructive Cmd Protection (e.g., preventing accidental git checkout -- operations).
    • Intelligence: Moving from a passive session monitor to an intelligent Session Coordinator and implementing smart task assignment via bv graph analysis.
  4. Understand the Dicklesworthstone Ecosystem

    main

    NTM (Named Tmux Manager) serves as the central orchestration layer within a larger ecosystem of tools designed for AI-assisted software development. While NTM manages agent orchestration, it is designed to interact with several specialized tools to form an 'Agentic Coding Flywheel'.

    Key ecosystem components include:

    • NTM: Central agent orchestration.
    • MCP Agent Mail (am): Inter-agent messaging and file reservations.
    • UBS (ubs): Static bug scanning across 8 languages.
    • Beads/bv (bd, bv): Issue tracking with dependency graphs.
    • CASS (cass): Session indexing across 11 agent types.
    • CASS Memory (cm): Three-layer cognitive memory.
    • CAAM (caam): Account switching and rate limit failover.
    • SLB (slb): Safety enforcement via a two-person rule for dangerous commands.
    • s2p (s2p): Source-to-prompt conversion for context preparation.
  5. What is HyperSync and how does it work?

    main

    HyperSync is a proposed distributed workspace fabric designed for multi-agent AI coding workloads. It provides single-workspace semantics, meaning multiple AI agents (like Claude Code or Codex) running on different machines see an identical, consistent state as if they were all working on a single machine.

    Core Architecture

    HyperSync uses a leader-authoritative model:

    • Leader (Main Machine): Acts as the single source of truth. It maintains an Op Log (with monotonic sequence numbers and Blake3 content-addressed chunks), runs a RaptorQ Encoder for loss-tolerant broadcasting, and uses a Scheduler to manage agent placement.
    • Workers: Run a FUSE Mount (ntmfs/) to intercept filesystem operations. A Worker Daemon captures writes and forwards them to the leader, while a RaptorQ Decoder reconstructs log entries from the leader's broadcast.
    • Transport: Uses QUIC for NAT-traversal and congestion control.
  6. How the Session Coordinator manages agents

    main

    The Session Coordinator (an Agent Mail agent) acts as the intelligent brain of an NTM session. While it currently functions as a passive identity holder, its intended role is to actively manage the lifecycle and coordination of all agents within a session.

    Core Responsibilities:

    • Monitoring: Tracks all active agents in the session.
    • Summarization: Generates periodic digest summaries of session state for humans.
    • Conflict Resolution: Detects file reservation conflicts and negotiates resolutions between agents.
    • Work Assignment: Distributes prioritized work to idle agents based on capability, file overlap, and critical path scoring.
    • Scaling & Recovery: Scales agents based on queue depth and handles recovery for crashed agents.
    • Lifecycle Management: Manages the lifecycle of file reservations.
  7. Concurrency and State Management in NTM

    main

    NTM uses several patterns for state management that can lead to concurrency hazards if not handled carefully:

    • Global Mutable State: Many packages use package-level variables (e.g., projectionStore, outputFormat, stateTracker) that are set via setter functions like robot.SetProjectionStore(). This can cause race conditions during concurrent operations, such as multiple HTTP requests attempting to configure different stores simultaneously.
    • Exclusive Mutexes: The Store.Transaction uses an exclusive mutex during SQLite operations. This blocks all other reads while a write is in progress, even though SQLite's WAL mode typically allows concurrent reads.
    • Event Dropping: Several internal event systems use fixed-size buffers and will silently drop data when full:
      • EventEmitter: 1024-entry buffer.
      • SSE client channels: 100-entry buffer.
      • WebSocket hub broadcast channel: 256-entry buffer.

    When building extensions, prefer passing explicit context objects (like a RobotContext containing store, feed, and config) rather than relying on package-level globals.

  8. HyperSync Read Semantics and Linearization

    main

    Mutations are linearized at the moment the leader commits them to the op log at index k.

    Read Modes

    • Default Mode: A read on worker W_i returns data from state S_{a_i}. This may be stale relative to the leader (Sequential Consistency).
    • Read-your-writes: A client must block until its local applied index a_i >= k for its own committed mutation k.
    • Strict reads (Optional): Read operations may block until a_i >= commit_index_at_read_start to provide linearizable reads relative to the leader's snapshot.
  9. Handle Replay-to-Live Handoff

    main

    NTM streams perform a replay of historical events before transitioning to live real-time events. The sequence is:

    1. connected: Stream established.
    2. replay_start: Historical replay begins.
    3. events: Sequence-ordered historical events.
    4. replay_end: Replay complete, switching to live.
    5. events: Live real-time events.

    Events include replay: true and a replay_sequence during the replay phase. Once replay_end is received, subsequent events will have replay: false and live: true.

    {
      "event_class": "control",
      "event_type": "control:replay_start",
      "payload": {
        "replay_from": "cur_20260322035000",
        "replay_to": "cur_20260322040000",
        "events_pending": 127,
        "estimated_duration_ms": 500
      }
    }
  10. Understand the Robot Projection Section Model

    main

    The Robot Projection Section Model defines the canonical data structures used to represent the state of the NTM system across various surfaces (like snapshot, status, dashboard, etc.). The model is organized into several key sections, each owned by a specific adapter or service.

    Key sections include:

    • Summary: High-level counts for quick assessment (e.g., total_sessions, agents_busy, open_alerts).
    • Sessions: Detailed state of tmux sessions, windows, and agents.
    • Work: Bead state for task management (Ready, Blocked, In Progress).
    • Coordination: Agent Mail state, including inboxes, file leases, and active threads.
    • Quota: Resource usage for providers (Anthropic, OpenAI, etc.), RCH, and system resources.
    • Alerts & Incidents: Active alerts and durable escalations.
    • Attention: Prioritized items requiring action.
    • Source Health: Metadata indicating the freshness and availability of each section's data.

    When a section's source is unavailable, it must include degraded markers: _degraded, _degraded_reason, and _degraded_since, with data fields set to null.

  11. Understand the Canonical Projection Section Model

    main
    The Canonical Projection Section Model is the authoritative schema that all robot surfaces in NTM must use for output. Instead of surfaces inventing their own data representations, they must project from this unified model to ensure consistency, composability, and testability across different interfaces (such as CLI, web, or VS Code).