probe-research 0.14.0 → 0.15.0

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.
Files changed (2) hide show
  1. package/bin/probe-research.js +307 -52
  2. package/package.json +2 -2
@@ -13,17 +13,23 @@
13
13
  * Resolution order, best first:
14
14
  * 1. `probe` on PATH AND new enough -> exec it (the common re-run case)
15
15
  * 2. `uv` -> uvx, no install, no state left behind
16
- * 3. `pipx` -> isolated install
17
- * 4. bootstrap uv, then uvx -> the from-zero path
16
+ * 3. bootstrap uv, then uvx -> the from-zero path: uv at the Mac app's pin,
17
+ * its installer checked by sha256 before it runs
18
18
  *
19
19
  * We deliberately do NOT fall back to bare `pip install`: on a researcher's
20
20
  * machine that usually means a conda/system environment, and silently mutating
21
21
  * it to run an installer is exactly the kind of thing that breaks a training
22
22
  * run three days later.
23
+ *
24
+ * Windows: an install is refused before any of that (`isInstallCall`), with
25
+ * one PostHog event so we hear who asked (plan R17).
23
26
  */
24
27
 
25
28
  const { spawnSync } = require("node:child_process");
29
+ const crypto = require("node:crypto");
30
+ const fs = require("node:fs");
26
31
  const os = require("node:os");
32
+ const path = require("node:path");
27
33
 
28
34
  const DIST = "probe-research";
29
35
 
@@ -85,16 +91,50 @@ const MANIFEST_TIMEOUT_MS = 1500;
85
91
  * nothing, and there is no operator watching to read it. The old floor is
86
92
  * satisfied by every one of those installs.
87
93
  *
94
+ * (1) is why it is 0.374.0: the CLI's bootstrap (`probe service start
95
+ * --min-version`, plan T10) and an install that leaves a current Probe service.
96
+ * The floor only decides when the manifest's latest cannot be read; otherwise
97
+ * the launcher asks for the latest.
98
+ *
88
99
  * PUBLISHING ORDER MATTERS. `${DIST}>=${target}` must resolve, so this package
89
- * may only be `npm publish`ed once a CLI at or above the floor is live on PyPI.
90
- * That ordering is not enforced anywhere: the PyPI release is automated and
91
- * `npm publish` is manual, so it is a human who has to get it right. Raising
92
- * the floor ahead of the release strands the from-zero entry point.
100
+ * may only be published once a CLI at or above the floor is live on PyPI. The
101
+ * Release workflow (`release.yml`) publishes it after PyPI in the same run,
102
+ * automatically; raising the floor ahead of a CLI release strands the from-zero
103
+ * entry point, so the floor only ever names a release already on PyPI.
104
+ */
105
+ const MIN_CLI = "0.374.0";
106
+ /**
107
+ * The floor where Probe's compiled CLI has no build (`getMissingBuild`): no release past
108
+ * the split installs there, so the newest that does is run as it is (plan R15, T22).
109
+ * 0.147.0 added the website's sign-in codes, which this launcher drops itself (`cliArgs`).
110
+ */
111
+ const NO_BUILD_MIN_CLI = "0.147.0";
112
+
113
+ /** The uv this launcher installs where none is found: the Mac app's pin (desktop `wizard.rs` UV_VERSION). */
114
+ const UV_VERSION = "0.13.1";
115
+ /**
116
+ * The oldest uv on PATH the launcher runs (the desktop app's UV_MIN): 0.4.20 is the first that downloads
117
+ * CPython 3.13 final (PYTHON_REQUEST). Behind it, the pinned uv is installed and run by its path.
118
+ */
119
+ const UV_MIN = "0.4.20";
120
+ const UV_INSTALLER_URL = `https://astral.sh/uv/${UV_VERSION}/install.sh`;
121
+ /**
122
+ * sha256 of that installer script. It is saved to a private file and run only when it hashes
123
+ * to this: never `curl | sh`, which runs a truncated or tampered download. The script then
124
+ * checks the uv archive's own sha256 (where `sha256sum` exists).
125
+ */
126
+ const UV_INSTALLER_SHA256 = "7c482d409673a53f4d9bd34ae95c9166be3b8d89ca82f27dd7bca3cab457afff";
127
+ const UV_INSTALL = `curl -LsSf ${UV_INSTALLER_URL} | sh`;
128
+ /** How long the uv download may take. */
129
+ const UV_DOWNLOAD_TIMEOUT_S = 120;
130
+ /** How long `probe --version` may take before the installed `probe` counts as unknown. */
131
+ const VERSION_TIMEOUT_MS = 5000;
132
+ /**
133
+ * The Python `uv tool run` runs the CLI on (the CLI's `installs.PYTHON_REQUEST`, the desktop app's too).
134
+ * Left to choose, uv takes the first Python on PATH: Homebrew's 3.15 has no tiktoken wheel, so the
135
+ * install needed Rust (T19 smoke, 2026-11-03). uv downloads this one when the machine has none.
93
136
  */
94
- // 0.147.0 adds positional website sign-in codes to wizard/install. Publish this
95
- // launcher only after that CLI release is available on PyPI.
96
- const MIN_CLI = "0.147.0";
97
- const UV_INSTALL = "curl -LsSf https://astral.sh/uv/install.sh | sh";
137
+ const PYTHON_REQUEST = "3.13";
98
138
 
99
139
  /** Compare dotted numeric versions. Returns true when `a` >= `b`. */
100
140
  function atLeast(a, b) {
@@ -108,6 +148,13 @@ function atLeast(a, b) {
108
148
  return true;
109
149
  }
110
150
 
151
+ /** The version `uv --version` answers, or null (none on PATH, no answer in time). */
152
+ function getUvVersion() {
153
+ const r = spawnSync("uv", ["--version"], { encoding: "utf8", shell: false, timeout: VERSION_TIMEOUT_MS });
154
+ const m = r.status === 0 && r.stdout ? r.stdout.match(/^uv (\d+(?:\.\d+)+)/) : null;
155
+ return m ? m[1] : null;
156
+ }
157
+
111
158
  /**
112
159
  * The version of an existing `probe`, or null if it cannot be determined.
113
160
  *
@@ -117,7 +164,7 @@ function atLeast(a, b) {
117
164
  * the wizard in it, which is precisely the bug this check exists to stop.
118
165
  */
119
166
  function installedVersion() {
120
- const r = spawnSync("probe", ["--version"], { encoding: "utf8", shell: false });
167
+ const r = spawnSync("probe", ["--version"], { encoding: "utf8", shell: false, timeout: VERSION_TIMEOUT_MS });
121
168
  if (r.status !== 0 || !r.stdout) return null;
122
169
  const m = r.stdout.match(/(\d+\.\d+\.\d+(?:\.\d+)?)/);
123
170
  return m ? m[1] : null;
@@ -156,7 +203,7 @@ function has(cmd) {
156
203
  // ONE shell string, never (command, args[], shell:true): Node deprecated that
157
204
  // pairing in DEP0190 because the args are concatenated rather than escaped,
158
205
  // and it printed a security warning on every single launcher run. `cmd` is a
159
- // literal at all three call sites, so there is nothing to escape here -- but
206
+ // literal at every call site, so there is nothing to escape here -- but
160
207
  // a warning users see on the from-zero entry point is its own problem.
161
208
  const line = process.platform === "win32" ? `where ${cmd}` : `command -v ${cmd}`;
162
209
  const r = spawnSync(line, { stdio: "ignore", shell: true });
@@ -191,46 +238,148 @@ const LauncherVerb = Object.freeze({
191
238
  });
192
239
  /** What `install` means -- exactly what `probe install` always ran (`main.py`). */
193
240
  const INSTALL_ACTION = Object.freeze(["--action", "configure"]);
194
- /** The website's one-time sign-in code; the CLI enforces the same shape. */
241
+ /** The website's retired one-time sign-in code; the CLI ignores the same shape. */
195
242
  const SIGN_IN_CODE = /^[A-Z0-9]{10}$/;
196
243
  /** The CLI root's own options: a call that starts with one names its own
197
244
  * command (`--base-url X doctor`, `--base-url=X doctor`) and reaches `probe`
198
245
  * untouched. */
199
246
  const ROOT_ONLY_FLAGS = Object.freeze(["--version", "--help", "--base-url", "--spool-dir", "--async", "--sync"]);
200
247
 
248
+ /** Where a retired sign-in code sits in what was typed (`CODE …`, `install CODE …`), or -1. */
249
+ function signInCodeAt(args) {
250
+ if (args.length && SIGN_IN_CODE.test(args[0])) return 0;
251
+ if (args[0] === LauncherVerb.INSTALL && args.length > 1 && SIGN_IN_CODE.test(args[1])) return 1;
252
+ return -1;
253
+ }
254
+
201
255
  /**
202
256
  * `probe` arguments for what was typed after `npx probe-research`.
203
257
  *
204
- * (nothing) -> wizard
205
- * CODE [flags] -> wizard CODE [flags]
206
- * install [CODE] [flags] -> wizard [CODE] --action configure [flags]
207
- * CODE install [flags] -> wizard CODE --action configure [flags]
258
+ * (nothing), CODE -> wizard
259
+ * install [CODE] [flags] -> wizard --action configure [flags]
260
+ * CODE install [flags] -> wizard --action configure [flags]
208
261
  * --flag ... -> wizard --flag ... (the CLI root's own excepted)
209
262
  * anything else -> unchanged (`doctor`, `backfill`, `wizard ...`)
210
263
  *
211
- * A sign-in code keeps its meaning either way: bare, it signs in and opens the
212
- * menu; with `install`, the one-time exchange waits for the agent selection so
213
- * it grants exactly what the user chose.
264
+ * A website sign-in code from an old copied command is dropped, never
265
+ * forwarded: no argv or `ps` listing carries it, and the browser approval
266
+ * signs in instead (install redesign R1).
214
267
  */
215
268
  function cliArgs(args) {
216
- const [first, ...rest] = args;
269
+ const at = signInCodeAt(args);
270
+ const words = at < 0 ? args : [...args.slice(0, at), ...args.slice(at + 1)];
271
+ const [first, ...rest] = words;
217
272
  if (first === undefined) return [LauncherVerb.WIZARD];
218
- if (SIGN_IN_CODE.test(first)) {
219
- if (rest[0] === LauncherVerb.INSTALL) {
220
- return [LauncherVerb.WIZARD, first, ...INSTALL_ACTION, ...rest.slice(1)];
221
- }
222
- return [LauncherVerb.WIZARD, first, ...rest];
223
- }
224
- if (first === LauncherVerb.INSTALL) {
225
- const code = rest.length && SIGN_IN_CODE.test(rest[0]) ? rest.slice(0, 1) : [];
226
- return [LauncherVerb.WIZARD, ...code, ...INSTALL_ACTION, ...rest.slice(code.length)];
227
- }
273
+ if (first === LauncherVerb.INSTALL) return [LauncherVerb.WIZARD, ...INSTALL_ACTION, ...rest];
228
274
  // Flags alone (`npx probe-research --agent codex`) used to reach the CLI's
229
275
  // root as `probe --agent codex`, which is not a command at all.
230
276
  if (first.startsWith("-") && !ROOT_ONLY_FLAGS.includes(first.split("=")[0])) {
231
- return [LauncherVerb.WIZARD, ...args];
277
+ return [LauncherVerb.WIZARD, ...words];
278
+ }
279
+ return words;
280
+ }
281
+
282
+ /** Said once when an old command passes a code; the CLI says the same words. */
283
+ const SIGN_IN_CODE_NOTE = "Sign-in codes are no longer needed; opening the browser instead.";
284
+
285
+ // --- Windows: no install (plan R17) ------------------------------------------
286
+
287
+ /** What a person on Windows reads; the CLI says the same words. */
288
+ const UNSUPPORTED_PLATFORM = "Probe runs on macOS and Linux for now.";
289
+ /** The wizard actions that install or sign in: refused on Windows, before any download. */
290
+ const INSTALL_ACTIONS = Object.freeze(["configure", "login"]);
291
+
292
+ /** Whether `probe` arguments install or sign in (`install`, `--action configure|login`). */
293
+ function isInstallCall(forwarded) {
294
+ if (forwarded[0] !== LauncherVerb.WIZARD) return false;
295
+ for (let i = 1; i < forwarded.length; i++) {
296
+ const word = forwarded[i];
297
+ if (word === "--action") return INSTALL_ACTIONS.includes(forwarded[i + 1]);
298
+ if (word.startsWith("--action=")) return INSTALL_ACTIONS.includes(word.slice("--action=".length));
299
+ }
300
+ return false;
301
+ }
302
+
303
+ /** The CLI's PostHog project and host (`analytics/core.py`; agent/tests holds the two in step). */
304
+ const POSTHOG_HOST = "https://us.i.posthog.com";
305
+ const POSTHOG_KEY = "phc_pCSs24bQtPaxoJ59PaTtTpJDS3dfzymfZeY74XQQ956K";
306
+ /** The catalog's name (contracts/probe_contracts/analytics/events.json). */
307
+ const UNSUPPORTED_EVENT = "install.unsupported_platform";
308
+ /** The event's `os` as the dashboard and the CLI send it. */
309
+ const OS_NAMES = Object.freeze({ win32: "windows" });
310
+ /** How long the refusal may wait on PostHog before it exits anyway. */
311
+ const TELEMETRY_TIMEOUT_MS = 1500;
312
+ /** `PROBE_TELEMETRY` spellings that turn telemetry off, as the CLI reads them. */
313
+ const TELEMETRY_OFF = Object.freeze(["off", "0", "false", "no", "disabled"]);
314
+
315
+ /** Whether this run may send the event: the CLI's switch, DO_NOT_TRACK, and hosted servers only. */
316
+ function maySendTelemetry(env) {
317
+ if (TELEMETRY_OFF.includes(String(env.PROBE_TELEMETRY || "").trim().toLowerCase())) return false;
318
+ if (String(env.DO_NOT_TRACK || "").trim() === "1") return false;
319
+ if (!env.PROBE_BASE_URL) return true;
320
+ // A self-hosted server's people are never reported to us (the CLI's `hosted_base_url`).
321
+ try {
322
+ const url = new URL(env.PROBE_BASE_URL);
323
+ const host = url.hostname.toLowerCase().replace(/\.$/, "");
324
+ return url.protocol === "https:" && (host === "prbe.ai" || host.endsWith(".prbe.ai"));
325
+ } catch {
326
+ return false;
327
+ }
328
+ }
329
+
330
+ /** The CLI's anonymous machine id (`analytics/core.py` `machine_id`), minted the same way when absent. */
331
+ function machineId(env) {
332
+ const home = env.XDG_STATE_HOME || path.join(os.homedir(), ".local", "state");
333
+ const file = path.join(home, "probe-telemetry", "machine_id");
334
+ try {
335
+ const found = fs.readFileSync(file, "utf8").trim();
336
+ if (found) return found;
337
+ } catch {}
338
+ const minted = crypto.randomUUID().replace(/-/g, "");
339
+ try {
340
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
341
+ fs.writeFileSync(file, minted, { flag: "wx", mode: 0o600 });
342
+ } catch {
343
+ try {
344
+ return fs.readFileSync(file, "utf8").trim() || minted; // another process minted it first
345
+ } catch {}
232
346
  }
233
- return args;
347
+ return minted;
348
+ }
349
+
350
+ /** POST one `install.unsupported_platform`, awaited and bounded; never throws. */
351
+ async function sendUnsupportedPlatform(env) {
352
+ if (!maySendTelemetry(env)) return;
353
+ try {
354
+ const machine = machineId(env);
355
+ const host = (env.PROBE_TELEMETRY_HOST || POSTHOG_HOST).replace(/\/+$/, "");
356
+ const version = require("../package.json").version;
357
+ await fetch(`${host}/batch/`, {
358
+ method: "POST",
359
+ signal: AbortSignal.timeout(TELEMETRY_TIMEOUT_MS),
360
+ headers: { "content-type": "application/json" },
361
+ body: JSON.stringify({
362
+ api_key: POSTHOG_KEY,
363
+ batch: [{
364
+ event: UNSUPPORTED_EVENT,
365
+ distinct_id: `machine:${machine}`,
366
+ timestamp: new Date().toISOString(),
367
+ properties: {
368
+ surface: "launcher",
369
+ os: OS_NAMES[process.platform] || process.platform,
370
+ arch: process.arch,
371
+ client_version: version,
372
+ client_kind: "launcher",
373
+ machine_id: machine,
374
+ authenticated: false,
375
+ $process_person_profile: false,
376
+ $lib: "probe-research-launcher",
377
+ $lib_version: version,
378
+ },
379
+ }],
380
+ }),
381
+ });
382
+ } catch {}
234
383
  }
235
384
 
236
385
  /**
@@ -256,6 +405,35 @@ function uvRunFlags(forwarded) {
256
405
  return mayUseInstalled(forwarded) ? [] : ["--isolated"];
257
406
  }
258
407
 
408
+ /**
409
+ * What this computer is, when Probe's compiled CLI (probe-research-cli) has no build for it;
410
+ * null when it has one: macOS arm64 and x86_64, Linux with glibc 2.28+ on x86_64 and aarch64 (the
411
+ * active platforms of agent/packaging/private/platforms/platforms.json; the test holds the two together).
412
+ * Anywhere else `probe-research[all]` at a newer release cannot install, so the launcher says so
413
+ * and asks for the newest release that installs here. Windows is dormant: its last build is 0.372.0.
414
+ */
415
+ function getMissingBuild(platform, arch, glibc) {
416
+ if (platform === "darwin" && (arch === "arm64" || arch === "x64")) return null;
417
+ if (platform === "win32") return `win32 ${arch}: Windows is not supported yet`;
418
+ // manylinux_2_28: glibc 2.28 or newer.
419
+ const [major, minor] = String(glibc || "0.0").split(".").map(Number);
420
+ const hasGlibc228 = major > 2 || (major === 2 && minor >= 28);
421
+ if (platform === "linux" && (arch === "x64" || arch === "arm64") && hasGlibc228) return null;
422
+ const libc = platform === "linux" ? (glibc ? `glibc ${glibc}` : "musl") : "";
423
+ return [platform, arch, libc].filter(Boolean).join(" ");
424
+ }
425
+
426
+ /** The C library's version on Linux; none on musl (node reports no glibc there). */
427
+ function readGlibc() {
428
+ try {
429
+ // No socket list: it would look up every open socket's name (slow on a slow resolver).
430
+ process.report.excludeNetwork = true;
431
+ return process.report.getReport().header.glibcVersionRuntime || null;
432
+ } catch {
433
+ return null;
434
+ }
435
+ }
436
+
259
437
  /** What a repair says when the newest release cannot be read. */
260
438
  const REPAIR_NEEDS_NETWORK = "probe repair needs the network to fetch a working CLI";
261
439
 
@@ -264,7 +442,14 @@ async function main() {
264
442
  // `npx probe-research` with no arguments runs the wizard — that is the entire
265
443
  // reason this package exists, so it should not require remembering a verb.
266
444
  const forwarded = cliArgs(args);
267
- const wanted = MIN_CLI;
445
+ // FIRST, before any `probe` or uv is looked for: an installed one would
446
+ // otherwise run the install (plan R28).
447
+ if (process.platform === "win32" && isInstallCall(forwarded)) {
448
+ console.error(UNSUPPORTED_PLATFORM);
449
+ await sendUnsupportedPlatform(process.env);
450
+ process.exit(1);
451
+ }
452
+ if (signInCodeAt(args) >= 0) console.error(SIGN_IN_CODE_NOTE);
268
453
 
269
454
  // Hand off to an existing install only when it is BOTH above the floor and
270
455
  // current. The floor alone is not enough, and that was the bug: `npx <tool>`
@@ -275,7 +460,16 @@ async function main() {
275
460
  // That is the same failure the `--refresh` flag below exists to fix -- uv
276
461
  // serving whatever it resolved on day one -- in the other branch. It was
277
462
  // fixed there and left standing here.
463
+ // No compiled CLI build for this computer: no release after the split installs here, so an
464
+ // installed probe is never "behind" one; run it as long as it is above the floor.
465
+ const missingBuild = getMissingBuild(process.platform, process.arch,
466
+ process.platform === "linux" ? readGlibc() : null);
467
+ const wanted = missingBuild ? NO_BUILD_MIN_CLI : MIN_CLI;
278
468
  let latest = null;
469
+ if (missingBuild && mayUseInstalled(forwarded) && has("probe")) {
470
+ const found = installedVersion();
471
+ if (found && atLeast(found, wanted)) return run("probe", forwarded);
472
+ }
279
473
  if (!mayUseInstalled(forwarded)) {
280
474
  // A repair runs the NEWEST release, never the floor: the floor predates
281
475
  // `probe repair`, and would hand the job to a CLI that cannot do it.
@@ -312,7 +506,15 @@ async function main() {
312
506
  const target = latest && atLeast(latest, wanted) ? latest : wanted;
313
507
  // `[all]`: the CLI's dependencies are an extra from the release after
314
508
  // 0.188 (plan 2.11); asking for it is harmless while core still has them.
315
- const spec = `${DIST}[all]>=${target}`;
509
+ // It is also what brings the compiled CLI (probe-research-cli) since the split.
510
+ if (missingBuild) {
511
+ console.error(
512
+ `probe-research: Probe's CLI has no build for this computer (${missingBuild}); installing ` +
513
+ "the newest release that runs here, which will not update itself. The Python SDK alone " +
514
+ "(the probe-research package without [all]) installs at every version.",
515
+ );
516
+ }
517
+ const spec = missingBuild ? `${DIST}[all]` : `${DIST}[all]>=${target}`;
316
518
  // REFRESH. uv caches the ENVIRONMENT it built for a requirement, so a range
317
519
  // like `>=0.10.0` keeps serving whatever it resolved the FIRST time — every
318
520
  // user frozen on the version they happened to run on day one, with the
@@ -323,38 +525,91 @@ async function main() {
323
525
  // kept returning 0.10.0 after 0.10.1 was published). The full refresh costs
324
526
  // ~100ms, which is nothing for a command that only runs when there is no
325
527
  // usable local install.
528
+ // No pipx: the CLI installs itself for good with uv only, so a pipx run ended
529
+ // in that refusal anyway (install redesign R11).
326
530
  const isolated = uvRunFlags(forwarded);
327
- if (has("uv")) {
328
- return run("uv", ["tool", "run", ...isolated, "--refresh", "--from", spec, "probe", ...forwarded]);
329
- }
330
- if (has("pipx")) {
331
- return run("pipx", ["run", "--no-cache", "--spec", spec, "probe", ...forwarded]);
531
+ const uvOnPath = has("uv");
532
+ const uvVersion = uvOnPath ? getUvVersion() : null;
533
+ if (uvVersion && atLeast(uvVersion, UV_MIN)) {
534
+ return run("uv", ["tool", "run", ...isolated, "--python", PYTHON_REQUEST, "--refresh", "--from", spec, "probe",
535
+ ...forwarded]);
332
536
  }
333
537
 
334
538
  if (process.platform === "win32") {
335
539
  console.error(
336
- `probe-research: needs uv or pipx on PATH.\n` +
540
+ `probe-research: needs uv ${UV_MIN} or newer on PATH.\n` +
337
541
  ` Install uv: https://docs.astral.sh/uv/getting-started/installation/`,
338
542
  );
339
543
  process.exit(1);
340
544
  }
341
545
 
342
- console.error("probe-research: installing uv (one-time)…");
343
- const boot = spawnSync("sh", ["-c", UV_INSTALL], { stdio: "inherit" });
344
- if (boot.status !== 0) {
345
- console.error(
346
- `probe-research: could not install uv automatically.\n Run: ${UV_INSTALL}`,
347
- );
348
- process.exit(1);
546
+ if (uvOnPath) {
547
+ console.error(`probe-research: ${uvVersion ? `uv ${uvVersion} is older than ${UV_MIN}` : "uv on PATH did not say its version"}.`);
349
548
  }
350
- // The installer drops uv in ~/.local/bin, which is not on THIS process's PATH
351
- // because it was resolved before the install ran.
352
- const uv = `${os.homedir()}/.local/bin/uv`;
549
+ const uv = installUv(process.env, forwarded);
353
550
  return run(uv, [
354
- "tool", "run", ...isolated, "--refresh", "--from", spec, "probe", ...forwarded,
551
+ "tool", "run", ...isolated, "--python", PYTHON_REQUEST, "--refresh", "--from", spec, "probe", ...forwarded,
355
552
  ]);
356
553
  }
357
554
 
555
+ /** The hex sha256 of a file's bytes. */
556
+ function hashFile(file) {
557
+ return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
558
+ }
559
+
560
+ /**
561
+ * Where uv's installer puts uv, in its own order (UV_INSTALL_DIR, XDG_BIN_HOME,
562
+ * XDG_DATA_HOME/../bin, ~/.local/bin): none of them is on THIS process's PATH,
563
+ * which was read before the install ran.
564
+ */
565
+ function getInstalledUvPath(env) {
566
+ const folders = [env.UV_INSTALL_DIR, env.XDG_BIN_HOME,
567
+ env.XDG_DATA_HOME ? path.join(env.XDG_DATA_HOME, "..", "bin") : null,
568
+ path.join(os.homedir(), ".local", "bin")];
569
+ for (const folder of folders.filter(Boolean)) {
570
+ const candidate = path.join(folder, "uv");
571
+ try {
572
+ fs.accessSync(candidate, fs.constants.X_OK);
573
+ return candidate;
574
+ } catch {}
575
+ }
576
+ return null;
577
+ }
578
+
579
+ /**
580
+ * Install uv UV_VERSION: its installer downloaded into a private folder, run with `sh` only
581
+ * when it hashes to UV_INSTALLER_SHA256, the folder removed after. The uv it installed, or
582
+ * exit 1 with the command to run by hand. With `--json` in `forwarded`, stdout carries only
583
+ * the CLI's events, so the installer's own text goes to stderr.
584
+ */
585
+ function installUv(env, forwarded = []) {
586
+ console.error(`probe-research: installing uv ${UV_VERSION} (one-time)…`);
587
+ const folder = fs.mkdtempSync(path.join(os.tmpdir(), "probe-uv-"));
588
+ const script = path.join(folder, "install.sh");
589
+ let failure = null;
590
+ try {
591
+ const fetched = spawnSync("curl", ["-fsSL", "--max-time", String(UV_DOWNLOAD_TIMEOUT_S), "-o", script,
592
+ UV_INSTALLER_URL], { stdio: ["ignore", "inherit", "inherit"] });
593
+ if (fetched.status !== 0) {
594
+ failure = `could not download the uv installer (${fetched.error ? fetched.error.message : `curl exit ${fetched.status}`})`;
595
+ } else if (hashFile(script) !== UV_INSTALLER_SHA256) {
596
+ failure = "the downloaded uv installer is not the one this launcher pins (sha256 mismatch); it was not run";
597
+ } else {
598
+ const ran = spawnSync("sh", [script], { stdio: ["inherit", forwarded.includes("--json") ? 2 : "inherit", "inherit"] });
599
+ if (ran.status !== 0) failure = `the uv installer failed (exit ${ran.status === null ? "signal" : ran.status})`;
600
+ }
601
+ } finally {
602
+ fs.rmSync(folder, { recursive: true, force: true });
603
+ }
604
+ const uv = failure ? null : getInstalledUvPath(env);
605
+ if (!uv) {
606
+ console.error(`probe-research: ${failure || "the uv installer finished, but no uv is where it installs"}.\n` +
607
+ ` Run: ${UV_INSTALL}`);
608
+ process.exit(1);
609
+ }
610
+ return uv;
611
+ }
612
+
358
613
  main().catch((err) => {
359
614
  // A throw here would exit 0 under an unhandled rejection on some Node builds,
360
615
  // which reads as success to whatever invoked the launcher.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "probe-research",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Setup wizard for Probe Research in your coding agents. Runs from zero with npx.",
5
5
  "bin": {
6
6
  "probe-research": "bin/probe-research.js"
@@ -14,7 +14,7 @@
14
14
  "license": "Apache-2.0",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/prbe-ai/research-os-agent.git"
17
+ "url": "git+https://github.com/prbe-ai/research-os.git"
18
18
  },
19
19
  "homepage": "https://research.prbe.ai/connect",
20
20
  "keywords": [