Skip to content

feat: Add websocket wrapper for processes

Andrew Fontaine requested to merge afontaine/attach-support/mitt into main

The added websocket wrapper uses a simple event hub implementation (mitt) to provide easy access to the websocket's many streams.

The five possible streams are as follows:

  • STDIN
  • STDOUT
  • STDERR
  • STATUS
  • RESIZE

Calling connect with a websocket URL and optional extra protocols will connect to the given URL, and return a promise that resolves to the websocket wrapper upon connection.

Main usage of the wrapper is then as follows:

  • on* functions receive a callback to be called with data is received to that stream. The two most useful here are onStdout and onStderr, as These are the output streams for the pod.
  • send* functions send data to a give stream. Here, sendStdin is the most important, as that is the main way of sending data to the process within your websocket. sendResize gives dimensions for the tty to run processes in, which is important if you, e.g., want curses-based UIs to work.

For #2 (closed)

Merge request reports