docs/cmd/ez-agent.md

ez-agent client

ez-agent opens the TUI over a local socket or SSH, connects that TUI through AgentHub, or runs scripted CLI operations. Parsing lives in pkg/cli, connection setup in internal/frontend, and presentation in pkg/tui.

Modes

InvocationMode
ez-agentTUI using saved startup preferences, initially the local daemon
ez-agent --connectionsTUI connection manager
ez-agent --via user@hostTemporary SSH TUI with Auto socket discovery
ez-agent --socket /path/to/socketTUI on an explicit local socket
ez-agent --connection <name-or-id> [--cwd <dir>]TUI on a saved connection
ez-agent --hub [target] [--cwd <remote-dir>]AgentHub connection into the existing TUI
ez-agent -p '…'Scripted local prompt
ez-agent --list-sessions or another actionLocal inspection/management CLI

The built-in Local daemon connection autolaunches by default; its TUI preference or --no-autolaunch makes an unavailable daemon an error. Custom sockets and SSH never start a service. Hub mode must be the first argument, never starts or contacts the local daemon, and rejects local actions/autolaunch flags. A target may be a saved alias, last, exact address, or new host:port.

Local and remote TUI modes both inherit command SIGINT/SIGTERM cancellation, including while the client-local /hub dashboard owns the terminal. Healthy intentional /quit and keyboard Ctrl-C return exit 0 after joined shutdown. Known pressure and other failed transport/drain results still return failure; a local-close sentinel alone is not an application failure. External signals can close a Hub tunnel before draft-helper deletion, unlike terminal Ctrl-C or /quit. See TUI cleanup behavior.

In chat, click a local-port forwarding link, or focus chat and use Tab or Shift+Tab to select a link and Enter to activate it. Review and approve the link before the TUI binds a client-local port. Ctrl+T is an optional link chooser. /tunnels lists and manages all active and pending forwards, which also appear in Inbox. See TUI port forwarding for the exposure and path rules.

In scripted CLI mode, SIGINT or SIGTERM cancels the client's context and closes its connection, releasing a pending RPC or prompt-event wait. The CLI reports the interruption as an error and exits with status 1. On SIGINT, it also prints Continuing in background. to stdout. SIGTERM does not print that notice. Neither client exit nor connection loss aborts accepted agent work or stops the daemon. Ctrl-X in the TUI is the separate agent-abort action.

TUI connections and directories

/connections opens the connection manager without changing the current session. Add saved local sockets or SSH destinations, edit or delete profiles, and choose which connection opens by default. With only the built-in Local daemon enabled, startup opens it directly. With other saved connections and no explicit default, startup shows the manager. --connections always shows it. An explicit --connection, --socket, or --via overrides saved startup choices.

These are client-only preferences in tui.yaml, not daemon or provider settings:

  • Enable local controls whether the built-in Local daemon is available. When disabled, ordinary startup neither probes nor starts it. Explicit custom sockets remain available.
  • Start local automatically controls autolaunch independently. Disable it when the service needs to be started manually with special parameters. --no-autolaunch also disables autolaunch for the current invocation.
  • Open by default chooses a saved connection for startup. Disabling or deleting that destination clears its default.

The Add form's Save connection checkbox distinguishes saved profiles from connections that exist only until disconnected. --via and explicit --socket connections are temporary and do not write connection or directory/leaf recency. Temporary applies to TUI connection state; OpenSSH's normal known_hosts policy still applies. The sidebar shows the configured connection name; its CWD row opens the directory picker. /cwd opens the same picker, and /cwd /absolute/path selects a directory without moving an existing session. A standalone --cwd also opens the TUI.

Only one connection is active. Opening another closes and joins the previous client connection first; server-side agent work continues. Disconnect returns to the manager. Quit exits the TUI. Switching requires an empty composer and no unresolved submission or directory mutation, rather than discarding a draft. There is no multi-connection background monitoring or cross-connection Inbox. Within the active connection, Inbox groups entries under working-directory headings, with the current directory first. Its first row switches between All directories and Current directory. Sessions remains CWD-filtered. Opening an Inbox item in another directory changes CWD and selected leaf together through the service API, without moving the session or clearing its alert.

sh
1ez-agent --via user@host
2ez-agent --via office --socket /custom/ez-agent.sock --cwd /workspace/project
3ez-agent --socket /run/user/1000/ez-agent/ez-agent.sock
4ez-agent --connection Office

For SSH, Auto discovers $XDG_RUNTIME_DIR/ez-agent/ez-agent.sock from the remote login environment before forwarding. This requires an SSH command channel in addition to Unix-socket forwarding. Restricted accounts and login environments without XDG_RUNTIME_DIR may not support it. Discovery failure requests an explicit socket path; it never guesses the local runtime path or starts a remote service. Discovery and forwarding can require separate authentication prompts.

OpenSSH uses the client's SSH configuration, keys, agent and host-key policy. When authentication requires a password or passphrase, the TUI displays a masked prompt. Host-key confirmation remains an explicit identity check. Answers are never saved with profiles. Cancelling retires the owned SSH process and forward.

AgentHub mode

AgentHub is unreleased and opt-in. Normal distributions omit ez-agent-hub. To enable Hub commands, install a regular, executable ez-agent-hub beside the real ez-agent executable. Client install symlinks are followed; a real client with a .exe suffix uses ez-agent-hub.exe. Detection never searches PATH, starts a process, probes sockets, reads credentials, or creates state. There is no configuration, environment override, or alternate build variant.

This marker is a temporary release policy, not an architectural dependency. Remote access does not require a local Hub daemon. Without the marker, normal CLI help omits Hub sections and examples, and the TUI hides /hub from its command reference and completion. --hub, --hub --help, and the offline bookmark controls fail with fixed unavailable guidance before state or any local/remote connection is opened. An exact typed /hub reports the same guidance, never a model prompt or macro. Local prompt text such as -p --hub and slash prose such as /hub explain this retain normal parsing.

The following Hub flows apply to opted-in installations.

sh
1ez-agent --hub
2ez-agent --hub office
3ez-agent --hub hub.example:443 --cwd /workspace/project

Bare --hub always waits for deliberate chooser input. Explicit targets bypass the chooser, not required admission. New admission and Add agent display the client claimant card before dialing, authenticate independently supplied Hub or endpoint checks, read secret JOIN WORDS without echo, and wait for owner approval after durable ACK. Admission and endpoint access are separate grants.

For voice/manual entry, KEY CHECK is four public words plus their mandatory byte, entered as word_word_word_word and two lowercase hex digits. JOIN is five secret invitation words, entered separately without echo. A full fingerprint is 64 lowercase hex digits obtained independently from the owner. It may stand alone when both short fields are blank; when both forms are supplied, all values must agree. No expiry, raw SPKI, machine blob or QR input is required. Malformed or contradictory input stops locally without quoting entered values. Zero directory matches stop before endpoint JOIN input or a claim; multiple matches require an independently supplied full fingerprint selecting exactly one match. Candidate fingerprints are diagnostics, not independent authenticators, even if confirmed on screen. A generic TLS or transport failure does not prove a mismatch. Verify the intended address and independently supplied public checks with the owner; do not replace them with values learned from the failed connection.

Saved Hub history includes every configured address, its accepted fingerprint and ordinary-success recency. Recognized-revoked Hubs remain visible. Selecting one requires readmit or cancellation; it cannot open an ordinary connection. To recover an interrupted admission or request fresh admission to any saved Hub, run bare --hub, type readmit, choose the exact numbered address row, then confirm readmit. A retained claimed credential is recovered without JOIN WORDS. A retained nonapproved completed decision offers recover, fresh, or cancellation; fresh keeps the old decision record and starts only the newly entered invitation. Otherwise enter a fresh owner-issued invitation locked to this client's claimant card and the identity check matching the saved pin. Keep the saved trust; do not erase it to force first-contact onboarding. Owner approval after durable ACK is still required. Generic transport failure does not confirm revocation and never starts an invitation automatically. Unrelated new Hubs cannot be onboarded into a populated saved-Hub store.

Saved approved endpoints remain visible as offline when discovery or a usable route is missing. Recognized revocations appear as revoked, including after restart; neither status is selectable. Add agent remains available with an empty directory, but a zero-match identity check stops before JOIN WORDS or an endpoint connection. A fresh approved onboarding replaces revoked state.

Saved aliases and recency are convenience, not trust. Ctrl-C closes the current prompt or connection without rolling back durable protocol state; an unambiguous pending request can resume at its exact saved address and pin. The direct-handshake review owns ceremony and recovery ordering.

After application open, the existing typed client and TUI run unchanged. There is no pre-TUI root/leaf chooser or remote RPC mapping. Explicit --cwd wins; otherwise the TUI uses the endpoint's remembered remote CWD, then leaf recency for the exact endpoint/CWD pair. Missing CWD fails before hello. Remote paths are never inspected locally. The chooser and transport UX extend in place.

Client-local Hub dashboard

In an opted-in installation, /hub opens localHub in either local or remote TUI mode. This is the Hub dashboard on the machine running this ez-agent client. It does not administer the remote application's Hub. The command runs the shipped sibling ez-agent-hub --config, without a PATH fallback, remote executable path, application RPC, second application client, or service autostart. It inherits the client's local working directory and XDG environment, never the remote CWD or selected Hub address. The command list and borrowed-terminal introduction disclose this distinction. The introduction directs you to follow the dashboard prompts, using quit in an existing dashboard or Enter to cancel at the first-run bootstrap prompt.

The dashboard owns local socket selection, offline bootstrap and lock rules. An empty local installation asks for bootstrap; press Enter to cancel without changing files. An existing dashboard accepts quit to return. Normal return and dashboard errors restore the same TUI, application connection and selected leaf. Dashboard lookup checks the sibling again before borrowing the terminal; missing or unusable binaries leave the TUI usable. Shutdown or application disconnect cancels and joins the dashboard child before terminal restoration and the existing joined application shutdown. It does not wait for the operator to dismiss a dashboard after disconnect.

Local remote bookmarks

When enabled, these controls work offline and exit without opening a Hub, local daemon, remote application, or terminal UI:

sh
1ez-agent --hub --bookmarks
2ez-agent --hub --select-bookmark <endpoint-fingerprint> --cwd '<exact-remote-cwd>'
3ez-agent --hub --forget-bookmark <endpoint-fingerprint> --cwd '<exact-remote-cwd>'

--bookmarks lists existing exact endpoint/CWD pairs from the TUI's tui.yaml. The endpoint is its full 64-character lowercase fingerprint, not a Hub address, alias, or server ID. CWD and leaf values are quoted with escaped terminal controls and line breaks. Selected marks the remembered startup CWD for each endpoint. A remembered CWD with no leaf is still listed.

--select-bookmark selects an existing exact pair as that endpoint's remembered CWD. Then connect normally with ez-agent --hub or ez-agent --hub <target> and deliberately choose the Hub and endpoint. Selection never chooses a Hub or grants access. The TUI resolves the selected CWD and its leaf before hello. Explicit --cwd still overrides that default, and a stale saved leaf follows the ordinary TUI validation and creation policy.

--forget-bookmark removes only that exact pair's local leaf recency. If it was the selected CWD, forgetting also clears the endpoint's default without selecting another CWD. Other endpoints, other CWDs, local session recency, and sidebar preferences stay unchanged. Pins, approvals, and remote sessions are untouched. A later normal TUI visit can remember the pair again.

Selection and forgetting require an existing pair and reject near matches. CWD bytes remain opaque, with no local path inspection or normalization. Use --cwd='<value>' for a value beginning with -. Local bookmark actions cannot be combined with a Hub target or each other. See ez-agent --hub --help.

CLI

-p submits text; -s/--leaf resumes a leaf. --cwd is fresh-discovery input and does not redefine a resumed leaf. Explicit model/profile choices override saved values. EZ_AGENT_LEAF_ID is a best-effort grouping hint, never authority to resume an unsafe or unrelated leaf. Scripted CLI runs never silently answer project-configuration trust questions.

Fresh and resume launch preflight report unavailable remote discovery or a not-found provider/model before validating thinking capabilities. Missing capability metadata in either state does not mean a saved or explicit thinking choice is invalid, and preflight does not rewrite the selected profile.

Inspection and management include session/leaf/root/model listing, leaf deletion, config display, daemon stop, and vacuum with dry-run/age/deep options. Session persistence belongs to pkg/service/session, and vacuum/service behavior to pkg/service.

Macro discovery, info, and invocation use --list-macros, --macro-info, --macro, and --param; -s supplies leaf context. Builtins are documented in ez-agent-builtin. --third-party-licenses runs locally.

Remote one-off prompts and scripts

For interactive use, open the TUI and use /connections to select, save, or manage connections. The CLI connection flags support one-off prompts and scripts:

sh
1ez-agent --connection office --cwd /srv/project -p 'Summarize the changes'
2ez-agent --socket /run/user/1000/ez-agent/ez-agent.sock --cwd /srv/project -p 'Summarize the changes'
3ez-agent --ssh user@host --socket /run/user/1000/ez-agent/ez-agent.sock --cwd /srv/project -p 'Summarize the changes'
4ez-agent --via user@host --cwd /srv/project -p 'Summarize the changes'
5ez-agent --connection office -s l_abc123 -p 'Continue'

--connection <saved-id-or-name> uses a saved TUI connection. Missing, ambiguous, or unavailable saved connections are errors, never a reason to connect locally. --socket <absolute-path> connects directly to that Unix socket. --ssh <destination> forwards the destination socket through SSH and requires --socket. --via <destination> is a temporary SSH connection with best-effort Auto socket discovery; an optional --socket overrides discovery. Destinations use [user@]host[:port] syntax. --connection cannot be combined with --socket, --ssh, or --via; --via cannot be combined with --ssh.

Auto discovery runs a fixed SSH command to find $XDG_RUNTIME_DIR/ez-agent/ez-agent.sock on the destination. It is not guaranteed when SSH exec is disabled or the remote login environment lacks XDG_RUNTIME_DIR. Failure stops the command without guessing another path or falling back locally. Supply the known absolute socket path with --socket when discovery is unavailable.

Fresh remote prompts require an absolute remote --cwd or a saved connection CWD. Explicit --cwd overrides the saved CWD. Remote path bytes are preserved, including repeated separators and ..; the client neither resolves them against its own working directory nor inspects them locally. Resuming with -s uses the leaf's authoritative root CWD and ordinary saved-profile policy instead. Remote operations ignore the local EZ_AGENT_LEAF_ID grouping and ancestry hints. Local CLI grouping behavior is unchanged.

These connections never probe or start a local daemon, even with --autolaunch. Inspection, leaf deletion, macros, and vacuum use the selected daemon. An explicit remote --vacuum therefore prunes remote data; use --dry-run to preview it. --stop is local-only and is rejected with a remote target. --help does not resolve a saved connection or open connection state.

SSH authentication uses a masked prompt on /dev/tty, not piped stdin or stdout. Cancellation restores the terminal before returning. Scripts without a controlling terminal must use noninteractive SSH authentication such as keys; required interactive authentication fails clearly rather than consuming script input. Passwords are not saved or logged.

TUI Inbox commands

The sidebar's Inbox lists sessions needing attention, newest alert first. An explicit /unsettle moves the session to the top. Sending an interactive composer prompt or steer settles existing attention and arms notification for the next idle transition, through the public leaf metadata API. Workflow and other API submissions do not arm alerts; scripts can set the same leaf parameters explicitly. Opening an entry does not dismiss it. An empty Inbox is valid and never forces a different chat or a new draft. A rejected send needs attention only when idle notification was armed; accepted runs use the normal agent idle/error lifecycle. Arming errors remain visible. Automatic attention changes and explicit Inbox commands are ordered by client intent per session. A late rejected-send reply cannot undo a newer retry, settle or snooze. Already-admitted metadata writes finish before newer ones start; an unacknowledged write blocks later changes for that session and reports uncertainty. Enter unlocks at send acceptance or rejection, even while a notification reply remains pending. A newer handoff may wait for that reply without blocking typing or other sessions.

Enter binds to the thread or draft visible at that moment, including any pending command/provider classification and first-message setup. Navigation does not cancel or redirect the handoff. Repeated Enter on that origin is locked until acceptance or rejection, while other threads remain usable. Later edits are not cleared by an old acknowledgement. Sending stays in the thread unless you navigate yourself. Mode choices remain cached for this client's connection and exact CWD across switches and /new. Failed initial discovery retries on the 10-second refresh tick, with overlapping initial lookups coalesced. Until it succeeds, unresolved slash input stays in the composer with a visible error. Loaded mode choices are not refreshed on Enter or by the timer. Live configuration changes and other clients do not synchronize that cache; a cached choice may receive an ordinary rejection. Exact mode shortcuts keep their existing syntax, so /build foo does not mean "switch mode and send foo".

  • Ctrl+S settles the displayed session, removing it from Inbox and closing the chat to open a welcome draft, exactly like /settle. It works during text entry on the main chat screen, but not in popups or dialogs. It preserves idle alerts.
  • /settle removes the selected session from Inbox and opens a welcome draft.
  • /unsettle shows it in Inbox now.
  • /snooze <time> schedules its return, for example /snooze 1hr, /snooze tomorrow 9am, or an RFC3339 timestamp.
  • Bare /snooze and the sidebar Snooze action open a preset popup with 1m, 5m, 30m, 1hr, and 1day. Escape cancels. Opening or using the popup leaves any composer draft untouched.

These commands do not change alert_idle. If idle notification is armed, a running leaf still returns to Inbox when it becomes idle, even if settled or snoozed during the run. Unrecognized time expressions use an isolated temporary small-model request without sending a message to the current conversation. Unusable results are errors rather than successful-looking notices. See TUI behavior for parsing, background-request cleanup, and refresh behavior.

ChatGPT plan usage

Connect through the configurator's Continue with ChatGPT action. Old Codex credentials require fresh sign-in and are not used by this version. Subscription usage does not silently fall back to API-key billing. The one existing TUI title includes the source label; /usage, sidebar Usage, or /edit during execution opens read-only access details and the Manage usage URL. Idle /edit retains its normal configuration controls. Unknown or unavailable access is neutral, not Local. See OAuth and service authorization, configurator controls, and TUI state.

Authority and tests

  • Mode selection and exits: cmd/ez-agent/main.go.
  • CLI parsing and launch policy: pkg/cli/.
  • Hub prompts, saved targets, and handoff: internal/frontend/hub_*.go.
  • TUI: pkg/tui/; connection readiness: internal/frontend/lifecycle.go.
  • Frames: pkg/protocol and the JSONL catalog.
  • Shipped-process coverage: test suites; commands and ownership: test guide.