Feature(Go): terminal_close, idle sweep and legacy-client guard
Add the terminal_close tool so a caller can release a shell session explicitly instead of waiting for it to age out. The tool is idempotent for the session it names, rejects a session_id that does not match the live session with -32002, and runs without the per-device lock so it can interrupt a terminal_exec call that is still polling on the same device. Give hub leases a generation counter: the generation is bumped when a pending lease is created and carried across a device re-login. MCP-side closes pass the generation, so a stale session can no longer tear down a shell a human operator opened after the device reconnected. The reaper runs on a 30 s ticker (shortened when TermIdle is smaller), skips sessions that are still opening, and reclaims idle sessions as well as commands overdue past the one-hour busy cap. The pre-bind terminal-close path in cmd no longer closes unconditionally; it touches only a pending lease, because an unbound sub-connection carries no lease identity and may be a stale orphan. Covered by unit tests for close semantics, lock exemption, reaper lifecycle and lease-generation ownership, plus a live run against a Debug ghost: close before and during a command, reopen, idle reap and mismatched-id rejection all behave as specified. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
599c891c00
commit
808747f9d2
10 files changed
+633
-52
No files matched your search
@@ -55,9 +55,10 @@ type termSession struct {
|
||||
droppedBytes uint64
|
||||
|
||||
isPTY bool
|
||||
ready bool // OnTerminalReady seen
|
||||
sawOutput bool // shell printed its first screen (prompt); bootstrap done
|
||||
opening bool // hub.OpenTerminalSession still in flight
|
||||
ready bool // OnTerminalReady seen
|
||||
sawOutput bool // shell printed its first screen (prompt); bootstrap done
|
||||
opening bool // hub.OpenTerminalSession still in flight
|
||||
lease uint64 // hub lease generation; 0 until the open completes
|
||||
closed bool
|
||||
closeReason string
|
||||
|
||||
|
||||
Reference in new issue
Block a user