@reservoirai/rsvr-provider 0.1.1 → 0.1.2

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.
@@ -75,6 +75,21 @@ function findBinary(platform, arch, resolve) {
75
75
  return binaryPath(packageJson, platform);
76
76
  }
77
77
 
78
+ /**
79
+ * Whether the launcher sends `signal` on to the program. SIGINT is NOT sent on
80
+ * Windows, nor where stdin is a terminal: there Ctrl-C reaches the program
81
+ * itself (every process on a Windows console, the whole foreground group
82
+ * elsewhere), and a second SIGINT reads to `run` as "Ctrl-C again: stop now"
83
+ * and ends it at once with 130 where one drains and exits 0 (GUIDE.md §8.5).
84
+ * On Windows Node's kill() is also TerminateProcess, which ends the program
85
+ * with exit code 1. With no terminal (a harness signalling the launcher alone)
86
+ * SIGINT goes on, as every other signal does.
87
+ */
88
+ function forwards(signal, platform, interactive) {
89
+ if (signal === 'SIGINT') return !(interactive || platform === 'win32');
90
+ return true;
91
+ }
92
+
78
93
  function launch() {
79
94
  const platform = process.platform;
80
95
  const bin = findBinary(platform, process.arch, require.resolve);
@@ -99,15 +114,13 @@ function launch() {
99
114
 
100
115
  const child = childProcess.spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
101
116
 
102
- // Signals go on to the program. On a terminal, Ctrl-C already reached the
103
- // program with the launcher (one process group), and a second SIGINT would
104
- // read to `run` as "Ctrl-C again: stop now" (GUIDE.md §8.5), so on a
105
- // terminal the launcher stays alive for SIGINT and sends nothing.
117
+ // Signals go on to the program as `forwards` says, and the launcher returns
118
+ // the program's own exit code.
106
119
  const interactive = tty.isatty(0);
107
120
  const handlers = {};
108
121
  for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
109
122
  handlers[signal] = () => {
110
- if (signal === 'SIGINT' && interactive) return;
123
+ if (!forwards(signal, platform, interactive)) return;
111
124
  try {
112
125
  child.kill(signal);
113
126
  } catch (_) {
@@ -140,6 +153,6 @@ function launch() {
140
153
  });
141
154
  }
142
155
 
143
- module.exports = { SUPPORTED, packageFor, binaryPath, missingMessage, findBinary };
156
+ module.exports = { forwards, SUPPORTED, packageFor, binaryPath, missingMessage, findBinary };
144
157
 
145
158
  if (require.main === module) launch();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reservoirai/rsvr-provider",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "The reservoir provider command line: sign in, find your model server, and serve work for reservoir.",
5
5
  "homepage": "https://reservoirai.ai",
6
6
  "license": "UNLICENSED",
@@ -18,10 +18,10 @@
18
18
  "access": "public"
19
19
  },
20
20
  "optionalDependencies": {
21
- "@reservoirai/rsvr-provider-linux-x64": "0.1.1",
22
- "@reservoirai/rsvr-provider-linux-arm64": "0.1.1",
23
- "@reservoirai/rsvr-provider-darwin-arm64": "0.1.1",
24
- "@reservoirai/rsvr-provider-darwin-x64": "0.1.1",
25
- "@reservoirai/rsvr-provider-win32-x64": "0.1.1"
21
+ "@reservoirai/rsvr-provider-linux-x64": "0.1.2",
22
+ "@reservoirai/rsvr-provider-linux-arm64": "0.1.2",
23
+ "@reservoirai/rsvr-provider-darwin-arm64": "0.1.2",
24
+ "@reservoirai/rsvr-provider-darwin-x64": "0.1.2",
25
+ "@reservoirai/rsvr-provider-win32-x64": "0.1.2"
26
26
  }
27
27
  }