dsh-shell-host: DSH Persistent PTY and Terminal Management Plugin

Introduction

The DSH plugin ecosystem follows the “everything is a plugin” philosophy. dsh-shell-host is a tool-level bundle that natively supports MSYS2 (UCRT64) bash and is designed to provide persistent connectivity across the DSH shell seam. It delivers persistent PTY sessions, preset terminal launchers, and WSL bridge utilities. It is independent of any shell executor, does not expose the ctx.shell context, and does not take over the upstream loader-row.

Core Features

Persistent PTY Sessions (./pty)

./pty is the core of persistent sessions, providing the following capabilities:
- PTY management: implemented via src/pty/session-core.ts. Exposes four tools: pty_open, pty_send, pty_tail, pty_close.
- SSH interaction: builds full-duplex SSH sessions on top of the PTY core, exposing ssh_start, ssh_tail, ssh_send, ssh_close.
- ssh_start({ host, jump?, shell?, port?, options? }): supports standard ports, non-standard ports (via the -p flag), default keepalive settings (ServerAliveInterval=15), and custom -o options.
- Note: sessions will not automatically reconnect on disconnection; explicitly invoke ssh_start again.
- Limits: the default maxSessions is 8; exceeding it will result in an error.

Preset Terminals (./terminal)

./terminal is a launcher-layer plugin that provides a single tool, shell_open.
- Function: shell_open(preset, cwd?, env?, idleTimeoutMs?). It resolves the preset and opens a session via the ./pty core.
- Characteristics:
- No man-in-the-middle interception; directly operates the PTY core.
- Supports custom presets that override built-in presets. The result includes fields such as source, overrode (whether an override occurred), executable, probed, cwd, etc.
- Supports an optional idleTimeoutMs to auto-close the session when no new output occurs.

WSL Bridge (./wsl)

Provides Windows access tools for agents running inside WSL:
- win_ls, win_read, win_write, win_run, win_open
- win_path, win_drives

Architectural Notes

  • Not an executor: contains no shell executor logic and does not provide the ctx.shell provider.
  • Not a takeover: does not perform upstream loader-row takeover.
  • Separation of responsibilities: one-shot remote commands belong to the separate dsh-shell-remote plugin; long-lived interactive sessions (e.g., ssh_start) are handled by this plugin.

Host Environment Requirements

This bundle assumes the host environment has the MSYS2 toolchain installed; it does not install MSYS2. If the following tools are missing, agent verification methods may be downgraded:

pacman -S --needed diffutils patch jq unzip rsync

Code Examples

PTY Session

import * as pty from 'dsh-shell-host/pty'

// Open a session
const sessionId = pty.pty_open({ command: 'bash' })

// Send data
pty.pty_send(sessionId, 'ls -la\n')

// View output
const output = pty.pty_tail(sessionId)

SSH Session

import * as pty from 'dsh-shell-host/pty'

// Start an SSH session
const sshSession = pty.ssh_start({
  host: 'example.com',
  user: 'admin',
  port: 22,
  options: '-o ProxyCommand=...' // Supports custom options
})

Terminal Launcher

import * as terminal from 'dsh-shell-host/terminal'

// Open a preset terminal
const session = terminal.shell_open('pwsh', { cwd: '/tmp', idleTimeoutMs: 30000 })
  • License: MIT
  • Maintainer: ch1bug
  • GitHub: https://github.com/ch1bug/dsh-shell-host
  • Directory: https://www.skillhub.cn/plugins/ch1bug/dsh-shell-host
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye