面向 AI Agent 群的终端管理平台,提供跨 WezTerm 的实时 pane 捕获、状态机模式检测与 JSON API 编排能力,支持多 Agent 协调与策略控制。
FrankenTerm (命令行工具简称 ft) 是一个用 Rust 编写的终端管理平台,专为多 AI 编码 Agent 协调场景设计。
核心能力#
可观测性#
- Perfect Observability: 跨所有 pane 捕获终端输出,delta 提取延迟 <50ms
- Delta Extraction: 4KB 重叠匹配提取增量内容,避免全量捕获开销
- FTS5 全文搜索: 词法搜索 + 语义/混合检索模式
智能检测#
- 多 Agent 模式引擎,检测 rate limits、errors、prompts、completions
- 预置检测模式:Codex、Claude Code、Gemini、Terminal Runtime
- 用户可通过 TOML 配置自定义检测规则
自动化与控制#
- Event-Driven Automation: 基于模式触发工作流,无 sleep 循环或轮询
- Policy Engine: 能力门控、速率限制、审计追踪
- Robot Mode API: JSON 接口,AI agent 控制 AI agent
- MCP Server: stdio transport MCP 服务支持
安全与合规#
- Single-Writer Integrity: watcher 锁确保单写者,防止并发损坏
- 审批机制:安全的 multi-agent 控制门
- 密钥脱敏、本地优先(无遥测和云依赖)
架构概览#
ft Swarm Runtime Core
├── Session Graph │ Pane Registry │ State Store │ Control Plane
├── Ingest + Normalization Pipeline
│ └── Discovery → Delta Extraction → Fingerprinting → Filter
├── Storage Layer (SQLite + FTS5)
│ └── output_segments │ events │ workflow_executions │ audit_actions
├── Pattern Engine │ Event Bus │ Workflow Engine
├── Policy Engine
│ └── Capability Gates │ Rate Limiting │ Audit Trail │ Approvals
└── Robot Mode API + MCP + Platform Interfaces
设计哲学#
- Passive-First Architecture — 观察循环只读无副作用,动作循环严格分离并有策略门控
- Event-Driven, Not Time-Based — 条件驱动而非时间轮询
- Delta Extraction Over Full Capture — 增量提取优化存储与性能
- Single-Writer Integrity — 防止并发损坏
- Agent-First Interface — 结构化 JSON,适合机器解析
性能指标#
| 指标 | 值 |
|---|---|
| CPU (idle) | <1% |
| Memory (100 panes) | ~50MB |
| Disk (typical multi-agent) | ~10MB/day (compressed deltas) |
| Latency (capture) | <50ms average |
安装方式#
# 方式一:Cargo 安装
cargo install --git https://github.com/Dicklesworthstone/frankenterm.git ft
# 方式二:从源码构建(推荐)
git clone https://github.com/Dicklesworthstone/frankenterm.git
cd frankenterm
cargo build --release
cp target/release/ft ~/.local/bin/
快速开始#
ft setup # 生成配置和 shell hooks
wezterm cli list # 验证后端连接
ft watch # 启动 watcher
ft status # 检查状态
ft robot state # JSON 输出所有 pane
主要 CLI 命令#
# Watcher 管理
ft watch / ft watch --foreground / ft stop
# Pane 检查
ft status / ft get-text <pane_id>
# 搜索
ft search "error" / ft search "query" --pane 0
# Robot Mode (JSON API)
ft robot state
ft robot get-text <id> --tail 50
ft robot send <id> "text"
ft robot wait-for <id> <rule_id>
# MCP 服务器
cargo build --release --features mcp
ft mcp serve
配置文件#
路径: ~/.config/ft/ft.toml
[general]: log_level, log_format, data_dir[ingest]: poll_interval_ms, panes include/exclude, priorities, budgets[storage]: writer_queue_size, retention_days[patterns]: detection packs 启用[workflows]: 自动工作流执行[safety]: 审批、密钥脱敏、速率限制
预置 Agent 模式检测#
| Agent | 检测模式示例 |
|---|---|
| Codex | core.codex:usage_reached, core.codex:compaction_complete |
| Claude Code | core.claude:rate_limited, core.claude:approval_needed |
| Gemini | core.gemini:quota_exceeded, core.gemini:error |
| Terminal Runtime | core.wezterm:pane_closed, core.wezterm:title_changed |
与其他工具对比#
| 特性 | ft | WezTerm | Zellij | Ghostty |
|---|---|---|---|---|
| Swarm-native orchestration | First-class | External glue | External glue | External glue |
| Event-driven automation | Built-in | Not native | Not native | Not native |
| Machine API for agents | Robot Mode + MCP | No equivalent | No equivalent | No equivalent |
| Agent-safe control plane | Capability/risk/approval/audit | Not native | Not native | Not native |
补充说明#
- 环境要求: Rust 1.85+ (nightly required for Rust 2024 edition),Linux/macOS
- 依赖项: WezTerm CLI (兼容后端桥接)、SQLite (bundled via rusqlite)
- 特性门控:
--features distributed(分布式模式),--features mcp(MCP 服务器) - 数据保留: 默认 30 天(可通过
storage.retention_days配置) - 贡献政策: 作者不接收外部代码贡献,仅接受 issue 和 PR 提议