instabox 0.8.124 → 0.8.126

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/cli/SHA256SUMS CHANGED
@@ -1,6 +1,6 @@
1
- 1cd4a752fe0859d8d2b00a33c77afccec353e45bf39b913e40e174f19211c7d8 instabox-darwin-amd64
2
- 2b65c8787363c3589f56c215b622c122ade68b3a5f958477e4cbdf801b1beb16 instabox-darwin-arm64
3
- 57c8459453348d229369eb10bd1aaef4c8d0de413607b24940e89a801348a5b0 instabox-linux-amd64
4
- f684ab69d29577478bf221eea99bf488c1b24524d37d069fe9b966d349d233c9 instabox-linux-arm64
5
- 5c3f25fdebf343979e31a630566f21a3d4ff5b71b6c88af0eed2400d34bcd0d9 instabox-windows-amd64.exe
6
- a602d199556a54bb037cb46147e7e85f6fc0fc664d12acc4fa370f6e334a07e8 instabox-windows-arm64.exe
1
+ 7025a12c35ccbd7a2df302f915108ac9ca23dc98d6046dcc8ce88cd96e9cc1e7 instabox-darwin-amd64
2
+ 50fa1433e3706afd1aacde4428418d9ca5a575f1150c62f45bcb9d9516147004 instabox-darwin-arm64
3
+ 6235dc2551d30cc04b2e512f0124967fb74b095e09e3641559cc2151a869f061 instabox-linux-amd64
4
+ ada01b4e599828bdf60b3fef02c2290ea6bf496b0505266a949db909aaef83d5 instabox-linux-arm64
5
+ ac07d784fecbea8c1472bdb93734aef22c90a4007ec37a1f6d064d1f63812125 instabox-windows-amd64.exe
6
+ ee23b49ef781de9625c61bfa81dd8cb837045d267787d0c7e7e7267ec7d97954 instabox-windows-arm64.exe
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // The Go instabox CLI: find it, install it, hand it the command line.
2
- import { execFile, spawnSync } from 'node:child_process';
2
+ import { execFile, spawn } from 'node:child_process';
3
3
  import { createHash } from 'node:crypto';
4
4
  import {
5
5
  accessSync,
@@ -13,7 +13,7 @@ import {
13
13
  rmSync,
14
14
  statSync,
15
15
  } from 'node:fs';
16
- import { homedir } from 'node:os';
16
+ import { constants as osConstants, homedir } from 'node:os';
17
17
  import { dirname, join, sep } from 'node:path';
18
18
  import { fileURLToPath } from 'node:url';
19
19
  import { buildName, platformFor } from './platforms.mjs';
@@ -187,12 +187,62 @@ export function missingBundledCli({ platform = process.platform, arch = process.
187
187
  return 'this package carries no cli/ (a checkout?); from npm/: ../scripts/build-cli.sh --out ../out/cli && node scripts/bundle-cli.mjs --cli-dir ../out/cli';
188
188
  }
189
189
 
190
- // Hand the command line to the Go CLI and exit with its status.
191
- export function runCli(path, args) {
192
- const r = spawnSync(path, args, { stdio: 'inherit' });
193
- if (r.error) {
194
- console.error(`instabox: could not run ${path}: ${r.error.message}`);
190
+ // The signals that stop a wrapper in place of the CLI: `kill PID`, `timeout`, an agent stopping it,
191
+ // a closed terminal. Each is passed on, so stopping the wrapper stops the CLI too instead of leaving
192
+ // it running. On Windows a console Ctrl-C or close already reaches the CLI, which shares the console,
193
+ // and child.kill there terminates it outright, so nothing is passed on: the wrapper only stays to
194
+ // report the CLI's status.
195
+ export const FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
196
+
197
+ // Hand the command line to the Go CLI and exit with its status. The CLI shares this terminal
198
+ // (stdio inherited), so a TTY behaves as when it is run directly. A CLI ended by a signal ends the
199
+ // wrapper by the same signal (exit 128+n where that cannot be raised).
200
+ export function runCli(path, args, { platform = process.platform } = {}) {
201
+ const forward = platform !== 'win32';
202
+ const listeners = new Map();
203
+ let child;
204
+ const off = () => {
205
+ for (const [sig, fn] of listeners) process.removeListener(sig, fn);
206
+ listeners.clear();
207
+ };
208
+ const fail = (e) => {
209
+ off();
210
+ console.error(`instabox: could not run ${path}: ${e.message}`);
195
211
  process.exit(1);
212
+ };
213
+ for (const sig of FORWARDED_SIGNALS) {
214
+ const fn = () => {
215
+ if (!forward || !child || child.exitCode !== null || child.signalCode !== null) return;
216
+ try {
217
+ child.kill(sig);
218
+ } catch {
219
+ // The CLI is already gone; its exit event reports the status.
220
+ }
221
+ };
222
+ try {
223
+ process.on(sig, fn);
224
+ listeners.set(sig, fn);
225
+ } catch {
226
+ // A signal this platform cannot listen for.
227
+ }
196
228
  }
197
- process.exit(r.status ?? 1);
229
+ try {
230
+ child = spawn(path, args, { stdio: 'inherit' });
231
+ } catch (e) {
232
+ fail(e);
233
+ }
234
+ child.on('error', fail);
235
+ child.on('exit', (code, signal) => {
236
+ off();
237
+ if (code !== null) process.exit(code);
238
+ const n = (signal && osConstants.signals[signal]) || 0;
239
+ if (signal && forward) {
240
+ try {
241
+ process.kill(process.pid, signal);
242
+ } catch {
243
+ // Fall through to the status a shell reports for it.
244
+ }
245
+ }
246
+ process.exit(n ? 128 + n : 1);
247
+ });
198
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instabox",
3
- "version": "0.8.124",
3
+ "version": "0.8.126",
4
4
  "description": "A cloud box for your coding agent, the instabox CLI and its agent skills in one command: npx instabox@latest",
5
5
  "type": "module",
6
6
  "bin": {