Skip to main content

Crate midtown

Crate midtown 

Source
Expand description

Midtown - Multi-agent workspace management daemon for Gas Town.

This crate provides the core library for the Midtown daemon, which manages multiple agent workspaces (polecats, refineries, witnesses) in a Git-based workflow system.

§Core Components

  • RPC: JSON-RPC 2.0 protocol for inter-process communication
  • Channels: Append-only message logs for agent coordination
  • Cursors: Per-agent position tracking in message streams
  • Worktrees: Git worktree isolation for coworkers
  • Coworkers: Agent session management via tmux
  • Tmux: Low-level tmux session operations

§Quick Start

The primary abstractions are Channel for communication and Message for individual messages:

use midtown::{Channel, Message, MessageType};

// Create a channel for agent communication
let channel = Channel::new(temp_dir.path(), "midtown").unwrap();

// Agents send messages to the channel
channel.send(&Message::text("lead", "Starting build")).unwrap();
channel.send(&Message::status("worker1", "Compiling...")).unwrap();
channel.send(&Message::text("worker1", "Build complete")).unwrap();

// Each agent tracks their read position with cursors
let messages = channel.read_since_cursor("worker2").unwrap();
assert_eq!(messages.len(), 3);

// Subsequent reads only return new messages
channel.send(&Message::text("lead", "Deploy now")).unwrap();
let new_messages = channel.read_since_cursor("worker2").unwrap();
assert_eq!(new_messages.len(), 1);

Re-exports§

pub use coworker::Coworker;
pub use coworker::CoworkerManager;
pub use coworker::CoworkerStatus;
pub use coworker::is_coworker_name;
pub use session_key::SessionKey;
pub use usage::UsageData;
pub use usage::fetch_usage_for_profile;
pub use worktree::WorktreeError;
pub use worktree::WorktreeInfo;
pub use worktree::WorktreeManager;

Modules§

agents
Agent system prompt loading.
auth
Auth profile management for midtown.
ci_stats
CI check duration statistics for auto-retry of stale checks.
clustering
AI-driven channel clustering for task organization.
config
Project-level configuration for midtown.
coworker
Coworker management for the midtown daemon.
coworker_state
Structured coworker workflow phases.
daemon
Midtown daemon server.
daemon_messages
Randomized daemon message templates for spawn and shutdown events.
github_rate_limit
GitHub API rate limit tracking and adaptive throttling.
github_state
Persistent GitHub state for the midtown daemon.
headless
Headless Claude Code executor using JSON streaming.
launch
Unified launch configuration for Claude Code sessions.
mailbox
Agent teams mailbox writer for delivering messages to Claude Code coworkers.
pane_detection
Pane content pattern detection for usage limits, API errors, and UI chrome.
paths
Path utilities for midtown daemon and clients.
push
Web Push notification support for the Midtown PWA.
reminders
Reminder system for the midtown daemon.
rpc
JSON-RPC 2.0 types for daemon communication.
rules
Pure decision functions and shared types for the daemon tick loop.
sandbox
Lightweight filesystem sandbox for Claude Code sessions.
session_key
Session key type for identifying coworker sessions.
specialized
Specialized headless coworker abstraction.
tasks
Claude Code task storage integration.
test_utils
Test utilities shared across unit and integration tests.
tmux
Tmux session management for coworker processes.
usage
Usage data fetching for Claude API rate limits.
web
Web API server for Svelte mobile app
webhook
GitHub webhook integration
webserver
Standalone multi-project webserver for midtown.
worktree
Git worktree management for coworker isolation.
worktree_registry
Task-based worktree registry.

Structs§

Channel
A channel for agent communication.
ChannelRouter
Router for managing multiple channels with lazy initialization.
Cursor
Cursor state for an agent’s read position in a channel.
Message
A message in the channel log.

Enums§

Error
Errors that can occur in the Midtown daemon.
MessageType
Types of messages that can be sent through a channel.

Functions§

resolve_web_dir
Resolve the web-app/dist/ directory containing built static assets.

Type Aliases§

Result
Result type alias for Midtown operations.