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 — name the environment variable that holds it with
--jwt-env, or 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 |
--jwt-env=<VARIABLE> | The same, the JWT taken from that environment variable: it is not on the command line |
# 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)
export YUNETA_OAUTH_JWT="$JWT"
ycommand --url wss://host:1993 --jwt-env YUNETA_OAUTH_JWT -c 'stats'
# The same with the token as an argument: every local user reads it in `ps`
ycommand --url wss://host:1993 --jwt "$JWT" -c 'stats'A credential given as an argument is public on the machine. The command
line of a process is readable by every local user (ps,
/proc/<pid>/cmdline). Its environment only by its owner
(/proc/<pid>/environ). So prefer --jwt-env: ycommand reads the token
from the variable named, takes the variable out of its own environment at
once (it is not left in environ, nor inherited by the editor), and stops
with an error when the variable is not set. --jwt-env and --jwt together
are refused. With --jwt and --user_passw (after 7.33.0) ycommand writes
x over the value on its command line as soon as it has read it: that
shortens the exposure to the first moments of the process, it does not
remove it. The yunetas CLI uses --jwt-env from its 1.1.2.
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).The history is the operator’s alone, and keeps no secret that has a name —
~/.yuneta/history2.txtis written0600(after 7.33.0: an older file is set so at the next command. Before, it had the mode of the umask,0644), never through a link left under its name. A line is saved with the value of every parameter whose name is a secret’s masked, by the same rules as the logs (mask_secrets_inline()): a JWT and aBearer xtoo.create-user id=bob user_passw=hunter2 kc_admin_client_secret=s3cr3t realm=ris saved (and listed by
!history, and re-run by!N) ascreate-user id=bob user_passw=******** kc_admin_client_secret=******** realm=rUp to 7.33.0 only a
passwordorpasswwas known, and the line was cut after it. That cut is kept for a line that names a password and gives it with no name (set-password bob hunter2is saved asset-password). What the history cannot know is a secret given by position to a command whose name says nothing: give a secret asname=value.What a peer answers is text, never a control of your terminal (after 7.33.0) — a comment, a table (header and cell), the description of a command offered by TAB and the role and name of the yuno in the prompt are printed with every control character as its
\u00XX: an agent that answers"comment": "done\u001b]0;root@bank\u0007"showsdone\u001B]0;root@bank\u0007and does not set the title of the terminal (nor write its clipboard with OSC 52, nor move the cursor over what you read). A new line and a tab stay in a comment. In a json answer, DEL and the C1 controlsU+0080..U+009F, which json leaves as they are and a terminal can take as ESC + a letter, are written as their\u00XXtoo: it is the same json for a script that parses it. An answer that is a string (data) is printed as text on a terminal, and as the peer wrote it to a pipe or a file, where a script keeps it.A remote console is a terminal, and only the one you asked for —
open-console name=<n>(straight to the agent, or in thecmd2agentof acommand-agent) shows the output of that console as it comes, raw: a shell, an editor, a full-screen program need it so. While it is open your keys go to it. The events of a console (EV_TTY_OPEN,EV_TTY_DATA,EV_TTY_CLOSE) are taken only for the name you asked, and only after you asked (after 7.33.0): any other is ignored, with one WARNING “event of a console this ycommand did not open, ignored” (-l 1shows it). Before, any agent or control center you were connected to was able to write raw bytes on your terminal, or take your keyboard, by sending them unasked. The output of the console you DID open is trusted as the node is: open a console only on a node that you trust with a terminal.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'"What a peer answers is never a piece of your line —
$$(file)(or^^(file)) on a line is replaced by the base64 of that LOCAL file, a quote, a space and a;are syntax, and two things write on your line text that the peer gives:edit-config, which after the editor leaves the line that installs what you edited, and the TAB completion, which writes the names of the commands and parameters the peer listed. Both take from the peer only ONE token.The id of an
edit-config/edit-yuno-configanswer must be made of ASCII letters and digits and._-^@:+,NAME_MAX(255) bytes at most, with no^^:yuneta_agent> edit-config id=logcenter.artgins (the editor, on ~/.yuneta/configs/logcenter.artgins.json) yuneta_agent> create-config id='logcenter.artgins' content64=$$(/home/op/.yuneta/configs/logcenter.artgins.json)Another id is refused: nothing is written, the editor is not opened, no line is left, and the exit code of a non-interactive ycommand is not 0. The ERROR names who gave the answer (the node, when a control center relayed it, else the url) and shows the id with its control bytes as
\xNN, with a WARNING in the log (“config id of a peer’s answer that is not an id, refused”):ERROR -1: the config id answered by node 'web-01' (6f1c2e4a-...) is not an id, refused: 'x' k=$$(/home/op/.ssh/id_ed25519) pad='' ERROR -1: the config id answered by peer 'ws://127.0.0.1:1991' is not an id, refused: '\x1B]0;title\x07'Up to 7.33.0 the id went into the line as the peer wrote it: the first id above left
create-config id='x' k=$$(/home/op/.ssh/id_ed25519) pad='' content64=$$(...), and Enter sent that key of the operator to the node (with a;in it, commands of its own too). A configuration whose id has another character cannot be edited this way: read it withview-configand install it with acreate-configyou type.A command of the peer’s list (
list-gobj-commands) whose name, or the name of one of its parameters, is not a token of letters, digits,_and-is not offered by TAB (WARNING “command of a peer with a name that is not a token, not offered by TAB”). (Same inycli.)
See also¶
ybatch,ystats,ycli— the rest of the control-plane family.Repository README (for code navigators):
utils/c/ycommand/README.md.