Rust-native, terminal-first agent harness for local coding workflows.
The CLI, task runner, policy engine, tools, workspace storage, SQLite index, checkpoints, sessions, and full-screen TUI are implemented in Rust. The harness itself needs no Node.js runtime — the npm package below is only a delivery channel for the prebuilt binaries.
DeepSeek is the default model provider for natural-language tasks. The default
model is deepseek-v4-flash and the default endpoint is
https://api.deepseek.com.
- Changelog: user-visible changes per release.
- Program design: modules, execution flow, storage, and boundaries.
- Plan, todo, and progress: direction, pending work, and change history (Chinese).
- Task evaluations: ten offline fixtures, independent graders, and a pinned real-model JSONL/Markdown baseline runner.
- OpenCode GitHub automation: automatic tasks on new Issues, optional comment commands, model/App setup and PR review (Chinese).
No Rust toolchain required — the npm package carries prebuilt binaries and only resolves the one that matches your platform:
npm install -g hyper-harnessAlternatively download the archive for your platform from GitHub Releases, or build from source below.
Rust 1.94 is selected by rust-toolchain.toml.
cargo build --release # target/release/{hyper,ha}
cargo testcargo test keeps its audit state in the system temporary directory instead of
the developer's real state directory, so a test run never accumulates throwaway
workspaces under ~/.local/state and still works where that directory is not
writable. A test harness is detected from the unit-test build or from cargo's
CARGO_BIN_EXE_* environment (set for integration-test and benchmark targets
only), and parent and child processes resolve the same location so a test can
read the events a spawned hyper wrote. Set HYPER_STATE_DIR to override it,
as for any other run.
Neither binary is on PATH until it is installed, so a bare cargo build
leaves hyper: command not found. Install them into ~/.cargo/bin, which a Rust
toolchain already puts on PATH:
cargo install --path . --locked # installs both `hyper` and `ha`The release binaries are target/release/hyper and its short alias
target/release/ha. Both run the same program with the same commands; ha
changes nothing but the name, so --version reports hyper and only the usage
line names the command you actually typed.
export DEEPSEEK_API_KEY="sk-..."
cargo run -- init
cargo run -- --approval allow run examples/hello.json
cargo run -- runs
cargo run -- tuiAfter installing or copying either binary, the shortest workflow is:
ha # open TUI
ha --approval allow "implement login" # explicitly allow mutation tools
ha -p "analyze the bug" # plan modeha is the short alias of hyper; every command below works with either name.
On the first ha launch, Hyper prompts for the provider API key and stores it,
along with the API base URL and the model, in the user configuration directory
with owner-only permissions. Run ha config to update them. A bare Enter keeps
the stored API key, base URL, or model; a new key is entered without echoing it.
Interface text defaults to English. Set HYPER_LANG=zh (or zh-CN) to show
Hyper's prompts and TUI controls in Chinese. Model replies and tool output are
displayed in their original language.
Environment variables override the stored file, which overrides the defaults, so CI needs no configuration file:
export DEEPSEEK_API_KEY="sk-..."
export DEEPSEEK_BASE_URL="https://api.deepseek.com" # default
export DEEPSEEK_MODEL="deepseek-v4-pro" # default: deepseek-v4-flashAdd profiles and active_profile to ~/.config/hyper/config.json (the user
configuration directory on other platforms):
{
"active_profile": "work",
"profiles": {
"work": {
"protocol": "chat",
"base_url": "https://provider.example/v1",
"model": "coding-model",
"auth": { "source": "env", "variable": "WORK_API_KEY" },
"endpoints": {
"chat": "chat/completions",
"responses": "/v1/responses",
"messages": "https://provider.example/v1/messages"
}
},
"backup": {
"protocol": "messages",
"base_url": "https://backup.example/v1",
"model": "backup-model",
"auth": { "source": "config", "api_key": "your-key" }
}
}
}auth.source selects an environment variable or a saved key. Keep saved keys in
an owner-only file; ha profile use writes the configuration with mode 0600 on
Unix. Profiles require a protocol, base URL, model and authentication source.
Names contain 1–64 ASCII letters, digits, underscores or hyphens.
ha profile list
ha profile use work
ha profile test # active profile, or legacy settings
ha profile test backup # test without changing the active profile
ha profile test work --timeout-ms 2000
ha profile models # models the active profile's provider offers
ha profile models backup # another profile's provider
ha profile model glm-5.3 # switch the active profile's modelmodels reads the provider's OpenAI-style GET /models and marks the current
model. model rewrites only the active profile's model; a protocol that was the
one detected for the old model follows the new one, and a pinned protocol is
kept.
The TUI does all of this without leaving it. /model opens a searchable list
of the provider's models (type to filter, ↑↓, Enter), /profile opens the
provider list, and /connect (or the provider list's last row) adds a provider:
pick DeepSeek, OpenCode Go or any OpenAI-compatible base URL, fill in the name,
base URL and API key (masked while typed), and the new provider's models open
for selection. The key is saved in the owner-only configuration file.
/model <name> and /profile <name> remain as typed shortcuts.
list shows configuration and authentication sources without loading or printing
keys. use only saves the selection. test sends one small request with no tools
or retries, with a default 10-second timeout. It reports authentication, path,
protocol/response shape, model, rate-limit, timeout or connection errors. Model
errors use structured provider error codes or a differing reported model; an
unqualified HTTP 404 is classified as a path error. Provider error text is not
printed.
Nonempty DEEPSEEK_API_KEY, DEEPSEEK_BASE_URL, DEEPSEEK_MODEL and
DEEPSEEK_PROTOCOL override the corresponding selected-profile settings. An
unset profile credential never falls back to another profile or the legacy key.
Without active_profile, the old single configuration and default settings
continue to work; ha config preserves profiles while updating the legacy fields.
Remove active_profile to return to the legacy configuration.
Endpoint overrides are optional for each of chat, responses and messages.
A relative path appends to the effective base URL; a leading slash resolves from
the host root; a full HTTP(S) URL is used as supplied. Omitted overrides use the
protocol's standard path. URLs must omit userinfo, query strings and fragments
so credentials cannot enter configuration events. Absolute endpoint overrides
remain fixed when DEEPSEEK_BASE_URL changes.
Each run freezes its effective configuration at startup and reuses it across
model steps and automatic compaction. provider.resolved and
model.started.effectiveConfig record the profile, protocol, base URL, model,
authentication source, endpoint overrides, timeout and budget without the key.
Keys are redacted from event payloads, and HTTP errors only retain status and a
fixed diagnostic category.
For a chat-completions service that accepts Bearer authentication and Hyper's
request format, point DEEPSEEK_BASE_URL (or the stored base_url) at it and
set the model. DeepSeek is the default.
OpenCode Go serves the same DeepSeek models under a subscription, so the only change is the endpoint:
export DEEPSEEK_API_KEY="<opencode-go key>" # from the OpenCode Zen console
export DEEPSEEK_BASE_URL="https://opencode.ai/zen/go/v1"
export DEEPSEEK_MODEL="deepseek-v4-flash" # or deepseek-v4-proOr store the same three values once with ha config and drop the exports.
OpenCode Go requires every request to identify its conversation in
x-opencode-session; Hyper sends one id per step (all turns of that step share
it) and identifies itself as hyper/<version> rather than as its HTTP library.
Runs against a non-DeepSeek endpoint record that in the audit log:
model.started carries the provider, base URL, and protocol. model.finished
also carries the provider, so a run is not filed as a DeepSeek call it did not
make.
A gateway can expose its models over more than one wire format, and OpenCode Go does: the model determines which endpoint serves it.
| Protocol | Endpoint | OpenCode Go models |
|---|---|---|
chat |
{base}/chat/completions |
GLM, Kimi, LongCat, MiMo, DeepSeek, Hy |
responses |
{base}/responses |
Grok, GPT, Muse Spark |
messages |
{base}/messages |
MiniMax, Qwen3.6 Plus / 3.7 / 3.8 |
Hyper picks the protocol for you when the base URL is an OpenCode one, and
otherwise stays on chat/completions, which is what any OpenAI-compatible
service speaks. Set it explicitly when detection would guess wrong, or for a
gateway that maps models differently:
export DEEPSEEK_PROTOCOL="messages" # chat | responses | messagesAn optional protocol value in the configuration file is used the same way;
ha config preserves an existing value but does not prompt for one. The
environment wins over the file. An unrecognised name is rejected rather
than silently ignored. Each model's protocol is recorded in the run's
model.started event, so a surprising answer is always traceable to the
endpoint it came from.
Explicit Chat truncation/filtering and incomplete Responses replies fail before
any tool in that reply executes. model.failed and run failure details retain
bounded completion diagnostics without tool argument text. Missing usage stays
unknown; failed streams are not automatically replayed. See
completion behavior and remaining limits.
Natural-language plan, build, and TUI prompts use the configured provider.
Explicit instruction prefixes continue to use local deterministic tools and do
not require an API key.
A prompt run belongs to a conversation, and a conversation is what gives a follow-up its context.
ha plan "which files implement the policy check?" --session review
ha plan "and which tests cover it?" --session review
ha sessions # list conversations
ha session review # print the transcript
ha resume review # open the TUI inside this conversation
ha forget review # delete the conversation, keep its runs
ha compact review # summarize older turns, keep the transcriptRuns without --session stay standalone, and the TUI is a single conversation:
the first message opens one, every later message continues it, and the header
shows which one. /new starts a fresh conversation (the old one stays readable
under sessions/), and /session prints the current id so a CLI run can pick
the conversation up with --session.
The transcript keeps the prompt and the answer — what the model is replayed on
the next turn — while the tool calls behind them stay in the run's
events.jsonl. A conversation is therefore small and readable, and the full
trace is still there when you need it.
A conversation that grows past its useful context can be compacted without
losing anything. ha compact <session-id> [--keep-turns <N>] asks the model for
a summary of the turns older than the most recent N (default 1), and appends
it to sessions/<session-id>.compactions.jsonl. The transcript itself is never
rewritten: later runs project the summary — a <session_summary> block — in
place of the turns it covers, and each run records the exact projection it used,
so replay stays byte-for-byte. A summary that fails or is cancelled is recorded
as a terminal attempt and never projected, so the full history keeps working.
With HYPER_AUTOCOMPACT=1, a run whose
projected history exceeds HYPER_HISTORY_TOKENS summarizes everything older
than HYPER_AUTOCOMPACT_KEEP_TURNS turns (default 1) before its steps and
records compaction.started/compaction.finished, so context is not silently
dropped. It is off by default so existing conversations and their cost are
unchanged. An automatic summary that fails keeps the full history, is not
retried at the same boundary, and never fails the run.
The agent loop does the same for its own turns: with HYPER_LOOP_COMPACT=1, a
request that would exceed the input budget summarizes the loop's older tool
turns first. The cut is always at a turn boundary, so a tool call is never
separated from its result; the summary is recorded as model.loop_summary and a
replay reproduces the same projection. A failed summary leaves the messages
untouched, and the normal budget check still reports the real error.
A model step reads every non-ignored AGENTS.md under the workspace and
delivers each as its own labeled block:
<project_instructions source="AGENTS.md" truncated="false">
...file text...
</project_instructions>
<project_instructions source="src/AGENTS.md" truncated="false">
...file text...
</project_instructions>
Files are ordered root first, then shallower before deeper, and share a 16000
byte total budget applied on UTF-8 boundaries with an explicit truncated
marker. The same ignore rules as search apply, so .git, target and audit
directories never contribute; a symlinked instruction file is skipped, not
followed. Each block is read through the same anchored entry as the file tools,
is never executed, is fixed into the request, and its provenance (source, bytes,
truncated) is recorded in model.started, so ha replay rebuilds the exact
prompt. Project instructions are guidance for the model, not authority: they
cannot change tool permissions, the sandbox, the workspace boundary or any audit
protection. Directory-scoped overrides beyond this fixed order are not yet
defined.
ha replay <run-id> rebuilds the conversation a run sent to the model — the
system prompt, the conversation prefix it replayed, the input it was given, and
every assistant turn with the observations that followed it — and prints it as
JSON. New runs record the actual conversation prefix and system prompt in
their events, so replay survives forgetting the session and prompt changes.
Older runs use the session transcript and current system prompt as fallbacks.
Replay makes no provider request and executes no tools, though opening the
workspace may repair its SQLite index. If the session has been forgotten,
replay omits that prefix for older runs. A run recorded before the events
carried the necessary payloads is refused instead of being guessed from
missing data.
Session history uses a sliding window of whole user-led turns, retaining the
most recent turns within HYPER_HISTORY_TOKENS (default: 16000; 0 sends no
history). The estimate conservatively counts one token per character plus
eight per message; it is not a provider tokenizer. An oversized latest turn
leaves no history rather than being split or replaced with older turns. The
original transcript stays intact. model.started records the selected history
and its budget, estimated usage, and kept/dropped message counts.
The history budget covers previous session messages. A separate total request
budget, HYPER_CONTEXT_TOKENS (default: 128000), reserves
HYPER_OUTPUT_TOKENS (default: 8192) for output. Set both for the limits of
your model; these defaults are local budgets, not detected model capabilities.
The output cap is sent as max_tokens for Chat/Messages and
max_output_tokens for Responses.
An agent step stops after HYPER_MAX_TURNS tool-calling turns (default: 12,
up to 200); raise it for long multi-file tasks. Each model request times out
after HYPER_REQUEST_TIMEOUT_SECS (default: 120, up to 3600); network
errors and retryable statuses are retried with backoff. Both values are
recorded on model.started and provider.resolved.
Before each request, Hyper conservatively estimates the entire translated
JSON body at one token per character, including system/input messages,
workspace context, tool schemas, arguments and observations. Initial requests
drop additional old session turns if needed. If the current input or a later
tool round still exceeds the remaining input budget, the step fails with
ContextBudgetError before that request is sent. Tool calls and results stay
intact. model.context_budget records each estimate, reserve and decision;
replay ends at the last request that passed the budget (or has no model step
if the first request was rejected).
Estimates do not use a provider tokenizer and cannot guarantee compatibility with every model's context limit. Budget values must be integers, output must be positive, and context must exceed output. Invalid values fail the model step before making a provider request.
ha prune --keep <N> deletes every conversation but the N most recently
updated, transcripts and registry rows included; ha prune --runs --keep <N>
does the same for runs, taking their events, artifacts and checkpoints with
them. A run whose lock is still held is never a candidate. --dry-run reports
what would go and deletes nothing.
hyper config
hyper profile list | use <name> | test [name]
hyper state
hyper migrate-state --from <path>
hyper init
hyper validate <task.json>
hyper run <task.json>
hyper plan <prompt> [--session <session-id>]
hyper build <prompt> [--session <session-id>]
hyper runs [-n <limit>]
hyper show <run-id>
hyper sessions [-n <limit>]
hyper session <session-id>
hyper forget <session-id>
hyper compact <session-id> [--keep-turns <N>]
hyper tui
hyper resume <session-id>
hyper diff <run-id>
hyper artifacts <run-id>
hyper checkpoints <run-id>
hyper restore <run-id> <checkpoint-id>
hyper undo <run-id>
hyper replay <run-id>
hyper prune --keep <N> [--runs] [--dry-run]
Every command can use ha instead, for example ha tui or ha config.
Common aliases remain available: ha b, ha p, ha r, ha ls, and ha s.
ha diff prints the file diffs recorded by write/edit tools, ha artifacts
lists the run's artifact files, ha checkpoints lists snapshots and
ha restore <run> <checkpoint-id> rewinds one file to a specific snapshot.
ha replay <run-id> prints the rebuilt conversation, and ha prune --keep <N>
retires the oldest conversations or runs.
ha run, ha plan, ha build and a direct prompt exit with status 1 when the
run does not finish, so CI can rely on the exit status; the run summary is still
printed on stdout. Subcommand prompts may be passed unquoted as several words:
ha plan fix the login bug is the same as ha -p "fix the login bug".
The TUI uses Ratatui and Crossterm. Press Tab to switch plan/build mode (or
complete a slash command) and Enter to submit. The message box edits like a
shell line: ←/→ (with Ctrl/Alt by word), Home/End or
Ctrl-A/Ctrl-E, Ctrl-W (word), Ctrl-U/Ctrl-K (to line start/end),
Delete. Shift-Enter or Alt-Enter (where the terminal reports them),
Ctrl-J, or a trailing \ adds a line; pasted text keeps its newlines and is
never sent by them. ↑/↓ move between lines of a multi-line message, then
recall earlier messages (kept per workspace in its state directory, owner-only,
up to 500); PageUp/PageDown and the mouse wheel scroll the chat, and with an
empty box Home/End jump to its top or latest. While running, Esc or Ctrl-C cancels the current
run. While idle, Esc clears the input and never exits; Ctrl-C clears the
input first, and on an empty input exits only when pressed twice within two
seconds (or use /quit). In an approval modal, Esc denies that action and
Ctrl-C cancels the run. Slash commands:
/help, /runs, /session, /mode plan|build, /model, /profile,
/connect, /resume, /diff, /undo, /compact, /permissions, /new,
/cancel, and /quit.
Type @ and part of a path to pick a workspace file (ignored files are left
out); Tab or Enter inserts @path, which the model is told to read when it
matters. /compact summarizes the conversation's older turns (keeping the
latest) to free context, as ha compact does. /permissions switches
write/edit/bash between asking, allowing and refusing for the rest of the TUI
session, and forgets "always allow" answers. While a task runs, its progress
reads as ▸ bash cargo test / ✗ bash exit 101 (12.3s) / ✓ read src/a.rs.
/resume lists this workspace's conversations and continues the chosen one,
showing its transcript; ha -c (--continue) does the same for the most
recent one, and ha -c "prompt" continues it from the command line. /diff
shows the file changes of the last run started in this TUI, and /undo, after
naming the files and asking, restores each to its state before that run (files
the run created are removed). The header shows context use (ctx, the last
request's input tokens) and the conversation's input/output token totals. On a
first start with no provider configured, the TUI opens on provider setup
instead of a line-by-line prompt. /runs
lists recent runs inline; /session shows the conversation the next message
will join.
While a task runs, the TUI shows streamed model text and its recent event stream
(up to 12 brief updates). The complete events, including model.delta text
chunks, remain in events.jsonl.
Use --jsonl for a machine-readable live event stream from run, plan,
build, or a direct prompt:
ha --jsonl --approval allow run examples/hello.json
ha --jsonl plan --session review "inspect this project"
ha --jsonl --approval allow "fix the failing tests" > events.jsonlStdout contains one complete event per line, identical to the run's audit log,
in persistence order. Each line is flushed immediately, including streamed
model.delta text. Plain answers and pretty-printed summaries are omitted;
successful runs end with run.finished (its payload includes the summary),
failed runs with run.failed (its payload includes the failure), and cancelled
runs with run.cancelled (summary and cancellation reason).
Diagnostics go to stderr; failed runs exit with status 1, cancelled runs 130.
JSONL mode never opens the configuration wizard; missing or invalid provider
settings are recorded as run failures. Use ha config separately.
Slow consumers apply backpressure without dropping events. An output or flush
error stops the command with a non-zero exit status; events already persisted
remain available, and a run left unfinished is repaired as interrupted on the
next workspace open. --jsonl requires a run command or prompt and cannot be
used with the TUI or inspection commands.
CLI Ctrl-C and Unix SIGTERM/SIGHUP use the same run cancellation source as
the TUI. Cancellation interrupts response-header/body waits, all three SSE
protocols, retry delays, approval waits, and shell process groups. Later tools
and steps stop; completed file changes and checkpoints remain. It does not
automatically undo changes. cancelled is a deliberate terminal state, distinct
from task failed and crash-recovered interrupted; the conversation can continue
with a fresh run token. TUI /quit and shutdown wait for the active worker to settle.
On Unix, CLI JSONL pipe backpressure is also cancellable. If a consumer stops reading or the output closes during cancellation, stdout can be incomplete; the full cancellation event, summary and session still persist in the external audit store. Native Windows pipe backpressure, terminal rendering backpressure, and OS-blocked filesystem I/O do not yet have a bounded cancellation guarantee. Custom synchronous event writers must supply their own interruptible I/O. Linux gated tests assert completion within two seconds for network, approval, shell and stalled JSONL-pipe waits.
Synchronous library users can pass RunOptions and a shared CancellationToken
to run_task_with_control; cancel its clone from another thread. Library calls
do not install process signal handlers. The existing run APIs remain available.
CLI and TUI share allow / ask / deny decisions. By default read and
search are allowed; bash, write and edit ask. The TUI answers each
invocation with y or n/Esc, or a to stop asking for the rest of the TUI
session: for bash that covers the exact same command only, for write/edit
the tool. The modal shows the full command, and for write/edit a unified
diff of what would change (built only after the target passes the path checks;
display only, never recorded). CLI runs have no interactive approval handler:
ask fails closed with exit 1, including when stdout is a terminal. For an
authorized unattended task, set --approval allow explicitly; --approval deny
disables mutation tools. The flag applies to CLI and TUI and overrides
HYPER_APPROVAL (allow, ask, or deny).
An explicit --permissions FILE accepts JSON such as
{"read":"allow","search":"allow","write":"ask","edit":"ask","bash":"deny"}.
Missing entries keep the defaults; unknown fields/values fail before a run.
Fallback precedence is --approval for mutation tools, then the explicit file, then
HYPER_APPROVAL, then defaults. Repository files are never loaded as permission
configuration automatically. run.started fixes the effective decisions and
source; tool.policy records each decision. A TUI approval permits one call,
including reads if configured to ask. Approval never expands the plan mode,
step tool whitelist, workspace path checks or shell OS boundary.
Keep permission files outside the writable checkout. The file also accepts optional rules:
{
"write": "deny", "edit": "deny", "bash": "deny",
"rules": [
{"tool": "write", "path": "src/", "decision": "allow"},
{"tool": "write", "path": "src/private/", "decision": "deny"},
{"tool": "read", "path": "private/", "decision": "deny"},
{"tool": "bash", "command": "cargo test --offline", "decision": "allow"}
]
}Paths are literal workspace-relative names; a trailing / selects a directory
subtree. Absolute paths, .., globs and backslashes are rejected. Rules apply
independently to read/write/edit; bash matches the complete command string passed
to the shell, with no prefix or token expansion. Matching rules override the tool
fallback; among matching rules deny wins over ask, which wins over allow.
Path checks combine the requested spelling and resolved destination using the
stricter decision. Linux path-scoped tools reject hardlinked targets before I/O;
path rules fail closed on other platforms until descriptor confinement is ready.
--approval allow changes mutation fallbacks and preserves scoped ask/deny.
--approval ask also constrains scoped mutation allows; --approval deny denies
all mutations. tool.policy records zero-based matching rule indices and the
resolved relative target. Approval displays and retains that resolved target.
Search and automatic context include only files whose read decision is allow;
ask files require an explicit read invocation and never prompt during enumeration.
These rules authorize tool calls. Shells retain their configured OS boundary,
and an allowed command can execute changing repository scripts. Rules do not
redact prior conversation history or user input, or create OS-level read secrecy.
Do not use a broad --approval allow fallback when a narrow allow-list is wanted.
RunOptions.permissions exposes the same policy to embedders. For API
compatibility, older run_task* helpers retain their prior automatic mutation
permission or gated approval behavior; their source is legacy-library-api.
Use run_task_with_control for explicit decisions and the default ask policy.
Agent file tools deny the retired .harness area, including resolved symlink
aliases and Unix hardlinks; search/context also filter these files. On Windows,
file tools conservatively reject every file whose open handle reports a link
count other than one, including ordinary workspace hardlinks. They check both
the resolved path and the handle actually used for I/O; failure to query the
count also denies access. This does not add Windows shell isolation or protect
against concurrent alias creation after the check. Authoritative
audit storage now lives outside the workspace. Restricted Linux shell commands
cannot write, delete, rename or hardlink these external records. Pre-existing
hardlink aliases fail closed before shell execution. Artifact output is collected
by the harness into the external store; shell temporary files use .hyper-tmp
inside the workspace, with the configured workspace write boundary.
This protects file content and directory entries, not all metadata: on the tested
Linux kernel a workspace-write shell can still chmod an external audit file,
potentially denying future access. Read-only shells additionally use seccomp to
reject explicit permission, ownership, timestamp and xattr mutations. Linux direct read/write/edit, search and context now use anchored
openat2 descriptors; snapshots and modifications share the opened inode.
Symlink substitutions, magic links and nested mount crossings are refused.
Existing internal symlinks are resolved before opening. Unsupported Linux
kernels or syscall restrictions fail closed. macOS direct tools walk pinned directory
descriptors with single-component openat/O_NOFOLLOW calls and exclusive creation.
Reads, snapshot source bytes and mutations share the opened file. Cross-device
paths are refused, but same-device mount aliases and host directory moves remain
outside this guarantee. macOS path-scoped rules remain unsupported. Other
platforms retain path checks.
Search enumerates ignored-filtered text files and reads them through this same
entry point. Linux restore/undo pin snapshot and target directory descriptors,
stage the complete file outside the workspace, then atomically replace the target
entry; removal uses unlinkat. Other hardlink aliases are preserved. Restored bytes
and snapshot permission bits replace the target; ownership/ACLs/xattrs are not
reconstructed. The workspace parent must permit external staging on the same
mount as the target. Snapshot storage may be on another mount. Source or commit
errors retain the old target, though newly required directories can remain.
On Linux, standalone workspace::create_checkpoint now pins the resolved source
before reading and distinguishes a missing target from permission/link errors.
It shares the descriptor-based snapshot writer with direct file tools. The writer
pins the canonical output directory, creates new snapshot/temp names exclusively,
copies and syncs bytes and mode bits, then publishes the complete JSON manifest
with renameat2(RENAME_NOREPLACE). Existing entries are never overwritten; ordinary
errors attempt to remove only newly created entries. The output filesystem must
support that operation; there is no unsafe fallback. Manifests use mode 0600 and
snapshot paths are absolute, including for relative API roots/output paths.
The library API is a host administrative operation; its caller must choose trusted
storage. It does not apply agent approval rules, prevent same-inode concurrent
writes, or make workspace-writable storage authoritative. Abrupt termination can
leave orphan snapshots/temp manifests, and directory entries are not synced for a
power-loss durability guarantee. Non-Linux checkpoint creation keeps its earlier
path-based behavior.
Metadata isolation, remaining platform descriptor/restore boundaries and OS-level range isolation
remain pending. unrestricted
shells retain host permissions, including access to external state. See the
measured boundaries.
Shell tool stdin is closed; supply command input with pipes or redirection,
so a tool cannot consume TUI keyboard events.
--sandbox applies to CLI and TUI runs. The default is workspace-write:
on Linux, shell commands and their child processes use Landlock to confine
filesystem writes to the workspace and deny TCP connections. Both restricted
modes also use seccomp to deny external socket creation/connections and addressed
socket I/O, covering UDP and Unix sockets. Anonymous AF_UNIX socketpair and
address-free send/recv remain available for process IPC. read-only
also denies write/edit tools and shell writes, and on Linux rejects explicit
metadata mutation syscalls with EPERM. unrestricted explicitly
removes shell isolation and the dangerous-command check; tool permission
decisions still apply. For example:
ha --sandbox read-only run examples/hello.json
ha --approval allow --sandbox unrestricted "build this project"HYPER_SANDBOX sets the default for either interface; --sandbox overrides
it. The effective mode is recorded in run.started and shown in the TUI.
Workspace-write shell commands use .hyper-tmp for temporary files; read-only
runs do not create this directory. A kernel
without Landlock ABI 4, or a non-Linux host, rejects sandboxed bash instead
of silently running it without isolation. Both restricted modes additionally require
seccomp filtering on native 64-bit x86-64 or little-endian aarch64; unsupported
architectures or filter installation failures refuse to start the shell. The
filter also rejects compat/x32 syscall ABIs, io_uring, pidfd_getfd, ptrace and
process_vm_writev. Read-only additionally rejects ioctl. Socket-based build
servers and local network tests cannot run in restricted modes, even inside
the workspace; ordinary pipes and anonymous Unix socketpair still work. To run
shell commands on unsupported hosts, select
unrestricted explicitly.
This boundary limits writes and explicit socket syscalls. It does not revoke
generic read/write or address-free send/recv on connected sockets deliberately
inherited by a library caller, control shared mappings prepared by the host, or restrict every metadata
operation. Library callers must supply trusted inherited descriptors and use
Sandbox::apply_prepared_in_child; apply_in_child applies only Landlock.
Workspace-write metadata isolation remains pending. Read-only restrictions cover explicit mutation
syscalls, including fchmodat2 and new xattr-at/file_setattr calls, inherited by
threads and child processes; normal reads may still update access times and locks
are not forbidden. Commands can still read files
outside the workspace. Shell commands in unrestricted mode run with the
calling user's privileges. Direct read/write/edit tools continue to use
workspace path checks in every mode.
{
"name": "hello",
"steps": [
{
"id": "greet",
"mode": "build",
"instruction": "bash:echo hello from harness"
}
]
}Supported instructions: bash:, read:, search:, write:, and edit:.
Plan mode is read-only.
write: takes the content from the lines after the path, so the format is
path\ncontent. A trailing newline is therefore meaningful: "write:a.txt\n"
writes an empty file, while "write:a.txt" (no content line at all) is rejected
rather than silently emptying an existing file. edit: expects
path\nsearch\nreplace and replaces the first occurrence of search.
The model's edit tool is stricter than the instruction: when search appears
more than once it requires an occurrence (1-based) and reports the matching
line numbers instead of silently editing the first block, and it refuses a file
whose bytes changed since the run read them (stale edit). read reports a
workspace file's sha256, which the model can pass back as expectedHash to pin
the exact content it edited.
read also accepts a 1-based line window: line alone reads to the end of the
file, and an optional lines bounds the count. The result carries
startLine/endLine/totalLines, and truncated marks a window cut by the end
of the file or the per-read cap. A byte offset and a line window are
mutually exclusive; the whole-file sha256 is returned either way.
Each read returns about 3 KB (3200 JSON-escaped bytes) so the whole result
fits in one model observation instead of being cut in the middle. A line window
is cut at whole lines and reports nextLine; a byte read is cut at a character
boundary and reports nextOffset. The model continues from there rather than
re-reading.
A step whose instruction has no tool prefix runs the tool-calling agent:
the model inspects the workspace context, calls tools (read, search,
bash, write, edit) in a loop, and feeds each result back until it
produces a final answer (capped at 12 turns). A model that repeats the same tool
call with the same failure three times in a row is stopped with an
agent.repeated_failure event instead of spending every remaining turn. In plan
mode the model only sees the read-only tools. The optional per-step tools
field acts as an allowlist: "tools": ["read", "search"] restricts that step to
the listed tools.
A model step can declare explicit lint/test commands to run once the model says
it is done. They run through the same policy, approval, sandbox, timeout and
resource limits as a bash tool call; the first non-zero exit is handed back to
the model as the next user turn so it can fix the cause, up to retries times
(retries + 1 attempts total, retries capped at 5). Verification is a build-
step feature — a plan step or a direct bash:/read:/… instruction has no model
loop to feed a failure back to and is rejected by validation. Attempts and
results are recorded as verify.started/verify.finished, and the feedback is
recorded as model.verification so replay stays exact. A step whose
verification still fails after its retries fails with VerificationError.
{
"name": "fix and test",
"steps": [
{
"id": "build",
"instruction": "make the failing test pass",
"verify": { "commands": ["cargo test"], "retries": 1 }
}
]
}On Linux, every bash process receives a default limit of 8 GiB virtual
address space and 1 GiB per output file. Its CPU time limit defaults to the
step's wall timeout rounded up to seconds plus two seconds. A step can override
each value without changing the others:
"timeoutMs": 30000,
"limits": { "memoryMb": 2048, "fileMb": 128, "cpuSeconds": 20 }limits applies only to bash, including its descendants. These are
per-process limits inherited by child processes, not a total quota for the
process tree or workspace. Values of zero are rejected. An inherited tighter
limit remains in force. Explicit limits on non-Linux hosts are rejected.
Runs are stored outside the checkout. ha state prints the authoritative paths
as JSON. Linux defaults to $XDG_STATE_HOME/hyper/workspaces/<workspace-key>
(or ~/.local/state/hyper/...); other platforms use the user data directory when
no state directory is available. HYPER_STATE_DIR selects an absolute base outside
the workspace; symlinked registries and storage inside the workspace fail closed.
The key is SHA-256 of the canonical workspace path. Unix registry/store directories
are owner-only. The checkout supplies no locator, symlink or state identity.
ha state
# In a legacy checkout, before other commands and after stopping old runs:
ha migrate-state --from .harness
# In a fresh moved/restored checkout, before initializing destination state:
ha migrate-state --from /absolute/path/to/previous-storage-or-backupMigration is explicit: existing .harness data is never imported automatically.
It copies fresh inodes, snapshots SQLite including committed WAL data, validates
records/schema, rebinds checkpoint paths and commits by atomic directory rename.
The source remains unchanged; temporary legacy files are excluded. Invalid data,
symlinks, active run locks and open source workspaces are refused. Stop older
binaries and other source writers before copying/importing, since they do not
participate in the new shared lease. Imports never overwrite initialized state.
For backups and workspace moves, save the path from ha state, stop writers,
copy that complete external directory and the checkout, then import explicitly
before running in the destination. Checkpoints use relative target paths; model
request history retains the original messages for replay. State is intentionally
not carried by Git or located through a writable checkout file.
The external directory keeps the familiar layout:
<storageDir>/
workspace.json
migration.lock
harness.db
runs/<run-id>/
events.jsonl
task.json
summary.json
lock
artifacts/
checkpoints/
sessions/<session-id>.jsonl
sessions/<session-id>.compactions.jsonl
JSONL remains the audit log; SQLite provides the local run/event index and the
conversation registry (sessions table: title, turn count, run count, last
update). A session id is also a file name, so it is restricted to letters,
digits, - and _.
runs/<run-id>/lock is an advisory lock held for the lifetime of the run. Every
Hyper startup checks the runs still marked running: if a run's lock is not
held, the process that owned it is gone, so the run is rewritten as
interrupted — with a run.interrupted event and a summary.json — instead of
lingering as running forever. Runs that are still executing keep their lock and
are never touched.
Every startup also reconciles the index with the log. A run whose
events.jsonl holds events the database does not — a harness.db that was lost
or copied mid-run — is indexed again from the files, and a run with no row at
all is recreated from its task.json. The log is written before the index, so
an event that reached the files cannot stay unrecorded.
bashdrains stdout and stderr while the command runs, so a command that prints more than the OS pipe capacity cannot deadlock. The event keeps at most 256 KiB per stream — it setstruncatedand reports the real byte counts — while the reader holds up to 4 MiB per stream so the output can be filed underartifacts/instead. Past that cap the bytes are dropped as they arrive, so a runaway command cannot exhaust memory.- A command that exceeds its timeout is killed as a whole process group and
reported as
TimeoutErrorwith"timedOut": true, which stays distinguishable from an ordinary non-zero exit. On Linux the shell additionally dies with the harness (PR_SET_PDEATHSIG), so a crashed orkill -9ed harness does not leave commands running — although processes started by that shell can still outlive it. - On Linux,
bashalso starts withRLIMIT_AS,RLIMIT_FSIZE, andRLIMIT_CPU. The configured values are included intool.startedandtool.finished; a CPU or file-size limit signal is reported asResourceLimitError. Memory allocation failures can be reported by the program as an ordinary non-zero exit; inspect its stderr and the recorded memory cap. ha artifactslistsruns/<run-id>/artifacts/, which everybashcall writes to: one file per non-empty stream, named<step>-<index>-<invocation>-bash-stdout.log(up to 4 MiB each, with a marker where it was cut short). For output between 256 KiB and 4 MiB, the artifact retains text omitted from the event. Output beyond 4 MiB is not retained. Each invocation has a unique filename. The model can pass an artifact path returned bybashtoread, with an optional nonnegative byteoffsetto read later chunks (about 3 KB per read, continuing fromnextOffset). This access requires the ordinaryreadpermission and is limited to artifacts issued by the current run.readresults are not copied — the whole file is still in the workspace — and the observations handed to a model are derived from payloads already in the log.- The dangerous-command check is a lightweight denylist over shell words
alongside the default Linux shell boundary. It rejects common accidents:
rm/shred/chmodand redirections aimed at/, the home directory, the workspace root or a system directory; machine-level programs (sudo,dd,mkfs*,fdisk,shutdown,systemctl, …);curl … | sh; and the same commands hidden one level down insidesh -c '…',sudo,env,timeoutorxargs. Quoting and command substitution are parsed rather than string-matched, sorm -rf targetandcurl -o f.tar.gzstill pass the parser. The parser itself is not a containment boundary. CLI and TUI apply the same tool permissions on top of the execution boundary. The explicitunrestrictedmode skips this check. - The workspace context sent to the model contains repository file contents, so a repository can influence the model's actions (prompt injection). Run Hyper on code you trust.
.github/workflows/release.yml runs on v* tags. It builds the five supported
targets, attaches the archives to a GitHub Release, and publishes the npm
channel.
The npm channel is hyper-harness plus one package per platform
(hyper-agent-linux-x64, hyper-agent-darwin-arm64, …), each holding the
hyper binary built by the same workflow, so the npm and GitHub Release
binaries are byte-identical. The main package lists the platform packages as
optionalDependencies and ships only a small Node shim
(npm/bin/hyper.js) that locates the right binary and hands over stdio and the
exit status; it runs no lifecycle scripts and downloads nothing at install time.
ha is linked to the same shim.
Publishing needs an NPMJS_TOKEN repository secret, passed to npm as
NODE_AUTH_TOKEN. Use a classic Automation token (Access Tokens → Generate
New Token → Classic → Automation), or a granular access token with Bypass
two-factor authentication enabled and read/write access to all packages — a
token scoped to hyper-harness* cannot be created before those packages exist. A
classic Publish token does not work unattended: npm rejects it with EOTP,
because using it to publish requires a one-time password.
Platform packages are published first, and the main package only once every one
of them is actually retrievable: npm acknowledges a publish while the upload is
still queued ("Your package is being processed and may take a few minutes to
become available"), and an optionalDependency that cannot be resolved yet is
skipped silently — which would leave an installed hyper-harness with the
shim but no binary.
The workflow stages and smoke tests the packages before uploading, and skips
versions that are already on the registry, so a partially failed release can be
re-run with gh run rerun <run-id> --failed. A manual run of the workflow does
the staging and smoke testing only, unless "Publish to npm" is checked — use it
to rehearse a release without spending a version number.
Maintainers edit npm/platforms.json to add a platform; it is the single source
of truth for the package names, npm os/cpu fields, and the release archive
each package is built from.