instabox 0.8.229 → 0.8.230

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
- 290ad63ea839cdb5c8e1bae2be6b35953f0b670a82eb62bf3bf935abaa1d4238 instabox-darwin-amd64
2
- ac9beec997491771553420371423ef4af8176d49a8ede0b58b70bd830e0c1e91 instabox-darwin-arm64
3
- fe7b6fdf70b0938eca4e24f3c0d6d350523e52c77bed1ce7acf49ac66b245e5a instabox-linux-amd64
4
- 062f09e5135969b39c6270c2cb5c56bce8927e3d28ebfa5a0183f2f376157dd8 instabox-linux-arm64
5
- 126fd63520841b0d4bba9670649edd19529e040573ede047c613ffdf008873f0 instabox-windows-amd64.exe
6
- fab7d32ebc6bd7cfaaee0fbe2a33f8b7c96aba1363118003d4d8391b819d3380 instabox-windows-arm64.exe
1
+ 12e39f7c22b901a8e4f30af4b5d03275e8cb508f25397eafc89d1596e60a649b instabox-darwin-amd64
2
+ a9bf612353f7eaccb4085c4596187d8201d122aa1a3943b5bedf69219fce2901 instabox-darwin-arm64
3
+ a75a2c2b3eb17bb94413fafce1469b3d00d18744073363fccb4c68e2ddefff94 instabox-linux-amd64
4
+ ddb742f2e1448746a6eada4dc19e6fb2a55159dec16b62bc8f4032cd732bf5d0 instabox-linux-arm64
5
+ eb6c29814928df1e48616552d7349bb713565024f551eb14342bfce26d779665 instabox-windows-amd64.exe
6
+ 532bdcec6d657b239d60d9a4e43455d9926e8e8e512392eaa09fb95651df19df instabox-windows-arm64.exe
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/cli.mjs CHANGED
@@ -109,7 +109,7 @@ export function pathHint(dir, { env = process.env, platform = process.platform }
109
109
  // never throws, and never needs the network.
110
110
  export async function installBundled(
111
111
  src,
112
- { dir, path: dest, env = process.env, platform = process.platform, version = cliVersion } = {},
112
+ { dir, path: dest, env = process.env, platform = process.platform, version = cliVersionCheck } = {},
113
113
  ) {
114
114
  const win = platform === 'win32';
115
115
  const to = dest ? dirname(dest) : dir || installDir({ env, platform });
@@ -118,10 +118,16 @@ export async function installBundled(
118
118
  mkdirSync(to, { recursive: true });
119
119
  copyFileSync(src, tmp);
120
120
  chmodSync(tmp, 0o755);
121
- const v = await version(tmp);
121
+ // version gives {version} or {why} (cliVersionCheck), or a string or null.
122
+ const r = await version(tmp);
123
+ const v = typeof r === 'string' ? r : r?.version;
122
124
  if (!v) {
123
125
  tryRm(tmp);
124
- return { error: 'the bundled instabox does not run (instabox --version failed)' };
126
+ if (r?.timedOut)
127
+ return {
128
+ error: `the bundled instabox did not answer instabox --version within ${selfCheckTimeoutMs / 1000}s, which antivirus software checking a new file can cause; run this again`,
129
+ };
130
+ return { error: `the bundled instabox does not run (instabox --version${r?.why ? `: ${r.why}` : ' failed'})` };
125
131
  }
126
132
  const path = dest || join(to, win ? 'instabox.exe' : 'instabox');
127
133
  renameSync(tmp, path);
@@ -155,18 +161,44 @@ export function findCli({ env = process.env, self = process.argv[1], platform =
155
161
 
156
162
  // What `instabox --version` prints after "instabox ", or null when it does not run. Async, so a
157
163
  // slow or hung binary does not hold up the rest of onboarding.
158
- export function cliVersion(path) {
164
+ export async function cliVersion(path) {
165
+ return (await cliVersionCheck(path, { timeout: 10_000 })).version ?? null;
166
+ }
167
+
168
+ // The limit on a new copy's --version check. Antivirus software can hold a new, unsigned file on
169
+ // its first run while it checks it (Windows Defender's cloud check waits up to 60 s).
170
+ export const selfCheckTimeoutMs = 90_000;
171
+
172
+ // `instabox --version` as {version}, or {why} it gave none (SUP2-1833: "does not run" alone left
173
+ // nothing to go on): {timedOut} past the limit, the spawn error's code (EBUSY, EPERM, ...), the
174
+ // exit code and first stderr line, or what it printed.
175
+ export function cliVersionCheck(path, { timeout = selfCheckTimeoutMs } = {}) {
159
176
  return new Promise((resolve) => {
160
- execFile(path, ['--version'], { encoding: 'utf8', timeout: 10_000 }, (err, stdout) => {
161
- if (err) return resolve(null);
177
+ execFile(path, ['--version'], { encoding: 'utf8', timeout }, (err, stdout, stderr) => {
162
178
  const m = String(stdout)
163
179
  .trim()
164
180
  .match(/^instabox (\S+)$/);
165
- resolve(m ? m[1] : null);
181
+ if (!err && m) return resolve({ version: m[1] });
182
+ if (err?.killed) return resolve({ timedOut: true, why: `no answer within ${timeout / 1000}s` });
183
+ if (typeof err?.code === 'string') return resolve({ why: err.code });
184
+ if (err) {
185
+ const line = firstLine(stderr);
186
+ return resolve({ why: `exit code ${err.code ?? err.signal}${line ? `: ${line}` : ''}` });
187
+ }
188
+ resolve({ why: `it printed ${JSON.stringify(firstLine(stdout))}` });
166
189
  });
167
190
  });
168
191
  }
169
192
 
193
+ // s's first non-blank line, at most 160 characters.
194
+ function firstLine(s) {
195
+ const line = String(s ?? '')
196
+ .split('\n')
197
+ .map((l) => l.trim())
198
+ .find(Boolean);
199
+ return !line ? '' : line.length > 160 ? `${line.slice(0, 157)}...` : line;
200
+ }
201
+
170
202
  // The file's sha256, streamed: the CLI is tens of MB and this runs while the box starts.
171
203
  export function sha256File(path) {
172
204
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instabox",
3
- "version": "0.8.229",
3
+ "version": "0.8.230",
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": {