Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:23blocks OS Ai maestro tmux

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Terminal
Last Updated 2026-10-26 18:00 GMT

Overview

tmux terminal multiplexer for managing AI agent sessions, with shell-injection-safe invocation via `execFile` and argument vectors.

Description

AI Maestro uses tmux as the session layer for AI agents. Each agent optionally runs inside a tmux session; the session name matches `^[a-zA-Z0-9_-]+$` (tmux's own constraint). The `tmux-safe.mjs` module is the single source of truth for tmux invocation: it uses `execFile` with an argument vector (never shell strings) and validates session names at every helper, closing the class of shell-injection vulnerabilities where a session name containing `$(...)` or backticks would execute arbitrary commands.

Pane-level helpers accept targets like `agent:0.0` (session:window.pane) validated by `PANE_TARGET_RE`. The module also provides `splitKeySpec` to translate legacy quoted key sequences into argv entries without a shell. The wake/hibernate flows create, kill, and rename sessions; the notification path sends keys to specific panes; the status path checks session existence and captures pane content.

Usage

Use this environment for all agent lifecycle operations: creating sessions (wake), killing sessions (hibernate), sending messages to panes (notification), capturing pane content (status, chat verification), and checking session existence. tmux must be installed on every host that runs agents.

System Requirements

Category Requirement Notes
OS Linux / macOS tmux is a POSIX tool
Software tmux >= 3.0 Older versions may lack `display-message -p` format flags
Disk Minimal Session state is in-memory and in tmux's socket

Dependencies

System Packages

  • `tmux` >= 3.0

Node Packages

  • `child_process.execFile` / `execFileSync` (Node builtins; no shell)
  • No npm package — tmux is invoked as an external binary

Credentials

No credentials required. tmux runs as the same user as the AI Maestro server process and shares its socket.

Quick Install

# Debian/Ubuntu
sudo apt-get install tmux

# macOS
brew install tmux

Code Evidence

Session name validation from `lib/tmux-safe.mjs:45-49`:

export const SESSION_NAME_RE = /^[a-zA-Z0-9_-]{1,128}$/

export function isValidSessionName(name) {
  return typeof name === 'string' && SESSION_NAME_RE.test(name)
}

No-shell invocation from `lib/tmux-safe.mjs:101-103`:

export async function tmux(args, opts = {}) {
  return execFileAsync('tmux', args, { encoding: 'utf8', ...opts })
}

Pane target validation from `lib/tmux-safe.mjs:81`:

export const PANE_TARGET_RE = /^[a-zA-Z0-9_-]{1,128}(?::[0-9]{1,4}(?:\.[0-9]{1,4})?)?$/

Common Errors

Error Message Cause Solution
`Invalid tmux session name` Name contains characters outside `[a-zA-Z0-9_-]` Sanitize the name at agent creation; the registry enforces this
`session not found` Agent hibernated or session killed outside AI Maestro This is expected; the agent record persists without a session
`no server running on /tmp/tmux-1000/default` No tmux sessions exist Not an error; treated as "no agents online"

Compatibility Notes

  • Session names: Must match `^[a-zA-Z0-9_-]{1,128}$`. This is tmux's own constraint, not an AI Maestro restriction. Anything else was never valid.
  • Cloud agents: Cloud agents have no host tmux session — their tmux runs inside the Docker container. Use `docker exec` variants in `container-utils.ts`.
  • Streaming agents: SDK-based streaming sessions bypass tmux entirely; they use the streaming runtime, not tmux panes.
  • The `splitKeySpec` function reproduces legacy shell-quoted key sequences as argv entries so existing callers work without a shell.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment