@@ -833,6 +833,9 @@ or removing a command fails until the table changes in the same commit.
833833| `remote.sshConfigHosts` | List the Host aliases of the user's SSH configuration for an import |
834834| `remote.mottyHosts` | List the SSH hosts saved in Motty for an import |
835835| `remote.listWslDistributions` | List the WSL distributions installed on this Windows machine |
836+ | `remote.listContainers` | List the running Docker or Podman containers on this machine or a connected host |
837+ | `remote.devcontainerConfigs` | List the `devcontainer.json` files of a local folder |
838+ | `remote.devcontainerUp` | Build or reuse and start a trusted local folder's dev container with the Dev Container CLI |
836839| `remote.preferences` | Read the remote workspace settings and what each automatic value resolves to |
837840| `remote.editPreferences` | Set the SSH program, the reconnect limit, whether reverse forwards are allowed or what closing a connection does to its programs, or make one automatic again |
838841| `remote.runningPrograms` | List the processes and terminals a connection's host session still runs |
@@ -5941,6 +5944,85 @@ its redacted message for display; it is never logged. Cancellation and the
59415944bound are `cancelled` and `timed_out`. Nothing is saved: the window lists
59425945the distributions each time it opens.
59435946
5947+ `remote.listContainers` takes `{ engine, sessionId? }`, where `engine` is
5948+ `docker` or `podman`, and returns `{ available, containers, diagnostics }`.
5949+ Core runs `<engine> ps --no-trunc --format '{{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Status}}'`,
5950+ at most 15 seconds: on this machine in Core's own environment (the login
5951+ shell's `PATH` the application put in front, and variables such as
5952+ `DOCKER_HOST`) when `sessionId` is absent, and otherwise on that
5953+ connection's host in the server's environment, the same one the connection
5954+ later enters the container from. Only running containers are listed, since
5955+ Lithe never starts, creates or changes a container. `containers` are
5956+ `{ id, name, image, status }` in the engine's order, at most 256 and from at
5957+ most 256 KiB of output: `id` is the full id, `name` the first of the
5958+ container's names, and `image` and `status` the engine's text without
5959+ control characters, at most 256 bytes each. Lines that are not four fields,
5960+ or whose id or name is not a container name, are skipped, and so are
5961+ repeated ids. `available` is `false` when the engine CLI cannot start there;
5962+ when it runs and fails, for example because its service is not running,
5963+ `containers` is empty and `diagnostics` holds its redacted message for
5964+ display; it is never logged. Any other field is `invalid_request` ("Invalid
5965+ container listing request"), so a request cannot pick the program; an unknown
5966+ `sessionId` is `connection_closed`, and cancellation and the bound are
5967+ `cancelled` and `timed_out`. Nothing is saved.
5968+
5969+ #### Dev Containers
5970+
5971+ A local folder's dev container is built and started by the reference Dev
5972+ Container CLI (`devcontainer`, from `@devcontainers/cli`; `devcontainer.cmd`
5973+ on Windows) on `PATH`, then entered like any running container with
5974+ `remote.connect`'s `container`. Lithe does not interpret the configuration
5975+ and adds no mounts or options to it.
5976+
5977+ `remote.devcontainerConfigs` takes `{ folder }`, an absolute folder on this
5978+ machine, and returns `{ configs }`: `{ path, name? }` for each regular file in
5979+ the places the specification searches, in this order:
5980+ `.devcontainer/devcontainer.json`, `.devcontainer.json`, then
5981+ `.devcontainer/<subfolder>/devcontainer.json` for at most 64 subfolders in
5982+ name order, skipping names that start with `.`. `path` is relative to the
5983+ folder with `/` separators. `name` is the configuration's `name`, read as
5984+ JSON with comments and trailing commas, without control characters and at
5985+ most 128 bytes; it is absent when the file is larger than 1 MiB, resolves
5986+ outside the folder, cannot be read or has no non-empty string `name`. A
5987+ relative or empty `folder` is `invalid_request`; a folder that does not
5988+ exist is `workspace_not_found`. Reading starts nothing.
5989+
5990+ `remote.devcontainerUp` takes `{ folder, config?, engine,
5991+ projectCodeAllowed }` and returns `{ container?, diagnostics }`. Building runs
5992+ the folder's code on this machine (`initializeCommand`, Dockerfiles, feature
5993+ scripts), so when `projectCodeAllowed` is `false` nothing starts and the
5994+ request fails with `devcontainer_untrusted_folder`; native clients pass the
5995+ folder's trust decision, as for Git. `config` must be one of the `path`s
5996+ `remote.devcontainerConfigs` lists for the folder, otherwise
5997+ `invalid_request`; without it the CLI searches the folder itself. Core runs
5998+ `devcontainer up --workspace-folder <folder> [--config <folder>/<config>]`,
5999+ adding `--docker-path podman` after `up` for `engine: "podman"`, on this
6000+ machine in Core's own environment, for at most one hour. Each line the CLI
6001+ logs to standard error is sent as a `{ type: "devcontainerOutput", text }`
6002+ event, redacted, at most 4096 bytes per event and 2 MiB in all; after that
6003+ one `{ type: "devcontainerOutput", truncated: true }` event follows and later
6004+ lines are dropped. The log is shown, never logged.
6005+
6006+ The result is the last line of standard output that is a JSON object with an
6007+ `outcome`:
6008+
6009+ - `success`: `container` is `{ engine, container, containerId, user?,
6010+ workspaceFolder }`. `containerId` is the CLI's container id, `container` the
6011+ name `<engine> inspect --format '{{.Name}}'` gives within 15 seconds
6012+ (without Docker's leading `/`), or the id when it gives none, `user` the
6013+ configuration's `remoteUser`, and `workspaceFolder` the absolute
6014+ `remoteWorkspaceFolder` to open. A container id that is not a container
6015+ name, a user `exec` cannot take, or a folder that is not absolute is
6016+ `parse_failed`, and so is a successful exit without a result line.
6017+ - `error`, or no result line with a failed exit: `container` is absent and
6018+ `diagnostics` holds the end of the CLI's log followed by its `message` and
6019+ `description`, redacted, for display.
6020+
6021+ A missing CLI is `runtime_missing`; any other field is `invalid_request`
6022+ ("Invalid dev container start request"), so a request cannot add mounts or
6023+ pick the program; cancellation and the bound are `cancelled` and
6024+ `timed_out`. Nothing is saved.
6025+
59446026#### Remote workspace preferences
59456027
59466028The settings page "Tools › Remote Workspace" edits three values that apply to
@@ -6075,14 +6157,43 @@ because `wsl.exe` asks no questions. An unknown distribution is
60756157the distribution and the account (`{ wsl: { distribution, user } }` as the
60766158first and only hop).
60776159
6160+ The request may also name a running container as `container: { engine,
6161+ container, user? }`, where `engine` is `docker` or `podman`, `container` a
6162+ name or id such as `remote.listContainers` returned, and `user` a user, uid or
6163+ `user:group` inside it (the image's default user when absent or empty). Next
6164+ to `connection` or `wsl` the container is on that host: the remote command
6165+ becomes `<engine> exec -i [-u <user>] <container> …` there, after the login.
6166+ On its own the container is on this machine, and Core starts that command
6167+ itself in place of OpenSSH, with its own environment so the engine finds its
6168+ service. Core only enters the running container: it never starts, creates or
6169+ reconfigures it, mounts directories into it or asks for more rights than the
6170+ engine CLI has. The probe, the checked upload into the container's `$HOME`
6171+ and the stages are the same, and nothing is relayed through
6172+ `remote.authRespond` for the engine. When the engine gives up before the
6173+ server starts, a container that does not exist, is not running or is paused,
6174+ and an engine whose service does not answer, are `unreachable`; a service
6175+ socket the user may not open is `failed`, not `authenticationFailed`, even
6176+ over SSH; and other failures are `failed` with the engine's message in
6177+ `diagnostics` (or `<engine> exited with status <code>` when it printed
6178+ nothing). The connection log's `transport` is `container`, `ssh-container` or
6179+ `wsl-container`, without the container's name. Trust decisions name the
6180+ container after the other hops, as `{ container: { engine, program,
6181+ container, user? } }`, so a decision never carries over to another container
6182+ or account.
6183+
60786184A request that names both `connection` and `wsl` is `invalid_request` with
6079- `details` `{ field: "wsl", reason: "invalid" }`, and one that names neither
6080- `{ field: "connection", reason: "required" }`. A malformed connection, a
6081- distribution that is empty, longer than 64 bytes or not a WSL distribution
6082- name, a user that is longer than 32 bytes or not a Linux login name, an
6083- unknown `target` or a `sha256` that is not 64 hexadecimal digits is
6084- `invalid_request`, before OpenSSH or `wsl.exe` starts. A missing `ssh` or
6085- `wsl.exe` is `runtime_missing`. When the build for the host's platform cannot be
6185+ `details` `{ field: "wsl", reason: "invalid" }`, and one that names none of
6186+ `connection`, `wsl` and `container` `{ field: "connection", reason:
6187+ "required" }`. A malformed connection, a distribution that is empty, longer
6188+ than 64 bytes or not a WSL distribution name, a user that is longer than 32
6189+ bytes or not a Linux login name, a container that is empty (`{ field:
6190+ "container", reason: "required" }`), longer than 128 bytes or not a container
6191+ name, a container user that is longer than 64 bytes, starts with `-` or holds
6192+ other characters than letters, digits and `_.:-` (`{ field: "user" }`), an
6193+ unknown `engine` or field, an unknown `target` or a `sha256` that is not 64
6194+ hexadecimal digits is `invalid_request`, before OpenSSH, `wsl.exe` or the
6195+ engine starts. A missing `ssh`, `wsl.exe` or local engine CLI is
6196+ `runtime_missing`. When the build for the host's platform cannot be
60866197read or its SHA-256 differs, the attempt ends as `remote_server_invalid`
60876198without sending anything; `details` says which of the two happened and, for a
60886199mismatch, the SHA-256 Core computed, but never the path. Cancellation and the
0 commit comments