fix(cli): isolate Desktop compatibility probes [skip ci]
An older terminal can ignore the protocol probe flag and consume inherited gateway credentials or terminal input. Scrub its TUI environment and close stdin before probing, then pass only the selected Desktop resolver metadata to the compatible client. Validate the complete ready frame before opening mutation gates, not just its identity metadata. Add failing-before regressions and scope the existing recovery test process stub so real lease cleanup remains testable without changing runtime ownership.
This commit is contained in:
1 parent
48e7c4f697
commit
9a594f74ff
5 files changed
+61
-6
No files matched your search
@@ -110,12 +110,15 @@ def launch_desktop_tui(target: DesktopTarget) -> int:
|
||||
if cache is not None and not Path(cache).is_absolute():
|
||||
raise DesktopTargetError("Desktop client cache must be absolute")
|
||||
command = resolve_tui_command(data_dir=Path(cache)) if cache else resolve_tui_command()
|
||||
# An old client may ignore the probe flag. It must not consume terminal
|
||||
# input or connect using credentials inherited from another TUI session.
|
||||
env = {key: value for key, value in os.environ.items() if not key.startswith("NANOBOT_TUI_")}
|
||||
probe = subprocess.run(
|
||||
[*command, "--desktop-protocol"], capture_output=True, timeout=15, check=False,
|
||||
stdin=subprocess.DEVNULL, env=env,
|
||||
)
|
||||
if probe.returncode != 0 or probe.stdout.strip() != b"1":
|
||||
raise DesktopTargetError("The terminal client does not support Desktop attachment")
|
||||
env = {key: value for key, value in os.environ.items() if not key.startswith("NANOBOT_TUI_")}
|
||||
env["NANOBOT_TUI_DESKTOP_RESOLVER"] = json.dumps([
|
||||
sys.executable, "-I", "-S", str(Path(__file__).resolve()), "--resolve",
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user