Skip to content
bitty-terminalPublic

About

Wheel — the agent harness for the Bitty terminal (mascot: Bittie the hamster). Independent, pre-integration.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

83 Commits

Folders and files

Repository files navigation

Wheel

Wheel — the coding-agent harness for the Bitty terminal (mascot: Bittie the hamster). Independent out-of-process harness (lua/wheel/) for the 0.1.0 window.

Documentation & Ecosystem (https://wheel.bitty.run): Because Wheel's configuration surface, multi-agent runtime, and companion plugins are extensive, this README.md stays concise as the repository and command-surface overview. Full configuration guides, architecture deep-dives, and Wheel-related plugins will live on the dedicated https://wheel.bitty.run documentation and ecosystem site (hosted from this repository). See SECURITY-MODEL.md, CONTEXT-ARCHITECTURE.md, and CONTEXT-SNAPSHOT.md for normative specifications in-tree.

Overview

  • Independent harness process (Option B). Wheel runs as its own OS process under the user's authority, governed by SECURITY-MODEL.md. A Bitty panel or terminal supplies presentation and input only.
  • Software-engineering domain only. Roles (Primary, Commander, Coding, Debug, Research, Reviewer) vary by configuration and capability bindings (RoleBinding + monotonic policy_generation), never by class explosion.
  • One artifact for 0.1.0. dist/wheel-0.1.0.tar.gz ships the Lua module tree and core reference docs. The in-tree bitty-plugin.toml is retained only as a transitional artifact and is not the 0.1.0 distribution or authority model.
  • Opt-in OS-level sandbox. wheel --sandbox … runs the session behind a platform backend (Linux: bubblewrap) with a read-only system tree, one writable workspace, no $HOME, and no network route unless the operator allows specific destinations through a credential-injecting host relay. See OS-level sandbox.
  • Daemon ownership stays with bittyd. Final session hosting, IPC, attach/detach, lease generation, and worker supervision belong to bittyd. Wheel consumes that contract through the replaceable transport-injectable WheelBittydAdapter (lua/wheel/bittyd_adapter.lua); scripts/wheel-session remains a local development prototype.

Install

Build, verify, and install the standalone 0.1.0 harness archive locally (offline after just install):

just install                        # bun install --frozen-lockfile (one-time dev setup)
just package                        # builds dist/wheel-0.1.0.tar.gz + .sha256 + .manifest.json
just install-local "$HOME/.local"   # installs under <prefix>/wheel/0.1.0 and switches current
just rollback-local "$HOME/.local"  # switches current back to the recorded previous version

Launch against the Lua 5.1 module root:

LUA_PATH="$HOME/.local/wheel/current/lua/?.lua;$HOME/.local/wheel/current/lua/?/init.lua;;" \
  lua5.1 -e 'local wheel = require("wheel"); print(wheel.command_catalog[1].id)'

Or run the standalone daily-driver CLI (scripts/wheel):

./scripts/wheel init                      # scaffold XDG config/data stores (0700/0600)
./scripts/wheel providers                 # list built-in templates (opencode-go, openai, anthropic, deepseek, openrouter, ollama)
./scripts/wheel config show               # show effective config with precedence metadata
./scripts/wheel auth set opencode-go      # store credential via stdin/tty into $XDG_DATA_HOME/wheel/credentials.json (0600)
./scripts/wheel ask "Summarize this repo" # single-turn completion
./scripts/wheel run --max-turns 24 "Fix failing tests"  # ReAct tool-loop run with interactive allow/ask/deny gate
./scripts/wheel chat                      # interactive REPL (/thinking, /exit)

OS-level sandbox

wheel --sandbox <command> runs the harness inside an OS-level sandbox instead of with the invoking user's ambient authority. The sandbox is a policy layer with per-platform backends; the Linux backend uses bubblewrap (bwrap).

./scripts/wheel --sandbox run "Fix the failing test"                    # no egress at all
./scripts/wheel --sandbox --proxy --allow api.example.com -- ask "hi"   # allowlisted egress
  • What the session gets: the workspace read-write at its own path, one per-session scratch directory mounted at /cache (and exported as TMPDIR, CARGO_HOME, and the XDG_* roots), read-only /usr, /etc, /bin, /sbin, /lib, /lib64 (plus the harness tree itself, read-only, when it lives outside the workspace), a private /proc, a fresh /tmp, and a private PID/UTS/IPC/user namespace. $HOME is never set and no runtime tree is mounted, so SSH and cloud credentials, ~/.config/wheel, shell rc files, the Wayland/D-Bus/PipeWire sockets, /run/user/*, and the Docker/Podman socket do not resolve; the launcher also refuses a workspace anywhere under /run or $XDG_RUNTIME_DIR, so they cannot be bound in by pointing --workspace at them. Git metadata is the one protected corner of the writable workspace: each git directory is self-bound so it cannot be renamed or replaced, .git/hooks is masked with an empty reserved directory, .git/config is read-only, and a linked worktree's .git file cannot be repointed. .mcp.json and credential-shaped paths inside the workspace are masked the same way.

  • Network: the default mode is netless — loopback only, no resolver, no route. --proxy adds the single road out: a host-side CONNECT relay over a bind-mounted Unix socket with a default-deny allowlist (WHEEL_SANDBOX_ALLOW), per-request logging, bounds, and relay-side credential injection bound to WHEEL_SANDBOX_AUTH_HOSTS, so OPENCODE_GO_API_KEY never enters the sandbox environment and never reaches a host or port outside that list. Both lists name one host and one port: a bare entry means 443 and does not authorise subdomains.

  • Fail-closed: the launcher refuses to start when bwrap is missing and never falls back to an unsandboxed run.

  • Configuration continuity: inside the sandbox the harness starts with an empty configuration, credential, approval, and trust store under /cache, because the owner's $XDG_* state is not mounted. Provider access is the relay's job.

  • Requirements and evidence: bwrap, python3 for proxy mode, and openssl for proxy-mode session certificates. just test-sandbox runs the escape tests; WHEEL_SANDBOX_REQUIRE=1 just test-sandbox runs them as a hard gate instead of skipping without bwrap, and the Sandbox escape tests CI job does exactly that on a pinned image (the generic gate also executes the suite where bwrap is present). SECURITY-MODEL.md records what is still unprotected.

  • Platforms: Linux native today — scripts/wheel-sandbox runs the bwrap backend with the allowlisted egress relay. macOS runs the core POSIX surface only; the sandbox backend (Seatbelt) is not implemented, and --sandbox fails closed there because the launcher refuses to start without bwrap. Windows is WSL2 only: the Linux backend runs inside WSL2, and native Windows fails closed at seam construction — the standalone host seam (lua/wheel/host.lua) raises E_CAPABILITY_DENIED on a non-POSIX platform — and no native process backend is planned.

  • Gate interpreter: Lua 5.1 (lua5.1 primary release gate; luajit and lua development fallbacks with JIT disabled for evaluated project-config chunks).

  • Platform: POSIX hosts with GNU coreutils, util-linux (setsid), tar, and gzip.

Commands

Wheel exposes 14 commands declared in lua/wheel/init.lua (M.command_catalog). Every command validates arguments against a closed schema before running and returns a bounded { title, body } projection (title <= 64 bytes, body <= 8000 bytes).

Daily-driver CLI flags

wheel ask, wheel run, and wheel chat accept the flags below. Each subcommand prints its own usage with wheel ask --help, wheel run -h, wheel chat --help, or wheel help <command>, and exits 0 without contacting the provider. Unknown options are usage errors (exit 2), never prompt text.

Flag Commands Behaviour
--provider <name> ask, run, chat Selects a built-in provider template; defaults to the configured provider.
--model <name> ask, run, chat Model name or provider/model; outranks role config and the provider default (see model precedence below).
--thinking <gear> ask, run, chat Thinking gear: off, low, medium, high, or max.
--stream/--no-stream ask Stream the response (default) or wait for the complete response.
--workspace <dir> run Workspace root for tools; defaults to the current directory.
--approval-mode <m> run prompt (default), dashboard, or auto-deny.
--auto-deny run Shorthand for --approval-mode auto-deny.
--max-turns <n> run Turn budget, integer 1..200, default 24.
--trace, --verbose run Print one stderr line per tool call: tool name, outcome status, exit code, stdout/stderr byte counts, and the first redacted, bounded observation line.
-- all End option parsing; everything after it is prompt/task text.

Model precedence (resolved once in WheelAgent.resolve_model; applies to wheel run and the agent API, while wheel ask/wheel chat use --model or the provider's configured/template model without role-model resolution): (1) opts.model_profile (strict complete override). (2) --model/opts.model — a string is an opaque model id for the resolved provider, except a provider/model prefix that names a known provider and is compatible with the selection (no provider selected, or the prefix equals the selected/active provider); a table honours name/model, its provider claim when present, and temperature, an explicit table temperature applies to the final profile, and a table without a name is not a selection (tuning is kept and resolution continues). (3) roles.<role>.model_profile when it names the active provider or no provider (a complete override that is validated, not a skippable claim). (4) roles.<role>.model — a bare name applies to the active provider; a provider/model string or table naming a different provider is a foreign claim and is skipped; role model tables prefer model, while opts.model tables prefer name. (5) The provider's effective default model (provider config model, then template default). The built-in role default supplies the remaining profile fields and is the model fallback only when the provider has no default model; an active provider with no default model and no usable role model fails with the typed E_MODEL_PROVIDER_UNRESOLVED error instead of inheriting another provider's id.

wheel run exit codes: 0 the model produced a final answer inside the turn budget; 1 provider, persistence, or run failure; 2 usage/validation error; 3 turn budget exhausted before a final answer (workspace changes already written are kept and the run is not resumed; the message counts any tool calls that failed on the final turn instead of denying them).

Command Invocation Arguments schema Result contract
hello bitty-terminal.wheel:hello No arguments; closed object, no properties. { title, body }
status bitty-terminal.wheel:status No arguments; closed object, no properties. { title, body }
graph bitty-terminal.wheel:graph No arguments; closed object, no properties. { title, body }
plan bitty-terminal.wheel:plan No arguments; closed object, no properties. { title, body }
run bitty-terminal.wheel:run No arguments; closed object, no properties. { title, body }
trust bitty-terminal.wheel:trust Optional object: action (show/confirm/revoke), hash, path. { title, body }
team bitty-terminal.wheel:team No arguments; closed object, no properties. { title, body }
context bitty-terminal.wheel:context No arguments; closed object, no properties. { title, body }
tools bitty-terminal.wheel:tools No arguments; closed object, no properties. { title, body }
orchestrate bitty-terminal.wheel:orchestrate No arguments; closed object, no properties. { title, body }
models bitty-terminal.wheel:models No arguments; closed object, no properties. { title, body }
branch bitty-terminal.wheel:branch No arguments; closed object, no properties. { title, body }
checkpoint bitty-terminal.wheel:checkpoint No arguments; closed object, no properties. { title, body }
reflog bitty-terminal.wheel:reflog No arguments; closed object, no properties. { title, body }

Configuration

This plugin declares no settings.

Wheel harness configuration

Configuration is resolved by lua/wheel/config.lua across deterministic precedence (session_override > trusted_project > global_config > $XDG_DATA_HOME/wheel/settings.json > WheelConfig.RUNTIME_DEFAULTS) alongside $XDG_CONFIG_HOME/wheel/init.lua (plus modular providers/*.lua, agents/*.lua, commands/*.lua, tools/*.lua, and skills/*/SKILL.md under $XDG_CONFIG_HOME/wheel/) and .wheel/init.lua gated by the executable project-config trust gate pinned in $XDG_STATE_HOME/wheel/trusted_projects.json (see SECURITY-MODEL.md). Project .wheel/ overrides reject api_key, credentials, base_url, and permission weakening (project_config_escalation, including keeping approval_mode no weaker than auto-deny). Credentials resolve by session_override > env_var > global_config_provider_key > $XDG_DATA_HOME/wheel/credentials.json > "". Built-in provider templates (WheelProvider.TEMPLATES), unified thinking settings (thinking, thinking_enabled, thinking_gear), and interactive PermissionGate approvals (allow|ask|deny, with --approval-mode prompt|dashboard|auto-deny and cross-process $XDG_DATA_HOME/wheel/approvals.json inspected via wheel approvals [list|resolve]) govern daily execution. Comprehensive configuration examples and plugin docs will be published at https://wheel.bitty.run.

  • Function classes (lua/wheel/config.lua schema):
    • roles — role definitions, tool allowlists validated against the tool registry at agent construction, and model profile references.
    • directives — structured prompt directives applied across roles.
    • tools — tool allow/deny lists and custom tool declarations.
    • skills — session skill filters discovered from .agents/.
    • verification — change-gated verification declarations and test commands.
    • context — Three-Zone context budgets (64 KiB total: 16 KiB Zone 1, 32 KiB Zone 2, 16 KiB Zone 3), the 4 KiB run_command spillover threshold, and observation_max_bytes (default 8 KiB), the model-facing tool observation window. The window is clamped by zone3_max_bytes so it can never exceed the Zone 3 prompt budget; a result that fits the window reaches the model complete, and a larger one spills to the content-addressed blob with a marker naming the dropped bytes and the blob hash.
    • panel — Headless Panel working-container policy.
    • hooks — lifecycle hooks.

Keybindings

Wheel exposes commands, not keybindings. The Bitty host owns keybinding registration and dispatch, so Wheel registers no default keybindings and claims no key conflicts.

Troubleshooting

Command error contract

Every command crosses the typed failure boundary in lua/wheel/errors.lua and surfaces a three-field { class, code, message } table:

code class Meaning
E_CAPABILITY_DENIED runtime The host removed a surface the command needs. The message names the missing capability family.
E_INTERNAL runtime The handler failed unexpectedly. The message is generic and never describes the underlying defect as a capability.
E_ARGS_INVALID validation Arguments did not match the command's closed args_schema; the handler did not run.
E_SCHEMA_INVALID validation A command's args_schema or result_schema was malformed or unbounded at registration.
E_RESULT_INVALID validation A handler result did not match its closed result_schema.
E_COMPLETION_BUDGET_INVALID validation A completion-token bound override was zero, negative, non-integer, non-numeric, or above the named maximum.
E_TURN_BUDGET_EXHAUSTED budget A run stopped at its turn limit before a final answer; wheel run exits 3, keeps already-written workspace changes, and does not resume.
E_AGENT_TOOL_UNKNOWN validation A configuration-derived role tool list names unregistered tools, is map-shaped, or is not a dense array; agent construction fails closed with a bounded diagnostic.
E_MODEL_PROFILE_INVALID validation A model profile (explicit or role-configured) is malformed, e.g. a non-string provider or out-of-range temperature; model resolution fails closed.
E_MODEL_PROVIDER_UNRESOLVED resolution The active provider has no default model and no usable role model; pass --model or configure providers.<name>.model.
E_SNAPSHOT_INVALID validation A WheelContext snapshot failed format, bounds, hash, ref, reflog, or commit-graph validation; no context was built.
E_PROJECTION_INVALID validation A role-aware Context projection received malformed, cyclic, unsupported, out-of-scope, or over-budget input and failed closed.
E_MODULE_LOAD_FAILED resolution A Wheel submodule could not be loaded; the message names the rooted module and a bounded, path-free cause.
E_AUDIT_UNAVAILABLE runtime A local audit record could not be written; the message is static and never includes a path, value, or filesystem diagnostic.
E_JOB_NOT_FOUND runtime The requested job record or its private root does not exist; no signal was sent.
E_JOB_METADATA_INVALID runtime A job record is malformed, unowned, wrongly moded, oversized, or names an invalid id/generation; no signal was sent.
E_JOB_GENERATION_MISMATCH runtime The recorded leader generation, process group, session, or owner uid does not match the live retained leader; no signal was sent.
E_JOB_NOT_RUNNING runtime The job did not reach running, or its retained leader already exited without a terminal record; no signal was sent.
E_JOB_BUSY runtime The bounded terminal-transition lock stayed held; the request was refused rather than racing the transition.
E_JOB_SIGNAL_FAILED runtime The recorded process group could not be signalled after validation; the failure is reported without a fallback pattern kill.
E_JOB_UNAVAILABLE runtime The private job root, random source, capture file, or bounded sleep is unavailable; no weaker execution path was used.
E_JOB_CLEANUP_FAILED runtime A terminal job's private files could not be removed; the record was kept for diagnosis and no other path was deleted.

Configuration failures

Named configuration failures returned by lua/wheel/config.lua: untrusted_project_config, project_config_rejected, project_config_eval_error, project_config_escalation, and data_settings_rejected.

Development

just install                  # bun install --frozen-lockfile
just check                    # lint, fmt-check, manifest, docs-check, lua parse, bittyd conformance, unit & offline suites
just test-bittyd-conformance  # run pinned Core bittyd-conformance-corpus/1 (V-29, V-30, V-33) against WheelBittydAdapter
just test-sandbox             # OS-level sandbox escape tests (requires bwrap)
just test-real-host           # opt-in real-host fixture (requires lua5.1)
just verify-package           # deterministic package build, install, upgrade, rollback, and refusal checks

About

Wheel — the agent harness for the Bitty terminal (mascot: Bittie the hamster). Independent, pre-integration.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages