feat(cli): attach terminal clients to the selected Desktop [skip ci]

NAN-104 requires terminal chat and browser attachment without granting a client ownership of Desktop's gateway. Resolve bounded short-lived credentials over authenticated current-user IPC, pin both Desktop and gateway identities, and reject replacement instances or incompatible clients before any mutation.

Reuse the existing TUI artifact resolver behind a narrow Desktop-only entrypoint, keep credentials out of argv/environment/files, and preserve Python-mode reconnect and gateway leases. Add protocol, real-gateway, and anonymous IPC regression coverage; matching native-host and Windows acceptance remain release gates.
This commit is contained in:
Xubin Ren committed 2026-09-08 10:04:15 +08:00
1 parent b373a95f5c
commit 48e7c4f697
20 files changed
+797 -52

No files matched your search

+20 -5
View File
@@ -44,11 +44,11 @@ reports the current Python executable and continues normally. A virtual
environment's executable is shown without resolving it to its base interpreter.
Choosing Desktop for `nanobot webui` opens its already-running browser workbench
and exits; closing the browser never stops the Desktop gateway. The current
Python client and Desktop discovery protocol do not yet support attach-only terminal chat, so
choosing Desktop for bare `nanobot` fails explicitly without starting, restarting,
or replacing a backend. Use explicit `nanobot agent` for the Python terminal UI
until the Desktop TUI attachment protocol is available.
and exits; closing the browser never stops the Desktop gateway. Choosing Desktop
for bare `nanobot` opens the terminal UI against that same running backend when
the Desktop host, gateway and terminal client support terminal protocol 1. Older
versions fail explicitly with update guidance. Use explicit `nanobot agent` for
the original Python terminal UI.
After Desktop is selected, a disconnect or incompatible reply ends that invocation
with an error; it never silently switches to Python or launches a replacement.
On macOS, browser URLs are delivered through native Launch Services rather than
@@ -77,6 +77,21 @@ and gateway lifecycle commands—keeps its existing Python meaning and never ope
the Desktop picker. Target choices are not remembered, and Desktop settings are
not copied into the Python installation.
Desktop terminal credentials are short-lived WebSocket/API tokens obtained through
the authenticated current-user rendezvous. The TUI receives them through a bounded
anonymous pipe, not command arguments, environment variables or temporary files.
Its environment contains only a trusted resolver command and public instance IDs.
The resolver verifies the selected Desktop and gateway again for every credential
refresh. The gateway identity is also checked before any WebSocket mutation. This
mode does not acquire a gateway lifecycle lease: client exit leaves Desktop running,
and disconnect never automatically reconnects or replays an uncertain task.
Desktop-only distributions use the narrow `nanobot-desktop-tui` entrypoint inside
their existing private runtime; it is not a replacement for the full Python CLI.
They must ship this engine entrypoint and a matching terminal client together.
The client cache can be kept inside Desktop's data root without reading or writing
the separate Python installation's config. No additional system Python is needed.
## Common Patterns
Most day-to-day commands use the default config and workspace. Advanced or multi-instance runs usually pass both paths explicitly: