agent-tty
exec() killed frame detection.
AI gets pure data through a pipe. Humans get a real terminal with colors and readline. Same namespace. Python-native runtime.
guess when a command finished
strip terminal control codes
exec(src) → return value → done
pip install agent-tty
Write files, then exec
Complex code with quotes, f-strings, SQL, or shell variables? Write a file with your shell tool, then load it. No manual escaping. The file is transport; the namespace is the workspace.
config. The next cell can read or change it. The file was just transport — the namespace is the workspace.Two channels, one namespace
Your agent's commands enter through a structured pipe: source code in, captured output out. Humans attach through a real PTY: readline, tab completion, arrow keys, colors. Both paths share the same live Python process.
Stateful first
bash_tool is curl — every call forks a process, runs, and dies. k is a socket — one process stays alive, and every call is a function invocation inside it.
subprocess.run is amnesia. k run is accumulation.What stays alive
Some things only exist in process memory. A database connection, a TCP socket, an SSH tunnel, a trained model, a Flask app serving requests in a daemon thread, a CDP browser session — none of these can be serialized to disk. subprocess.run kills them every call. k run keeps them alive. The process is the workspace.
Variables and imports
A pandas DataFrame, a trained model, a parsed config, a compiled regex — anything in the namespace survives across cells.
Connections and servers
Database handles, HTTP sessions, WebSocket connections, Flask apps running in daemon threads — open once, use from every cell.
Live control plane
Feature flags, rate limits, firewall sets, routing weights become Python variables. Patch one cell; the next request sees it. No restart.
Broadcast
When your agent runs a cell, humans see it prefixed with [ai] >>> on the PTY. Two-way visibility — nobody works blind.
Async cells
k fire queues background work. k poll checks the result. The session keeps running. Multiple sessions for parallelism.
Single Python runtime
Core runtime is Python stdlib. The process owns the session directly. pywinpty gives raw WinPTY on Windows — without it, a socket console works fine.
The REPL is Turing complete
You don't need a built-in file watcher, a notification framework, or a monitor callback. The session is Python. Python can do anything. Give your agent the primitives; it builds the rest.
k gives your agent fire + poll as primitives. Complex workflows are code, not configuration.REPL patterns
Kill the prefix tax
from os import * — now listdir(".") instead of os.listdir("."). Every token your agent saves is money saved.
Print tax is zero
Expressions display automatically. k run w "len(data)" prints the result. No print() wrapper needed for the last expression.
Hot reload
exec(open("module.py").read()) or importlib.reload(m) — update code without restarting the session or losing state.
Incremental execution
Break a long script into cells. If step 3 crashes, fix and re-run just step 3 — steps 1 and 2's state is still in the namespace.
Catch, fix, retry
Exception in a cell? Read the traceback, fix the function, run again — all in the same session. State and data survive the error. No restart.
Shell via Python
Need the host OS? subprocess.run(["git","status"], capture_output=True, text=True).stdout — host commands return clean strings inside the session.