agentty 0.19.5 → 0.19.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,98 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v0.19.7] - 2026-11-20
11
+
12
+ ### Added
13
+
14
+ - `agentty`: show a harness session's reasoning and answer in the session view while the
15
+ model writes them; the saved answer replaces the streamed text when the turn ends.
16
+ - `ag-contracts`: add the transient `TurnEvent::Output` event for streamed turn output.
17
+ - `ag-harness`: register catalog entries with `ModelRegistry::register_catalog_entry`
18
+ and `HarnessBuilder::registration_revision`, so sessions built from a catalog resume
19
+ through `Harness::from_registry`.
20
+ - release: publish Homebrew formulas to `agentty-xyz/homebrew-tap`, `cargo-binstall`
21
+ metadata, and static musl Linux archives for x86-64 and ARM64; the shell and npm
22
+ installers fall back to the musl build on old glibc or musl systems.
23
+ - `ag-release`: add `prepare <version> --date <date>`, which bumps workspace versions,
24
+ refreshes `Cargo.lock`, and adds the changelog heading.
25
+
26
+ ### Changed
27
+
28
+ - release: build Linux targets on Ubuntu 26.04 runners and macOS targets on macOS 26.
29
+ - workspace: update GitHub Actions and the Rust toolchain.
30
+ - release: bump workspace crate metadata and lockfile package versions to `0.19.7`.
31
+
32
+ ### Fixed
33
+
34
+ - `agentty`: a chat reply to an output awaiting approval now resumes a paused graph, for
35
+ example after a restart, instead of running as an ordinary turn outside the graph.
36
+ - `agentty`: automatic focused review waits for a working graph to finish instead of
37
+ starting between its nodes.
38
+ - `agentty`: Settings offers the `Fast` speed only for models that support it, and
39
+ titles, auto-commit, and review keep such a model at `Normal` speed instead of
40
+ switching to another model.
41
+
42
+ ### Contributors
43
+
44
+ - @andagaev
45
+ - @minev-dev
46
+
47
+ ## [v0.19.6] - 2026-11-19
48
+
49
+ ### Added
50
+
51
+ - `ag-router`: implement the Anthropic Messages wire protocol, with signed thinking
52
+ replay, native or forced-tool structured output, and streamed responses.
53
+ - `ag-router`: stream Chat Completions and report text, reasoning, and tool-argument
54
+ deltas through `Router::execute_streamed`; harness runs emit them as `ItemDelta`
55
+ events.
56
+ - `ag-router`: mark Anthropic prompt-cache breakpoints on the tools, `system` prompt,
57
+ and latest message by default (`ProviderSpec::with_cache_breakpoints`).
58
+ - `ag-router`: add a per-provider `RetryPolicy` with jitter, opt-in `5xx` and `529`
59
+ retries, and HTTP-date `Retry-After`, and report waits as `Retrying` run events.
60
+ - `ag-harness`: gate writing and executing tool calls behind an `ApprovalHandler` with a
61
+ decision timeout, carried over `serve` as server-to-client requests.
62
+ - `ag-harness`: choose the native sandbox behavior with `HarnessBuilder::sandbox`, embed
63
+ the sandbox helper through `ag_harness::sandbox::dispatch`, and add
64
+ `Session::replayed_range`.
65
+ - `ag-harness-cli`: pick models from the provider catalog, show per-turn usage and cost,
66
+ and add `/usage` and `/history`.
67
+ - release: add `ag-release`, which plans, builds, and packages releases, writes the
68
+ release notes, and generates `.github/workflows/release.yml`.
69
+
70
+ ### Changed
71
+
72
+ - release: build and publish releases with `ag-release` instead of `dist`. Archives are
73
+ `.tar.gz` instead of `.tar.xz`, `release-manifest.json` replaces `dist-manifest.json`,
74
+ and the `agentty-update` and `testty-update` binaries are no longer published.
75
+ - release: the npm packages have no dependencies and need Node.js 18 or newer; the shell
76
+ installer verifies each archive's SHA-256 and rejects musl and too-old glibc.
77
+ - `agentty`: update shell installs in the background through the shell installer. Shell
78
+ installs of `v0.19.5` or earlier need one manual reinstall first.
79
+ - `agentty`: declare image input and tool calls for harness models from the harness
80
+ provider catalog.
81
+ - `ag-harness`: run commands unsandboxed with a `SandboxWarning` when the native sandbox
82
+ cannot start; `IfUnavailable::Refuse` keeps failing closed.
83
+ - release: bump workspace crate metadata and lockfile package versions to `0.19.6`.
84
+
85
+ ### Removed
86
+
87
+ - `agentty`: remove stacked sessions and the append-to-stack action; unfinished former
88
+ stacked children now target their root session's base branch.
89
+
90
+ ### Fixed
91
+
92
+ - `agentty`: remove worktrees of archived sessions reliably, including sessions whose
93
+ pull request was closed without merging, and sweep leftover worktrees at startup.
94
+ - `ag-harness-cli`: `serve` no longer fails `session/create` for cataloged models
95
+ without a declared context profile.
96
+
97
+ ### Contributors
98
+
99
+ - @andagaev
100
+ - @minev-dev
101
+
10
102
  ## [v0.19.5] - 2026-11-18
11
103
 
12
104
  ### Added
package/README.md CHANGED
@@ -31,9 +31,9 @@ ______________________________________________________________________
31
31
 
32
32
  ### npm (recommended)
33
33
 
34
- The `npm`, Bun, and `pnpm` packages require Node.js on your `PATH`. Global installs
35
- support automatic updates through the original package manager when Agentty can identify
36
- it.
34
+ The `npm`, Bun, and `pnpm` packages require Node.js 18 or newer on your `PATH`. Global
35
+ installs support automatic updates through the original package manager when Agentty can
36
+ identify it.
37
37
 
38
38
  ```sh
39
39
  npm install -g agentty
@@ -71,9 +71,22 @@ npx agentty
71
71
 
72
72
  </details>
73
73
 
74
+ <details>
75
+ <summary>Homebrew</summary>
76
+
77
+ ```sh
78
+ brew install agentty-xyz/tap/agentty
79
+ ```
80
+
81
+ Update with `brew upgrade agentty`.
82
+
83
+ </details>
84
+
74
85
  <details>
75
86
  <summary>Shell</summary>
76
87
 
88
+ Shell installs also update automatically.
89
+
77
90
  ```sh
78
91
  curl --proto '=https' --tlsv1.2 -LsSf https://github.com/agentty-xyz/agentty/releases/latest/download/agentty-installer.sh | sh
79
92
  ```
@@ -89,8 +102,18 @@ macOS source builds require Xcode Command Line Tools for native process bindings
89
102
  cargo install agentty
90
103
  ```
91
104
 
105
+ [`cargo-binstall`](https://github.com/cargo-bins/cargo-binstall) installs the prebuilt
106
+ release binary instead:
107
+
108
+ ```sh
109
+ cargo binstall agentty
110
+ ```
111
+
92
112
  </details>
93
113
 
114
+ Prebuilt Linux binaries need glibc 2.35 or newer; older distributions and musl systems
115
+ such as Alpine get the statically linked musl build.
116
+
94
117
  ## Supported CLI Agents
95
118
 
96
119
  Agentty currently supports Codex, Claude, and Antigravity. Install and authenticate at
package/binary.js CHANGED
@@ -1,128 +1,333 @@
1
- const { Package } = require("./binary-install");
1
+ "use strict";
2
+ // Installs and runs the agentty 0.19.7 binaries from https://github.com/agentty-xyz/agentty.
3
+ // Generated by ag-release 0.19.7.
4
+ //
5
+ // `install.js` installs the binaries after `npm install`. When install
6
+ // scripts are disabled, the first run of a command installs them instead.
7
+ // Set AGENTTY_DOWNLOAD_URL to download the release archives from
8
+ // another base URL; `file://` URLs work.
9
+
10
+ const childProcess = require("child_process");
11
+ const crypto = require("crypto");
12
+ const fs = require("fs");
2
13
  const os = require("os");
3
- const cTable = require("console.table");
4
- const libc = require("detect-libc");
5
- const { configureProxy } = require("axios-proxy-builder");
14
+ const path = require("path");
15
+ const url = require("url");
6
16
 
7
- const error = (msg) => {
8
- console.error(msg);
9
- process.exit(1);
17
+ const RELEASE = {
18
+ "app": "agentty",
19
+ "binaries": [
20
+ "agentty"
21
+ ],
22
+ "downloadUrl": "https://github.com/agentty-xyz/agentty/releases/download/v0.19.7",
23
+ "downloadUrlVariable": "AGENTTY_DOWNLOAD_URL",
24
+ "minGlibc": "2.35",
25
+ "targets": [
26
+ {
27
+ "arch": "arm64",
28
+ "archive": "agentty-aarch64-apple-darwin.tar.gz",
29
+ "directory": "agentty-aarch64-apple-darwin",
30
+ "libc": "none",
31
+ "platform": "darwin",
32
+ "sha256": "6dda5038732e57b0a26b699d4cf0192115026e8941d1a9e8b44dd09243610e72",
33
+ "target": "aarch64-apple-darwin"
34
+ },
35
+ {
36
+ "arch": "arm64",
37
+ "archive": "agentty-aarch64-unknown-linux-gnu.tar.gz",
38
+ "directory": "agentty-aarch64-unknown-linux-gnu",
39
+ "libc": "gnu",
40
+ "platform": "linux",
41
+ "sha256": "10398cddc77f9be0c45c8f37c083a7575ca077e0c038b40db7e4baefb8edbdca",
42
+ "target": "aarch64-unknown-linux-gnu"
43
+ },
44
+ {
45
+ "arch": "arm64",
46
+ "archive": "agentty-aarch64-unknown-linux-musl.tar.gz",
47
+ "directory": "agentty-aarch64-unknown-linux-musl",
48
+ "libc": "musl",
49
+ "platform": "linux",
50
+ "sha256": "d6eb8d1ac53d86695009cd4c6f49f5c536519fb6454f6ae35b679c27ae838a58",
51
+ "target": "aarch64-unknown-linux-musl"
52
+ },
53
+ {
54
+ "arch": "x64",
55
+ "archive": "agentty-x86_64-apple-darwin.tar.gz",
56
+ "directory": "agentty-x86_64-apple-darwin",
57
+ "libc": "none",
58
+ "platform": "darwin",
59
+ "sha256": "96a2e355417b6ce888d871e53f07111fc6d0ebdebb1d77e4d4f798bacda14d58",
60
+ "target": "x86_64-apple-darwin"
61
+ },
62
+ {
63
+ "arch": "x64",
64
+ "archive": "agentty-x86_64-unknown-linux-gnu.tar.gz",
65
+ "directory": "agentty-x86_64-unknown-linux-gnu",
66
+ "libc": "gnu",
67
+ "platform": "linux",
68
+ "sha256": "bddfbd62ccf99b074f82e3da1e189d14a7dac8268a5b2ccdc7851066db623a89",
69
+ "target": "x86_64-unknown-linux-gnu"
70
+ },
71
+ {
72
+ "arch": "x64",
73
+ "archive": "agentty-x86_64-unknown-linux-musl.tar.gz",
74
+ "directory": "agentty-x86_64-unknown-linux-musl",
75
+ "libc": "musl",
76
+ "platform": "linux",
77
+ "sha256": "218ad75ac7b422675256b4f832858b701ce6f98eab8b88c51be106c765748d19",
78
+ "target": "x86_64-unknown-linux-musl"
79
+ }
80
+ ],
81
+ "version": "0.19.7"
10
82
  };
11
83
 
12
- const {
13
- name,
14
- artifactDownloadUrls,
15
- supportedPlatforms,
16
- glibcMinimum,
17
- } = require("./package.json");
18
-
19
- // FIXME: implement NPM installer handling of fallback download URLs
20
- const artifactDownloadUrl = artifactDownloadUrls[0];
21
- const builderGlibcMajorVersion = glibcMinimum.major;
22
- const builderGlibcMinorVersion = glibcMinimum.series;
23
-
24
- const getPlatform = () => {
25
- const rawOsType = os.type();
26
- const rawArchitecture = os.arch();
27
-
28
- // We want to use rust-style target triples as the canonical key
29
- // for a platform, so translate the "os" library's concepts into rust ones
30
- let osType = "";
31
- switch (rawOsType) {
32
- case "Windows_NT":
33
- osType = "pc-windows-msvc";
34
- break;
35
- case "Darwin":
36
- osType = "apple-darwin";
37
- break;
38
- case "Linux":
39
- osType = "unknown-linux-gnu";
40
- break;
84
+ // The binaries live in `<package>/node_modules/.bin_real/`; tools that
85
+ // recognize npm installs by their executable's path rely on this location.
86
+ const INSTALL_DIR = path.join(__dirname, "node_modules", ".bin_real");
87
+
88
+ // Node's built-in `fetch` ignores proxies, so a configured one routes
89
+ // downloads through `curl`. The variables and their order are those that
90
+ // `proxy-from-env` 1.x reads for an `https:` URL, each in lower, then upper
91
+ // case. npm passes its `https-proxy`, `proxy`, and `noproxy` settings to
92
+ // install scripts only as `npm_config_*` variables, which `curl` does not
93
+ // read, so the resolved values reach `curl` as options.
94
+ const PROXY_VARIABLES = ["npm_config_https_proxy", "https_proxy", "npm_config_proxy", "all_proxy"];
95
+ const NO_PROXY_VARIABLES = ["npm_config_no_proxy", "npm_config_noproxy", "no_proxy"];
96
+
97
+ // The terminal also sends these to the binary, which decides how to react.
98
+ const IGNORED_SIGNALS = ["SIGINT", "SIGQUIT"];
99
+
100
+ // Signals sent to this process alone, passed on to the binary.
101
+ const FORWARDED_SIGNALS = ["SIGHUP", "SIGTERM"];
102
+
103
+ /** Installs the binaries unless they are installed already. */
104
+ function install() {
105
+ installMissing().catch(report);
106
+ }
107
+
108
+ /** Runs `binary` with this process's arguments and standard streams. */
109
+ function run(binary) {
110
+ const program = path.join(INSTALL_DIR, binary);
111
+ const installed = fs.existsSync(program) ? Promise.resolve() : installMissing();
112
+ installed.then(() => spawn(program)).catch(report);
113
+ }
114
+
115
+ async function installMissing() {
116
+ const missing = RELEASE.binaries.some(
117
+ (binary) => !fs.existsSync(path.join(INSTALL_DIR, binary)),
118
+ );
119
+ if (!missing) {
120
+ return;
121
+ }
122
+
123
+ const target = detectTarget();
124
+ const base = process.env[RELEASE.downloadUrlVariable] || RELEASE.downloadUrl;
125
+ const source = `${base.replace(/\/+$/, "")}/${target.archive}`;
126
+ const workDir = fs.mkdtempSync(path.join(os.tmpdir(), `${RELEASE.app}-`));
127
+ try {
128
+ const archive = path.join(workDir, target.archive);
129
+ say(`downloading ${RELEASE.app} ${RELEASE.version} for ${target.target}`);
130
+ await download(source, archive);
131
+ verifySha256(archive, target);
132
+ runTool("tar", ["-xzf", archive, "-C", workDir], `cannot extract ${target.archive}`);
133
+ fs.mkdirSync(INSTALL_DIR, { recursive: true });
134
+ for (const binary of RELEASE.binaries) {
135
+ installBinary(path.join(workDir, target.directory, binary), binary);
136
+ }
137
+ } finally {
138
+ fs.rmSync(workDir, { force: true, recursive: true });
139
+ }
140
+ say(`installed ${RELEASE.app} ${RELEASE.version} to ${INSTALL_DIR}`);
141
+ }
142
+
143
+ /** Returns the release target of this platform, or throws. */
144
+ function detectTarget() {
145
+ const { arch, platform } = process;
146
+ const arches = [arch];
147
+ // Under Rosetta 2, Node for x64 runs on Apple silicon: prefer the native
148
+ // archive.
149
+ if (platform === "darwin" && arch === "x64" && sysctl("hw.optional.arm64") === "1") {
150
+ arches.unshift("arm64");
151
+ }
152
+ const libc = platform === "linux" ? detectLibc(platform, arch) : { libcs: ["none"] };
153
+ const find = (libcs) =>
154
+ arches
155
+ .flatMap((candidate) =>
156
+ libcs.map((wanted) =>
157
+ RELEASE.targets.find(
158
+ (entry) =>
159
+ entry.platform === platform && entry.arch === candidate && entry.libc === wanted,
160
+ ),
161
+ ),
162
+ )
163
+ .find(Boolean);
164
+ const target = find(libc.libcs);
165
+ if (target) {
166
+ return target;
167
+ }
168
+ // A platform whose only targets need a glibc this system lacks fails with
169
+ // the reason.
170
+ if (libc.problem && find(["gnu"])) {
171
+ throw libc.problem;
172
+ }
173
+
174
+ throw unsupported(`${platform} ${arch}`);
175
+ }
176
+
177
+ function sysctl(name) {
178
+ const result = childProcess.spawnSync("sysctl", ["-n", name], { encoding: "utf8" });
179
+
180
+ return result.status === 0 ? result.stdout.trim() : "";
181
+ }
182
+
183
+ function unsupported(platform) {
184
+ const targets = RELEASE.targets.map((entry) => entry.target).join(", ");
185
+
186
+ return new Error(`unsupported platform ${platform}; ${RELEASE.app} supports ${targets}`);
187
+ }
188
+
189
+ /** Returns the C libraries whose targets run on this Linux system, in order
190
+ * of preference, as `libcs`: glibc targets when the system has glibc, at
191
+ * least the release minimum, and statically linked musl targets anywhere.
192
+ * When glibc targets do not run, `problem` is the error saying why. */
193
+ function detectLibc(platform, arch) {
194
+ process.report.excludeNetwork = true;
195
+ const version = process.report.getReport().header.glibcVersionRuntime;
196
+ if (!version) {
197
+ return { libcs: ["musl"], problem: unsupported(`${platform} ${arch} without glibc`) };
198
+ }
199
+ if (!RELEASE.minGlibc) {
200
+ return { libcs: ["gnu", "musl"] };
41
201
  }
42
202
 
43
- let arch = "";
44
- switch (rawArchitecture) {
45
- case "x64":
46
- arch = "x86_64";
47
- break;
48
- case "arm64":
49
- arch = "aarch64";
50
- break;
203
+ const needs = `${RELEASE.app} needs glibc ${RELEASE.minGlibc} or newer`;
204
+ const [major, minor] = version.split(".").map(Number);
205
+ if (!Number.isInteger(major) || !Number.isInteger(minor)) {
206
+ return { libcs: ["musl"], problem: new Error(`cannot determine the glibc version; ${needs}`) };
207
+ }
208
+ const [minMajor, minMinor] = RELEASE.minGlibc.split(".").map(Number);
209
+ if (major < minMajor || (major === minMajor && minor < minMinor)) {
210
+ return { libcs: ["musl"], problem: new Error(`${needs}, but this system has glibc ${version}`) };
51
211
  }
52
212
 
53
- if (rawOsType === "Linux") {
54
- if (libc.familySync() == "musl") {
55
- osType = "unknown-linux-musl-dynamic";
56
- } else if (libc.isNonGlibcLinuxSync()) {
57
- console.warn(
58
- "Your libc is neither glibc nor musl; trying static musl binary instead",
213
+ return { libcs: ["gnu", "musl"] };
214
+ }
215
+
216
+ /** Downloads `source` into the file `destination`. */
217
+ async function download(source, destination) {
218
+ try {
219
+ const proxy = firstVariable(PROXY_VARIABLES);
220
+ if (proxy) {
221
+ const noProxy = firstVariable(NO_PROXY_VARIABLES);
222
+ runTool(
223
+ "curl",
224
+ [
225
+ "--proxy",
226
+ proxy,
227
+ ...(noProxy ? ["--noproxy", noProxy] : []),
228
+ "--fail",
229
+ "--location",
230
+ "--silent",
231
+ "--show-error",
232
+ "--output",
233
+ destination,
234
+ source,
235
+ ],
236
+ "curl failed",
59
237
  );
60
- osType = "unknown-linux-musl-static";
238
+ } else if (source.startsWith("file:")) {
239
+ fs.copyFileSync(url.fileURLToPath(source), destination);
61
240
  } else {
62
- let libcVersion = libc.versionSync();
63
- let splitLibcVersion = libcVersion.split(".");
64
- let libcMajorVersion = splitLibcVersion[0];
65
- let libcMinorVersion = splitLibcVersion[1];
66
- if (
67
- libcMajorVersion != builderGlibcMajorVersion ||
68
- libcMinorVersion < builderGlibcMinorVersion
69
- ) {
70
- // We can't run the glibc binaries, but we can run the static musl ones
71
- // if they exist
72
- console.warn(
73
- "Your glibc isn't compatible; trying static musl binary instead",
74
- );
75
- osType = "unknown-linux-musl-static";
241
+ const response = await fetch(source);
242
+ if (!response.ok) {
243
+ throw new Error(`HTTP status ${response.status}`);
76
244
  }
245
+ fs.writeFileSync(destination, Buffer.from(await response.arrayBuffer()));
77
246
  }
247
+ } catch (error) {
248
+ const cause = error.cause ? ` (${error.cause.message})` : "";
249
+ throw new Error(`cannot download ${source}: ${error.message}${cause}`);
78
250
  }
251
+ }
79
252
 
80
- // Assume the above succeeded and build a target triple to look things up with.
81
- // If any of it failed, this lookup will fail and we'll handle it like normal.
82
- let targetTriple = `${arch}-${osType}`;
83
- let platform = supportedPlatforms[targetTriple];
84
-
85
- if (!platform) {
86
- error(
87
- `Platform with type "${rawOsType}" and architecture "${rawArchitecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${Object.keys(
88
- supportedPlatforms,
89
- ).join(",")}`,
90
- );
253
+ /** Returns the value of the first of `names` that is set, trying each in
254
+ * lower, then upper case, or an empty string. */
255
+ function firstVariable(names) {
256
+ for (const name of names) {
257
+ const value = process.env[name.toLowerCase()] || process.env[name.toUpperCase()];
258
+ if (value) {
259
+ return value;
260
+ }
91
261
  }
92
262
 
93
- return platform;
94
- };
263
+ return "";
264
+ }
95
265
 
96
- const getPackage = () => {
97
- const platform = getPlatform();
98
- const url = `${artifactDownloadUrl}/${platform.artifactName}`;
99
- let filename = platform.artifactName;
100
- let ext = platform.zipExt;
101
- let binary = new Package(platform, name, url, filename, ext, platform.bins);
266
+ /** Throws unless the file `archive` has the SHA-256 the release recorded. */
267
+ function verifySha256(archive, target) {
268
+ const found = crypto.createHash("sha256").update(fs.readFileSync(archive)).digest("hex");
269
+ if (found !== target.sha256) {
270
+ throw new Error(
271
+ `checksum mismatch for ${target.archive}: expected ${target.sha256}, found ${found}`,
272
+ );
273
+ }
274
+ }
102
275
 
103
- return binary;
104
- };
276
+ /** Runs `command`, throwing `failure` with its error output when it fails. */
277
+ function runTool(command, args, failure) {
278
+ const result = childProcess.spawnSync(command, args, {
279
+ encoding: "utf8",
280
+ stdio: ["ignore", "ignore", "pipe"],
281
+ });
282
+ if (result.error) {
283
+ throw new Error(`${failure}: cannot run ${command}: ${result.error.message}`);
284
+ }
285
+ if (result.status !== 0) {
286
+ throw new Error(`${failure}: ${result.stderr.trim()}`);
287
+ }
288
+ }
105
289
 
106
- const install = (suppressLogs) => {
107
- if (!artifactDownloadUrl || artifactDownloadUrl.length === 0) {
108
- console.warn("in demo mode, not installing binaries");
109
- return;
290
+ /** Moves `source` into place with an atomic rename, so a running binary is
291
+ * never written over. */
292
+ function installBinary(source, binary) {
293
+ const staged = path.join(INSTALL_DIR, `.${binary}.${process.pid}`);
294
+ try {
295
+ fs.copyFileSync(source, staged);
296
+ fs.chmodSync(staged, 0o755);
297
+ fs.renameSync(staged, path.join(INSTALL_DIR, binary));
298
+ } finally {
299
+ fs.rmSync(staged, { force: true });
110
300
  }
111
- const package = getPackage();
112
- const proxy = configureProxy(package.url);
301
+ }
113
302
 
114
- return package.install(proxy, suppressLogs);
115
- };
303
+ /** Runs `program` and exits as it does: with its status, or by its signal. */
304
+ function spawn(program) {
305
+ const child = childProcess.spawn(program, process.argv.slice(2), { stdio: "inherit" });
306
+ const ignore = () => {};
307
+ const forward = (signal) => child.kill(signal);
308
+ IGNORED_SIGNALS.forEach((signal) => process.on(signal, ignore));
309
+ FORWARDED_SIGNALS.forEach((signal) => process.on(signal, forward));
310
+ child.on("error", (error) => {
311
+ report(new Error(`cannot run ${program}: ${error.message}`));
312
+ });
313
+ child.on("exit", (code, signal) => {
314
+ IGNORED_SIGNALS.forEach((name) => process.removeListener(name, ignore));
315
+ FORWARDED_SIGNALS.forEach((name) => process.removeListener(name, forward));
316
+ if (signal) {
317
+ process.kill(process.pid, signal);
318
+ }
319
+ // Reached when the signal does not end this process.
320
+ process.exit(signal ? 128 + os.constants.signals[signal] : code);
321
+ });
322
+ }
116
323
 
117
- const run = (binaryName) => {
118
- const package = getPackage();
119
- const proxy = configureProxy(package.url);
324
+ function say(message) {
325
+ console.error(message);
326
+ }
120
327
 
121
- package.run(binaryName, proxy);
122
- };
328
+ function report(error) {
329
+ console.error(`error: ${error.message}`);
330
+ process.exitCode = 1;
331
+ }
123
332
 
124
- module.exports = {
125
- install,
126
- run,
127
- getPackage,
128
- };
333
+ module.exports = { install, run };
package/install.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ "use strict";
2
+ // Installs the binaries after `npm install`; see `binary.js`.
2
3
 
3
- const { install } = require("./binary");
4
- install(false);
4
+ require("./binary.js").install();