Show HN: TermHub – Open-source terminal control gateway built for AI Agents
Article URL: https://github.com/duo121/termhub Comments URL: https://news.ycombinator.com/item?id=47654495 Points: 1 # Comments: 1
中文说明
termhub is an AI-native terminal control tool.
It is designed for this closed loop:
-
AI inspects what terminal sessions are open.
-
AI opens a window or tab when needed.
-
AI launches or targets a Codex session.
-
AI sends the task into that session.
-
AI captures only the new output produced after send and returns it to the user.
-
Command: termhub
-
Alias: thub
-
npm package: @duo121/termhub
-
macOS backends: iTerm2, Terminal
-
Windows backends: Windows Terminal, Command Prompt (CMD)
Install
npm install -g @duo121/termhub
Or Homebrew (macOS):
Install from GitHub Releases (without npm):
-
termhub__macos-arm64.tar.gz
-
termhub__windows-x64.zip
After extraction:
- macOS
- Windows (PowerShell)
.\termhub.exe --version
Quick Start For AI
Use spec as machine-readable truth and --help as human-readable truth. Both now include a currentSession hint near the top that you can copy directly into --session for AI handoff.
SDK
termhub now ships an SDK preview entry:
import { createTermhubClient } from "@duo121/termhub/sdk";
Core SDK capabilities:
-
Open/close terminal targets.
-
Find/resolve terminal sessions.
-
Send keyboard text and key events (key / combo / sequence).
-
Mouse click simulation on terminal target (mouseClick) on macOS.
Platform notes:
-
macOS (iTerm2 / Terminal): keyboard + mouse click are supported.
-
Windows (Windows Terminal / CMD): keyboard control is supported; mouseClick currently returns unsupported.
SDK quick example:
import { createTermhubClient } from "@duo121/termhub/sdk";
const client = createTermhubClient({ app: "iterm2" });
const opened = await client.open({ scope: "tab" }); await client.send({ session: opened.target.handle, text: "echo hello from sdk" }); await client.press({ session: opened.target.handle, key: "enter" }); const output = await client.capture({ session: opened.target.handle, lines: 20 });
console.log(output.text);`
Command Map
Top-Level Command What It Does Common Secondary Flags
open
Open terminal window or tab
--app --window --tab --dry-run
list
List running windows/tabs/sessions
--app --compact
resolve / find
Narrow fuzzy target to one exact session
--title --title-contains --session --current-tab
send
Send text and optionally await/capture output delta in one step
--text --stdin --no-enter --await-output --dry-run
press
Send real key/combo/sequence events
--key --combo --sequence --repeat --delay
capture
Read visible output or delta since latest send checkpoint
--session --lines --since-last-send --app
focus
Bring target window/session to front
--session --app --dry-run
close
Close target tab or window
--session --app --dry-run
doctor
Check platform/backend/automation readiness
--app --compact
spec
Print machine-readable JSON contract
--compact
AI Usage Rules
-
Always resolve (or find) to one exact target before mutating commands.
-
Use --app when multiple backends are active.
-
Use --dry-run before risky operations.
-
Use send --no-enter only when you plan a separate real key submit.
-
Never fake submit by appending literal newlines inside --text or stdin.
Press Modes
press supports exactly one input mode:
-
--key
-
--combo (for example ctrl+c, cmd+k)
-
--sequence (for example esc,down5,enter)
Extra controls:
-
--repeat : only for --key and --combo
-
--delay : delay between repeated or sequenced key events
Examples:
Typical AI Scenarios
Open a new iTerm2 window:
termhub open --app iterm2 --window
List all iTerm2 tabs:
termhub list --app iterm2
Close a specific tab by title:
Read current Terminal tab (last 50 lines):
Run command in Windows Terminal tab titled API:
Send-To-Capture Delta Loop
termhub now supports a built-in session checkpoint loop so AI can capture only the new output produced after send.
Basic flow:
termhub send --session --text "npm test" --await-output 1200
How it works:
-
send stores a checkpoint for that exact session before writing input.
-
send --await-output waits and returns only delta output produced after that send.
-
capture --since-last-send remains available when you want a separate explicit read step.
Concurrency:
-
Checkpoints are session-scoped, so two AI agents can use different sessions in parallel without conflict.
-
State files are stored under ~/.termhub/state by default.
Notes
-
--session accepts native session id or namespaced handle.
-
Windows focus/send/capture/close rely on PowerShell + UI Automation.
-
Windows capture is best-effort based on visible text accessibility.
Sign in to highlight and annotate this article

Conversation starters
Daily AI Digest
Get the top 5 AI stories delivered to your inbox every morning.
More about
open-sourceagentgithub
Eight years of wanting, three months of building with AI
Eight years of wanting, three months of building with AI Lalit Maganti provides one of my favorite pieces of long-form writing on agentic engineering I've seen in ages. They spent eight years thinking about and then three months building syntaqlite , which they describe as " high-fidelity devtools that SQLite deserves ". The goal was to provide fast, robust and comprehensive linting and verifying tools for SQLite, suitable for use in language servers and other development tools - a parser, formatter, and verifier for SQLite queries. I've found myself wanting this kind of thing in the past myself, hence my (far less production-ready) sqlite-ast project from a few months ago. Lalit had been procrastinating on this project for years, because of the inevitable tedium of needing to work through
Knowledge Map
Connected Articles — Knowledge Graph
This article is connected to other articles through shared AI topics and tags.
More in Open Source AI

Qwen 3.5 Tool Calling Fixes for Agentic Use: What's Broken, What's Fixed, What You (may) Still Need
Posted - What follows after this introduction is generated by Claude Opus 4.6 after hundreds of back and forths with log analysis for tool calls that were not working, and Qwen 3.5 models getting confused from local llm providers as well as Nano-Gpt. I fixed it for my own use with Pi coding agent at the time. Some of the fixes that were needed are no longer needed (TLDR at the bottom) but most are still applicable, as validated today. If you use Qwen 3.5 models and are having issues with model performance, tool calls, or general instability, the reference below might be a useful read. In the end, the fixes below on pi coding agent + llamacpp + Bartowski's quants (for stability) is what took my experience to 99% reliability and quality with all Qwen 3.5 models (Q5_k_L). Hope it helps someon

NLP SOTA By far, (NOT WORK ON CNN) , Can save 66% FLOPs and same or BETTER accuracy than baseline
NLP SOTA. CNN NOT WORK, IN NLP WE REDUCE 66% FLOPs with same or MORE accuracy, you have the link of github on zenodo page. DeepFocus-BP: Error-Aware Adaptive Backpropagation via Dynamic Alpha-Beta Routing (Achieving 66% FLOPs Reduction with Improved Accuracy) - SOTA NLP Confirmed v3. (Resnet FAIL) 3 posts - 2 participants Read full topic

FairyClaw: An Open-Source Async Agent Runtime for Long-Running, Event-Driven Server Deployments
Hello everyone! We’re excited to share our new open-source project, FairyClaw . No more bloated SKILL.md files eating your context window. Structured code replaces prose — cheaper and more accurate. Meet FairyClaw — an open-source async agent runtime for long-running server deployments: Restructured Skill paradigm : instead of verbose markdown instructions flooding the context, Skills are declared as structured steps in manifest.json — deterministic playbooks that cut token usage while making tool selection and execution order semantically precise Single-step Planner : one inference per wakeup, event-driven continuation — no monolithic loops, tasks resume naturally after interruption Capability Groups : tools, skills, and hooks declared as pluggable units, routed semantically — structured


Discussion
Sign in to join the discussion
No comments yet — be the first to share your thoughts!