Document M6 in AGENTS.md and README
This commit is contained in:
2 files changed
+67
-5
No files matched your search
@@ -21,8 +21,9 @@ The full plan lives at `~/.opencode/plan/regent.md`.
|
||||
## Layout
|
||||
|
||||
```
|
||||
src/main.rs resource registration, entry point, --version
|
||||
src/main.rs arg parsing, resource registration, entry point
|
||||
src/application.rs AdwApplication, actions, CSS
|
||||
src/headless.rs headless mode + CLI pairing (no window)
|
||||
src/window.rs main window: view switcher over the pages
|
||||
src/config.rs GSettings wrapper (+ REGENT_RELAYS override)
|
||||
src/runtime.rs tokio runtime + the bridge back to the GTK main loop
|
||||
@@ -130,6 +131,35 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
|
||||
**Regent extension**, not NIP-46; the requested `perms` from a `connect`
|
||||
(`params[2]`) are shown in the pairing dialog but never auto-granted.
|
||||
|
||||
## Headless mode and CLI pairing (M6)
|
||||
|
||||
- `regent --headless` runs the signer with **no window** (and no display): it is
|
||||
a plain tokio program, deliberately *not* a `GtkApplication`.
|
||||
`regent --pair nostrconnect://…` runs the same way, pairs first, then keeps
|
||||
serving. No options opens the GUI.
|
||||
- **Headless denies anything not covered by a stored permission.** There is no
|
||||
window to ask, so the approval bridge's questions are answered `Deny`
|
||||
immediately (not after the timeout). Pre-approve with "Allow always" in the
|
||||
GUI, then run headless. `get_public_key`/`ping`/`get_relays` stay automatic.
|
||||
- **CLI pairing is the client-initiated (`nostrconnect://`) flow**: parse the
|
||||
URI, subscribe to the client's relays (kept in `SignerConfig::extra_relays`,
|
||||
**not** in `config.relays`, so they never leak into the bunker URI or
|
||||
`get_relays`), register the app, then send the `connect` **response** whose
|
||||
`result` is the client's secret, p-tagged to the client and signed by the
|
||||
device key. Running `--pair` is the consent; permissions are never
|
||||
auto-granted, and the URI/secret are never printed or logged.
|
||||
- The responder answers `connect` with `"ack"` for an **already approved**
|
||||
client even without the secret — a client-initiated pairing proves key
|
||||
possession by receiving our response. A new client still needs the secret.
|
||||
- **One instance only.** Two signers on one device key fight over `apps.json`.
|
||||
The GUI owns the D-Bus name `org.kosmos.raucao.Regent`; headless checks
|
||||
`NameHasOwner` and exits "Regent is already running". Residual race: two
|
||||
headless runs started at once, or the GUI starting after headless, are not
|
||||
caught — a lock or D-Bus activation would close that.
|
||||
- Errors are loud: `--headless`/`--pair` print a message and exit non-zero for a
|
||||
bad URI, no keyring, no identity key, or a relay that refused the connect
|
||||
response.
|
||||
|
||||
## Keys
|
||||
|
||||
- The **identity key** is the user's `nsec`. It lives in the system keyring and
|
||||
@@ -187,8 +217,12 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
|
||||
`pubkey`/`id`/`sig`). Hand-parse the `{id, method, params}` envelope.
|
||||
4. Clients send `switch_relays` *before* `connect`, sometimes with
|
||||
`params: null` (not `[]`). Handle it, and tolerate null params.
|
||||
5. `NostrConnectUri::parse()` handles both `bunker://` and `nostrconnect://`
|
||||
(`is_bunker()`, `relays()`, `secret()`) — use it.
|
||||
5. `NostrConnectUri::parse()` handles `bunker://` (`is_bunker()`, `relays()`,
|
||||
`secret()`) — use it for the **signer-initiated** direction. For
|
||||
`nostrconnect://` it expects a **non-standard `metadata=<json>`** query
|
||||
parameter, so a spec-shaped URI (`relay`/`secret`/`name`/`url`/`image`/
|
||||
`perms`) fails to parse: hand-parse the client direction (see
|
||||
`signer::parse_client_uri`).
|
||||
6. Requests arrive NIP‑44 encrypted; fall back to NIP‑04 for legacy clients.
|
||||
Respond NIP‑44.
|
||||
7. Several **Adwaita** widgets render text as **Pango markup by default**:
|
||||
@@ -262,8 +296,10 @@ the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
|
||||
dbus-run-session -- build-aux/acceptance.sh
|
||||
```
|
||||
Checks the keyring round-trip, a `nak` loopback against the responder, that a
|
||||
seeded identity key makes the app start the signer, and that the app created a
|
||||
device key. Needs `nak`, `secret-tool`, `gnome-keyring-daemon`,
|
||||
seeded identity key makes the app start the signer, that the app created a
|
||||
device key, and that headless `--pair` completes a client-initiated pairing
|
||||
(a `nak req --stream` subscriber must be listening, or `nak serve` mutes the
|
||||
response). Needs `nak`, `secret-tool`, `gnome-keyring-daemon`,
|
||||
`gtk4-broadwayd`; skips nothing, so run it where those exist.
|
||||
- Key store against a real (throwaway) Secret Service:
|
||||
```sh
|
||||
|
||||
@@ -39,6 +39,32 @@ dbus-run-session -- sh -c \
|
||||
./_build/regent'
|
||||
```
|
||||
|
||||
## Running without a window
|
||||
|
||||
Regent can run the signer with no window at all, including on a machine with no
|
||||
display (it needs a D-Bus session for the keyring, but no GUI):
|
||||
|
||||
```sh
|
||||
regent --headless
|
||||
```
|
||||
|
||||
Anything not already allowed with "Allow always" is denied — with no window there
|
||||
is nobody to ask, so pre-approve permissions in the GUI first.
|
||||
`get_public_key`, `ping` and `get_relays` are still answered automatically.
|
||||
|
||||
To pair a client without opening the GUI, pass the `nostrconnect://` string the
|
||||
client shows (the client-initiated flow). Regent joins the client's relays, sends
|
||||
the connect response, remembers the application, then keeps running headless:
|
||||
|
||||
```sh
|
||||
regent --pair 'nostrconnect://…'
|
||||
```
|
||||
|
||||
A graphical client usually shows that string as a QR code; the
|
||||
`nostrconnect://` URI is its text form. Permissions are never granted
|
||||
automatically, so a freshly paired application can only ask — approve what it
|
||||
may do with "Allow always" in the GUI. `regent --help` lists the options.
|
||||
|
||||
## Testing on another machine
|
||||
|
||||
The build host compiles; you test on the workstation it should actually run on.
|
||||
|
||||
Reference in new issue
Block a user