ycommand is the primary control-plane tool of Yuneta. It connects to a
running yuno — over the agent’s local socket or a remote WebSocket — and sends
it commands and stats requests, printing the response. Almost every operational
task in this documentation (deploying binaries, inspecting state, toggling
traces, managing realms) is driven through ycommand.
It is one of a small family of control-plane clients:
ycommand— send commands / read responses (this page).ybatch— run a file of commands unattended.ystats— subscribe to live statistics.ycli— the full-screen ncurses sibling for interactive browsing.
Usage¶
ycommand -c '<command>' # single command on the default yuno
ycommand <command> <args...> # same as -c, positional form
ycommand --url ws://host:port -c 'help' # remote yuno
ycommand -i # interactive shell (raw TTY)
cat script.ycmd | ycommand -u ws://... # long-lived stdin-pipe sessionThe stdin-pipe mode kicks in automatically when neither -c nor -i is
passed and stdin is not a TTY. Lines are read event-driven (one dup’d
io_uring read per line), so the session stays alive between commands — a shell
coproc, a { echo cmd1; sleep 5; echo cmd2; } block, or any programmatic driver
can stream commands into the same authenticated session and pay the OAuth2
round-trip only once. EOF on stdin triggers an orderly shutdown.
Run ycommand --help for the full flag list.
Choosing a mode¶
| Mode | When to use | Trade-off |
|---|---|---|
ycommand -c '<cmd>' | A single command inside a shell script or one-liner | Pays connect + auth on every invocation |
ycommand -i | Interactive exploration: prompt, TAB, history, Ctrl+R, did-you-mean | Requires a TTY. Not scriptable |
... | ycommand (stdin) | A known sequence of N commands without needing to read a response first | No feedback loop — every line is sent regardless of prior output. Connect + auth paid once |
Authentication (OAuth2 / OIDC)¶
The default ws://127.0.0.1:1991 is the agent’s plain local control port and
needs no credentials. The remote / TLS path (typically wss://host:1993) is
gated by an OAuth2 JWT, supplied one of two ways:
Pre-obtained token — pass it directly with
--jwt.Fetch at connect — pass
--user_id+--user_passwtogether with an IdP (--issueror--token-endpoint) and--client-id.ycommandobtains the JWT itself before opening the WebSocket.
When an IdP and a --user_id are present, ycommand runs a one-shot
token-fetch task at connect time: it resolves the token endpoint (via OIDC
discovery from --issuer, or taken verbatim from --token-endpoint), exchanges
user_id / user_passw / client_id for a JWT (resource-owner password
grant), then opens the WebSocket carrying that JWT in the handshake. In
stdin-pipe mode this round-trip happens once and the resulting session
serves every piped command.
| Flag | Short | Purpose |
|---|---|---|
--issuer=<url> | -I | OIDC issuer URL. Triggers discovery of the token / end-session endpoints |
--token-endpoint=<url> | -T | Explicit token endpoint. Skips discovery (set with --end-session-endpoint) |
--end-session-endpoint=<url> | -E | Explicit OIDC end_session endpoint. Skips discovery (set with --token-endpoint) |
--client-id=<id> | -Z | OAuth2 client_id (Keycloak / Auth0 / Azure AD / …) |
--user_id=<user> | -x | Username for the token grant |
--user_passw=<passw> | -X | Password for the token grant |
--jwt=<token> | -j | Use a previously obtained JWT. Skips the token-fetch task |
# Fetch a JWT via discovery, then connect to a remote agent
ycommand --url wss://host:1993 \
--issuer https://auth.example.com/realms/yuneta/ \
--client-id yuneta \
--user_id alice --user_passw '••••••' \
-c 'list-yunos'
# Reuse a JWT you already hold (no token-fetch round-trip)
ycommand --url wss://host:1993 --jwt "$JWT" -c 'stats'The same flags work for ybatch and ystats.
Command-line syntax¶
| Form | Meaning |
|---|---|
cmd arg=val ... | Send to the yuno’s default service |
cmd ... service=__yuno__ | Send to the yuno itself |
cmd ... service=<name> | Send to a named service inside the yuno |
*cmd ... | Force response display in form (raw JSON) mode |
!cmd | Run a local ycommand command (see !help) |
!! | Re-run the last command (bash-style history expansion) |
!N | Re-run history entry N (1-based, matches !history output) |
cmd1 ; cmd2 ; ... | Chain. Each waits for the previous response |
-cmd | Ignore errors for this command (the ybatch convention) |
# at start of line | Comment (ignored by !source / stdin piping) |
The ; split is quote/brace aware: a ; inside "...", '...' or {...} is
treated as literal, so JSON-valued parameters like kw={"a":1;b:2} pass through
untouched.
Interactive shortcuts¶
Available in -i mode (and shared with ycli through the common
C_EDITLINE line editor).
| Shortcut | Action |
|---|---|
TAB | Complete command or parameter. List candidates if ambiguous |
TAB after param= | Complete values for boolean params (true / false) |
Ctrl+R / Ctrl+S | Reverse / forward incremental history search |
Up / Down | Previous / next history entry |
Ctrl+A / Ctrl+E | Start / end of line |
Ctrl+B / Ctrl+F | Move left / right one character |
Ctrl+D / Backspace | Delete char under / before cursor |
Ctrl+K | Delete from cursor to end of line (readline) |
Ctrl+U / Ctrl+Y | Delete whole line |
Ctrl+W | Delete previous word |
Ctrl+T | Swap character with previous |
Ctrl+L | Clear screen |
While in Ctrl+R / Ctrl+S search mode the prompt changes to
(reverse-i-search)'pat': <match>. Enter accepts and submits, an arrow key
accepts and keeps editing, ESC or Ctrl+G cancel.
Local commands (invoked with !)¶
Run !help (alias !h or !?) inside an interactive session for the full
list. Short aliases follow the c_cli convention:
| Command | Aliases | Description |
|---|---|---|
!help | !h, !? | List all shortcuts and local commands |
!history | !hi | Show the command history with 1-based indices (!N) |
!clear-history | !clh | Erase history |
!exit / !quit | !x, !q | Leave ycommand |
!source <file> | !. <file> | Read commands from <file> and splice them at the head of the queue |
Batch / scripting¶
ycommand can run a list of commands sequentially, each waiting for the
previous response — similar to ybatch but with the line-oriented
ycommand syntax instead of JSON:
cmd1 ; cmd2 ; cmd3on a single line.!source script.ycmdinside an interactive session.cat script.ycmd | ycommand -u ws://...from a shell pipe.Any command can be prefixed with
-to keep the batch going on error. Without the-, the first error drops the queue.
Script file format: one command per line, # comments and blank lines ignored,
each line can itself contain ;-chained commands.
A connection that does not open¶
The connection must open in 10 s. If it does not, ycommand says why, with
the cause of the last attempt of its transport, and exits with an error
(code 255): on stderr in a script, on stdout with -i or -l. The log
(-l 1) says more, for example the name that a certificate does not match.
$ ycommand -u wss://127.0.0.1:1630 -c 'help'; echo "exit=$?"
Cannot connect to wss://127.0.0.1:1630: TLS handshake failed: error:0A000086:SSL routines::certificate verify failed
Abort.
exit=255A refused port says Connection refused. A peer that accepts and says
nothing gives no answer. Up to 7.30.17 ycommand waited for ever, and said
nothing without -l: the transport retries a failed connection, as every
client does, and tells its host nothing until one opens.
Other features¶
did-you-mean — on a
command not availableerror,ycommandcompares the typed command name against the in-memory cache (fetched vialist-gobj-commandsat connect) and suggests the closest match when it is within an edit-distance threshold. That fetch (interactive mode only) takes only its own answer, by the command its answer carries back (list-gobj-commands): up to 7.30.26 any error answer withoutdatathat came while it was pending was taken for it, so a request refused that way stayed pending and the next answer nobody asked was taken.Informative prompt — after connecting, the prompt reflects the remote yuno (
yuneta_agent^<name>>).Inline parameter hints — after typing
<cmd>, the remaining parameters appear in gray to the right of the cursor, required as<name=type>and optional as[name=type]. Already-typed params drop from the hint.Output rendering — schema-bearing responses render as aligned tables with bold-cyan headers in both interactive and non-interactive modes. Use the
*cmdprefix to force raw-JSON (form) mode instead.History dedup — consecutive and prior occurrences of the same command are removed from history (bash
HISTCONTROL=erasedupsstyle).Safe local config filenames (since 7.6.0) — when a
view-config/read-json/read-file/edit-configanswer is saved under~/.yuneta/configs/, the peer-supplied record name/id is sanitized first: characters outside[A-Za-z0-9._-]fold to_, a leading dot is forbidden, and path separators collapse to a single inert basename. This closes an RCE where a hostile name flowed into the"<editor> <path>"string handed to/bin/sh -c. (Same fix inycli.)Only the answers it asked for — the agent answers its own requests (
read-file,read-json,read-binary-file,running-keys,running-bin,edit-config,view-config,edit-yuno-config,view-yuno-config) with an event of its own (EV_READ_FILE,EV_EDIT_CONFIG, ...), and ycommand writes it under~/.yuneta/configs/, opens the editor on it, or leaves acreate-configon the line. It takes one only while a request of those is pending, one answer per request. A line counts as a request when the request is its COMMAND: its first word, or, of acommand-agent, the first word of itscmd2agent, socommand-agent cmd2agent='read-file filename=/etc/hosts'through a control center counts too, andhelp cmd=read-filedoes not (up to 7.30.26 a name anywhere in the line counted: its answer never spent the request, and the next answer nobody asked was taken). Any other is ignored with a WARNING (shown with-l 1):"msg": "answer of a request this ycommand did not make, ignored", "event": "EV_READ_BINARY_FILE"A request refused at once (an
EV_MT_COMMAND_ANSWERwith an error, such as “Command sent to 0 nodes”) leaves nothing pending, and a disconnection clears what was. Up to 7.30.26 ycommand took any that came from its peer. A request a control center sent (“Command sent to 1 nodes”) and the agent then refuses leaves nothing pending either: the refusal carries the line of its request in its command stack, and ycommand reads it there, as ycli does (up to 7.30.26 the request stayed pending, and the next answer nobody asked was taken).Straight to the agent, that event is the request’s ONLY answer (the agent sends no
EV_MT_COMMAND_ANSWERfor it), so it ends the command: the next one of the line runs, and ycommand ends. Through a control center its “Command sent to 1 nodes” ends the command, and the event comes after (give it time with-w):ycommand -c 'read-binary-file filename=/yuneta/agent/yuneta_agent; help'Up to the fix such a line never ran
helpand never ended.read-binary-filewrites data — the file is written0600, not executable (0700up to 7.30.26): it is a copy of what the node holds, to read or to upload again, not a program to run. A link left in~/.yuneta/configs/under the file’s name is not followed: the write fails, with an ERROR “Cannot write the binary file” naming the path, and the exit code is not 0 (up to 7.30.26 it wrote through the link, and a file it did not open was taken for written, with nothing said and exit code 0):ln -s ~/.bashrc ~/.yuneta/configs/yuneta_agent ycommand -c 'read-binary-file filename=/yuneta/bin/yuneta_agent; help' # -> ERROR "Cannot write the binary file", ~/.bashrc untouched, # help does not run, exit code not 0A
content64that is not base64, or not a string, writes nothing, and is a WARNING (“base64 of a peer not decodable, refused”, “content64 of a binary file that is not a string, not written”) with an exit code that is not 0. Up to 7.30.26 the first was an ERROR with a stack, the second said nothing, and both ended with exit code 0.Text and json answers are written the same way —
read-file(text) andread-json,view-config,edit-config,view-yuno-config,edit-yuno-config(json) are written0600, never through a link, and a failure is an ERROR “Cannot write the file” naming the path, with an exit code that is not 0. A failed write does NOT open the editor: up to 7.30.26 the file followed a link, took its mode from the umask, and a failed write opened the editor on what the file held before (edit-configthen offered it as acreate-config). A text that is not a string is a WARNING, and nothing is written:ln -s ~/notes.json ~/.yuneta/configs/my_yuno.json ycommand -c 'edit-config id=my_yuno' # -> ERROR "Cannot write the file", ~/notes.json untouched, no editor, # "ERROR -1: File NOT saved in '.../my_yuno.json'"
See also¶
ybatch,ystats,ycli— the rest of the control-plane family.Repository README (for code navigators):
utils/c/ycommand/README.md.