Commit graph

16 commits

Author SHA1 Message Date
Petr Houška
b6d5c2ecdc fix(env): kill the daemon's commands when it is terminated
Connection.close() ends stdin and sends SIGTERM at once. The daemon did not
handle SIGTERM, so it died before its end-of-input kill_all, and running
commands were reparented to init. The daemon now blocks SIGTERM, SIGINT and
SIGHUP before starting any thread and waits for them on its own thread, which
kills every process group it started and exits. On Windows the job object
already kills commands with the daemon.
2026-10-28 21:09:58 +01:00
Michael Yu
479d6e5e29
fix(env): include stderr in pi-env startup errors (#10716)
When the daemon exits before `hello`, the error has only the exit code.
For example, with `loginShell: true` and a profile that aborts on a
missing file:

```
pi-env exited with code 3 before it was ready
```

`sshConnection`'s probe and deploy steps already report ssh's stderr, so
this is about the launch itself: a login profile, a daemon that can't
execute, or a `Connection` created with its own command, which has no
probe or deploy step, so auth and network errors also end up here.

This keeps a short stderr tail until `hello` and adds it to startup
errors:

```
pi-env exited with code 3 before it was ready
remote stderr:
profile: /opt/toolchain/env.sh: No such file or directory
```

The tail is capped at 20 lines / 2000 chars, with terminal escapes and
control characters stripped. Ready sessions are unchanged.

I hit it while testing `loginShell` against an sshd in Docker. Tests are
in `test/connection.test.ts`, and `npm run check` and `./test.sh` pass.
2026-10-27 16:16:49 +01:00
Mario Zechner
14ff455a0a fix(env): make the read/bash differential test deterministic and meaningful
The fake tool API lacked retainedOutput, so every bash case threw on both sides
and the test only compared the error text. Its stdout+stderr case also depended
on the order of two concurrently read pipes and failed intermittently in CI.
The API now provides retainedOutput, each bash case writes to one stream, and
bash cases must return a result.
2026-10-16 19:58:24 +00:00
Armin Ronacher
d6370b72d0 fix(env): make the listing cancel and platform tests hold in CI
- Give the listing cancel test 30 s: creating 10,000 files takes over 5 s
  on Windows CI.
- Accept an x64 daemon on arm64 macOS: the darwin-x64 release daemon runs
  through Rosetta in CI.
2026-10-13 01:23:33 +02:00
Mario Zechner
de022efd61 test(env): wait for the foreground job's name, not just any foreground process
The shell forks before it execs, so a poll could catch the forked shell (named sh) and fail the name check.
2026-10-12 23:19:48 +00:00
Mario Zechner
b6fda579f4 feat(env): listFiles for remote and local environments, nodePlatform
RemoteExecutionEnv.listFiles resolves the path and lists through the
daemon; a daemon without the listFiles feature yields not_supported.
LocalExecutionEnv is NodeExecutionEnv plus listFiles through a daemon on
the same machine, so local and SSH sessions list with the same code.
nodePlatform maps hello's Rust names to Node's (windows -> win32,
macos -> darwin, x86_64 -> x64, aarch64 -> arm64).
2026-10-12 15:22:14 +00:00
Armin Ronacher
74613de659 feat(env): report a terminal's foreground job with ptyForeground
The process group in front of the pty when it is not the program's own (a job its shell runs), with the leader's name on macOS and Linux. Exposed as RemoteTerminal.foreground().
2026-10-11 16:35:08 +00:00
Armin Ronacher
367b2bcf59 feat(env): run programs in pseudo-terminals for interactive terminals
The daemon gets pty, ptyWrite and ptyResize: raw terminal output as events, input in arrival order, SIGWINCH on resize, and the process group killed on cancel or a lost connection. openTerminal() is the client, localDaemon() the daemon for this machine. Unix only; Windows answers ENOTSUP.
2026-10-11 16:35:08 +00:00
Armin Ronacher
5b31896472 fix(env): login shell test works when the account shell is zsh 2026-10-05 21:17:23 +02:00
Mario Zechner
031b24aa64 feat(env): lazy SSH connections 2026-10-05 20:39:50 +02:00
Mario Zechner
6fa21f2a37 fix(env): time out stuck ssh calls and daemon starts 2026-10-05 17:32:22 +02:00
Mario Zechner
956e81504c fix(env): ENOTDIR for listing a file on Windows, pinned NDK install, protocol docs 2026-10-05 17:32:22 +02:00
Mario Zechner
ed94330a20 feat(env): hardened SSH bootstrap and release daemon tests 2026-10-05 17:32:22 +02:00
Mario Zechner
46d0ff9365 fix(env): daemon robustness, output windows, native watching and Node read semantics 2026-10-05 17:32:22 +02:00
Mario Zechner
b78e6a9085 feat(env): SSH bootstrap and daemons in the npm package
- connectSsh detects the remote system, deploys the packaged daemon
  verified by SHA-256 before it runs, and connects over ssh with strict
  host keys under a fixed alias; scanHostKey and acceptHostKey
- Windows detection and deployment through PowerShell
- release builds the daemon for every supported remote system and
  ships them in @earendil-works/pi-env's bin/
- end-to-end tests against a disposable sshd
2026-10-05 13:06:08 +02:00
Mario Zechner
ba03e03f2d feat(env): add @earendil-works/pi-env, remote execution environments over SSH
- RemoteExecutionEnv: a Durable ExecutionEnv on another machine whose
  results match NodeExecutionEnv there; Connection to the pi-env daemon
- packages/env/daemon: the Rust daemon for Linux, macOS, Android and
  Windows, following Node and libuv semantics
- env.yml runs Durable's env tests, the daemon's checks and pi-env's
  conformance and differential tests on Linux, macOS and Windows
2026-10-05 12:50:48 +02:00