-
-
Notifications
You must be signed in to change notification settings - Fork 4
Processes and PTY
Background/service process control, transcript polling, stdin injection, and sleep ticks in the exec runtime.
See also Exec Runtime and Chat System.
The unified exec runtime owns foreground commands, background processes, and services. shell and process_start both accept tty: bool.
-
tty: falseuses normal stdout/stderr pipes. -
tty: trueuses the PTY path, exposes an interactive stdin writer, and combines stdout/stderr into thecombinedstream. - PTY output goes through the same bounded runtime buffers as pipe output.
- PTY can change command behavior; it should be used for REPLs, prompts, interactive CLIs, and programs that need a terminal.
- The Windows path uses ConPTY where available; if a PTY cannot be allocated, the tool fails clearly rather than silently falling back.
Start a runtime-owned background or service process and return its process ID, initial status, output cursor, and metadata.
Schema highlights:
command: stringdescription: string-
mode: "background" | "service"with defaultbackground -
service_namefor services workdirstartup_wait_msstartup_wait_portstartup_wait_keywordtty: boolean = false
Notes:
- Service mode requires
service_name. - Duplicate running services in the same owner/workspace are rejected.
- Workdir is resolved through active worktree privacy rules.
Schema:
- optional
status: "running" | "completed" | "all"with defaultrunning - optional
scope: "chat" | "workspace" | "all"with defaultchat
Returns process summaries under extra.exec.processes.
Schema highlights:
-
process_id: stringrequired - optional
since_seq - optional
stream: "stdout" | "stderr" | "combined" | "all" - optional output filters
Returns transcript chunks and cursor metadata under extra.exec.transcript:
since_seqnext_seqlatest_seq
Empty-output reads are normal when nothing new has been emitted. Use the returned cursor for the next poll.
Wait until terminal status or timeout, then return final/partial transcript metadata.
Schema highlights:
-
process_id: stringrequired - optional
timeout_ms - optional output filters
Schema: { "process_id": "exec_..." }.
Kills a runtime-owned process and returns its terminal metadata.
This is the PTY stdin path.
Schema:
{
"type": "object",
"properties": {
"process_id": { "type": "string" },
"chars": { "type": "string", "default": "" },
"yield_time_ms": { "type": "integer", "default": 250, "maximum": 10000 }
},
"required": ["process_id"]
}Behavior contract:
- Requires a
tty=trueprocess. - Writes
charsbytes to stdin. - Waits up to
yield_time_msfor new output or exit. -
chars: ""means poll only. - Returns
bytes_writtenandchunks_returnedin addition to standardextra.execfields.
ExecRegistry emits a completion event on the first terminal transition for background/service processes with an owning chat_id.
Current delivery is the ordinary MessageAdded envelope carrying a hidden event(process_completed) message. The event payload includes the process ID, status, exit code, duration, and short description. Foreground processes and records without chat_id do not inject notifications.
The sleep tool waits for the requested duration without holding a shell process.
Schema:
{
"type": "object",
"properties": {
"duration_ms": { "type": "integer", "minimum": 100, "maximum": 3600000 },
"tick_interval_ms": { "type": "integer", "minimum": 5000 },
"description": { "type": "string", "description": "Short description (≤80 chars)." }
},
"required": ["duration_ms", "description"]
}Returns { "slept_ms": number, "interrupted": boolean }. If tick_interval_ms is set, it injects event(tick, "tool.sleep", {elapsed_ms, remaining_ms}, "tick") at each interval.
Refact on GitHub: https://github.com/JegernOUTT/refact
- Agent Modes
- Agent Tools
- Task Planner & Cards
- Worktrees
- Subagents
- Memory & Knowledge
- Hidden Roles & Plans
- Context Compression
- Scheduler & Cron
- Processes & PTY
- Buddy
- MCP
- Skills, Commands & Hooks
- Marketplace
- Chat System
- Providers
- Caps & Models
- Code Completion (FIM)
- AST
- VecDB
- Exec Runtime
- HTTP API
- Checkpoints & Git
- Voice