Metadata-Version: 2.4
Name: flux-config-tui
Version: 0.5.1
Summary: The Flux node console, and flux-node: CLI, local gateway and library for nodes over SSH
Author: David White
Author-email: David White <david@runonflux.io>
License-Expression: GPL-3.0-or-later
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: System :: Monitoring
Requires-Dist: flux-config-shared[identity]>=0.37.0,<1.0
Requires-Dist: flux-networking-shared>=0.16.0,<1
Requires-Dist: textual>=8.2.8,<9
Requires-Dist: textual-fspicker>=1.0.1,<2
Requires-Dist: qrcode>=8.2,<9
Requires-Dist: pyperclip>=1.11.0,<2
Requires-Dist: setproctitle>=1.3.8,<1.4
Requires-Dist: yarl>=1.25.1
Requires-Dist: asyncssh>=2.24.1,<3
Requires-Dist: websockets>=17.4,<18
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: pyte>=0.8.2,<0.9
Requires-Dist: typer>=0.28.0,<0.29
Requires-Dist: aiohttp>=3.14.5,<4
Requires-Dist: flux-config-shared[x11] ; extra == 'node'
Requires-Python: >=3.13, <4
Provides-Extra: node
Description-Content-Type: text/markdown

# flux-config-tui

The Flux node's console, and `flux-node`: the same program as a command line, a local HTTP
gateway and a Python library for working on ArcaneOS nodes over SSH.

```sh
uv tool install flux-config-tui     # or: pip install flux-config-tui
```

## The console

`flux-config-tui` (or `flux-node` with no command) opens the console: system monitoring,
services, logs, network settings, installation and configuration. On the node it talks to
configd's operate socket; from your machine it logs in over SSH as `fluxtui` with an operate
key the node was installed with, and keeps the nodes you add in `~/.config/flux-config/`.

## flux-node

Each command works on `--host <address>` (with `--key`, `--port`), on a saved node
(`--node <name>`), or on your default saved node, and prints configd's answer as JSON. A saved
node is `operate` or `status`; `--status` logs in with a status key, which can read but not act.

```sh
flux-node status                      # install, fluxd's and fluxbench's status, ArcaneOS
flux-node benchmarks
flux-node logs fluxd                   # its latest lines, as the node's console shows them
flux-node service restart fluxd
flux-node reboot                      # asks first; the node drains its apps
flux-node call network.get_change     # any method the key's tier answers
flux-node events benchmarks system    # live events, one JSON object a line
flux-node trust <node>                # after a reinstall: trust the node's new host key
```

The first connection to a node trusts its SSH host key and prints its fingerprint; compare it
with the one on the node's own console. A different key later is refused until you `trust` it.

### Saved nodes

```sh
flux-node add 203.0.113.5 --key ~/.ssh/operator_ed25519 --name banana   # SSH port 16122
flux-node add 203.0.113.6 --agent-key SHA256:…   # a key your SSH agent holds
flux-node edit banana --address 192.168.1.50      # keeps the host key trusted for it
flux-node remove banana
flux-node nodes
```

Nodes to save can be found rather than typed:

```sh
flux-node import --owner <FluxID or payment address> --key ~/.ssh/operator_ed25519          # list them
flux-node import --owner <FluxID or payment address> --key ~/.ssh/operator_ed25519 --save   # and save them
flux-node import --file fluxnodes.yaml --save     # arcane-mage's file: names and LAN addresses
```

A FluxID finds the ArcaneOS nodes registered to it in the network's node list
(`stats.runonflux.io/fluxinfo`, one download), at their public addresses; a node's SSH port is
its API port less 5. An arcane-mage file gives each node's name and static address, and the key
whose public half the file lists and `~/.ssh` or your SSH agent holds; a DHCP node has no address
there. `--only <address or name>` saves just those.

Both give each node's collateral, and a saved node keeps it. A node found that is a saved node
(the same collateral, or a saved node with none at the same address and port) updates it rather
than being added. From a file, the file's name, address and port win, and its key and tier only
when the file found an operate key for a node saved with a status key. From the node list,
everything the saved node has wins, and only what it lacks (its name, its collateral) is filled.

Saving or finding a node contacts nothing; the first command that works on it logs in. A node's key is a
private key file that its owner alone can read, or a key an SSH agent holds (a key with a
passphrase, or a hardware key), named by its fingerprint. A login offers the node that key and
no other.

### Network changes

```sh
flux-node network show
flux-node network static ens18 192.168.1.50/24 --gateway 192.168.1.1 --dns 1.1.1.1
flux-node network dhcp ens18
flux-node network vlan-add ens18 148
```

A change asks the node to roll itself back unless `flux-node` reaches it again with a new login
within two minutes, at the new address when the change moves the one you use. Once reached, the
change is kept and saved, and a saved node follows its new address. Ctrl-C reverts at once.

### The gateway

```sh
flux-node ui                          # serve, and open the fleet page in your browser
flux-node ui --no-browser             # serve, and print the page's link
flux-node serve                       # http://127.0.0.1:8640, the API alone
flux-node token                       # the bearer token scripts send with each API request
```

After 15 minutes in which the page asks nothing (`--idle-timeout <minutes>` on `ui` and `serve`;
0 never), the gateway ends the page's session and disconnects the nodes the page used last, so a
forgotten gateway leaves the nodes' one session free for their console.

The page never holds the token. `flux-node ui` makes a link with a one-time code
(`http://127.0.0.1:8640/#code=…`) that opens the page once, within a minute: the page exchanges
the code for a session that lasts until the gateway stops or the page goes unused, and takes it
out of the address bar.
The browser is opened on a file in a directory only you can enter (under `$XDG_RUNTIME_DIR`, or
`~/.config/flux-config/ui/`) that sends it on to the link, so the code is on no command line; the
file is removed when the code is used or expires. With the gateway serving on the port already
(`flux-node ui` or `flux-node serve`), `flux-node ui` asks it for a new link and opens that. The
page's files need no token and are served only to `127.0.0.1`, `localhost` or `[::1]` on the
gateway's port.

`GET /nodes`, `GET /nodes/{name}`, `GET /nodes/{name}/benchmarks`,
`POST /nodes/{name}/call` (`{"method": …, "params": {…}}`),
`GET /nodes/{name}/events?topics=…` (server-sent events) and
`GET /nodes/{name}/log?service=…` (the latest lines of a service's log, as the node's console
shows them) for your saved nodes, one SSH connection each.

`POST /nodes/{name}/network` (`{"interface", "allocation": "static" | "dhcp", "address",
"gateway", "dns": […]}`) changes a node's network as `flux-node network` does: the node rolls the
change back unless the gateway reaches it with a new login within two minutes, at the new address
when the change moves the one in use; reached, the change is kept and the saved node follows its
new address. `GET /nodes/{name}/network` shows that change while it is checked, and its outcome.

`GET /nodes` shows each node's connection (`not_connected`, `connecting`, `connected`,
`no_answer`, `key_refused`, `host_key_changed`, `key_unusable`) and the state it last answered,
with its time, kept in `~/.config/flux-config/last_state.json`. Listing connects to nothing: a
node is logged in to by `POST /nodes/{name}/connect`, by `POST /connect` with
`{"nodes": [names]}` (ten logins at a time), or by a script's request to one of its own routes,
and `/disconnect` closes it. The page logs in only through the two connect routes: its request to
a node that is not connected is answered 409. A connection that drops reconnects by itself; a node that refuses the
key or presents another host key is not tried again until you ask.

`POST /nodes`, `PATCH /nodes/{name}` and `DELETE /nodes/{name}` change the saved list;
`POST /import/owner`, `POST /import/file` (`{"text": …}`) and `POST /import/save` are
`flux-node import`; `GET /keys` lists the key files in `~/.ssh` and the agent's keys, and
`POST /keys/check` (`{"path": …}`) says whether a file can be a node's key.

It listens on loopback only and refuses a request without the token or a page's session, with
a Host other than localhost, with an `Origin` other than the gateway's own
(`http://127.0.0.1:<port>`, `http://localhost:<port>` or `http://[::1]:<port>`), or a POST or
PATCH that is not JSON. `flux-node token --new` replaces the token at once.

### The library

```python
from flux_config_tui.node import Node

async with Node("192.168.1.50", key="~/.ssh/operator_ed25519") as node:
    print(await node.state())
    async for event in node.events(["benchmarks"]):
        print(event.type, event.data)
```

## Developing

The fleet page's source is `ui/` (Vue and Vite); its built files are committed in
`src/flux_config_tui/web/` and ship in the package, so installing it needs no Node.js. After a
change under `ui/`, build it with Node.js 24 or newer:

```sh
cd ui && npm ci && npm run build && npm run lint
```

Every package in `ui/package-lock.json` was published at least seven days before it was locked:
change a dependency with `npm install --before <the date seven days ago> --save-exact
<package>@latest`.

The build writes `web/source.sha256`, a hash over `ui/` (without `node_modules`, with
`package-lock.json`); `tests/test_web_build.py` fails while it does not match `ui/`.

## On the node

The node's image installs `flux-config-tui[node]`, whose extra brings what only the node's own
screen needs (`flux-best-resolution`).
