probe-research 0.16.0 → 0.18.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.
- package/bin/probe-research.js +267 -11
- package/lib/agent-run.js +110 -0
- package/lib/background-download.js +167 -0
- package/lib/device-identity.js +175 -0
- package/lib/sign-in.js +242 -0
- package/package.json +4 -3
package/bin/probe-research.js
CHANGED
|
@@ -31,6 +31,10 @@ const fs = require("node:fs");
|
|
|
31
31
|
const os = require("node:os");
|
|
32
32
|
const path = require("node:path");
|
|
33
33
|
|
|
34
|
+
const agentRun = require("../lib/agent-run");
|
|
35
|
+
const download = require("../lib/background-download");
|
|
36
|
+
const signIn = require("../lib/sign-in");
|
|
37
|
+
|
|
34
38
|
const DIST = "probe-research";
|
|
35
39
|
/** The compiled CLI `probe-research[all]` pins to its own version since the split (the CLI's `_entry.CLI_DIST`). */
|
|
36
40
|
const CLI_DIST = "probe-research-cli";
|
|
@@ -113,6 +117,20 @@ const MIN_CLI = "0.374.0";
|
|
|
113
117
|
* instead, downloaded once. Same rule as MIN_CLI: only ever a release already on PyPI.
|
|
114
118
|
*/
|
|
115
119
|
const FIX_MIN = "0.385.0";
|
|
120
|
+
/**
|
|
121
|
+
* The first CLI with the install prompt's half (plan D36): `sign-in --wait` (`wizard --action login
|
|
122
|
+
* --pending`), `install --attempt` / `--recommended` / `--session-default`, and status's `setup`
|
|
123
|
+
* block. An installed `probe` below it runs none of the agent's calls: the newest release does
|
|
124
|
+
* (downloaded once), as below FIX_MIN. Same rule as the floors above: a release already on PyPI
|
|
125
|
+
* when this launcher publishes (release.yml publishes the launcher after PyPI, in the same run).
|
|
126
|
+
* 0.418.0, not 0.417.0: 0.417.0 was cut from a commit before the agent install merged (#4350).
|
|
127
|
+
* 0.421.0 since PR4: the live example's `probe example` (which `needsAgentCli` routes here) came
|
|
128
|
+
* after 0.420.0 was cut, and one floor keeps every call of the install prompt on one release.
|
|
129
|
+
*/
|
|
130
|
+
const AGENT_MIN_CLI = "0.421.0";
|
|
131
|
+
/** `install` flags only AGENT_MIN_CLI knows (D36). */
|
|
132
|
+
const AGENT_INSTALL_FLAGS = Object.freeze(["--recommended", "--who-records", "--session-default", "--profile",
|
|
133
|
+
"--attempt"]);
|
|
116
134
|
/**
|
|
117
135
|
* The floor where Probe's compiled CLI has no build (`getMissingBuild`): no release past
|
|
118
136
|
* the split installs there, so the newest that does is run as it is (plan R15, T22).
|
|
@@ -173,13 +191,33 @@ function getUvVersion() {
|
|
|
173
191
|
* whatever ancient build happens to be on PATH gives them a CLI with none of
|
|
174
192
|
* the wizard in it, which is precisely the bug this check exists to stop.
|
|
175
193
|
*/
|
|
176
|
-
function installedVersion() {
|
|
177
|
-
const r = spawnSync(
|
|
194
|
+
function installedVersion(command = "probe") {
|
|
195
|
+
const r = spawnSync(command, ["--version"], { encoding: "utf8", shell: false, timeout: VERSION_TIMEOUT_MS });
|
|
178
196
|
if (r.status !== 0 || !r.stdout) return null;
|
|
179
197
|
const m = r.stdout.match(/(\d+\.\d+\.\d+(?:\.\d+)?)/);
|
|
180
198
|
return m ? m[1] : null;
|
|
181
199
|
}
|
|
182
200
|
|
|
201
|
+
/**
|
|
202
|
+
* An installed `probe` at or above `min`: the one on PATH, else the one uv's tool install put in
|
|
203
|
+
* its bin folder (a first download's, before the agent's shell PATH knows that folder); null.
|
|
204
|
+
*/
|
|
205
|
+
function findProbe(min) {
|
|
206
|
+
const candidates = [has("probe") ? "probe" : null, ...getUvBinFolders(process.env).map((d) => path.join(d, "probe"))];
|
|
207
|
+
for (const candidate of candidates.filter(Boolean)) {
|
|
208
|
+
if (candidate !== "probe") {
|
|
209
|
+
try {
|
|
210
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
211
|
+
} catch {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const found = installedVersion(candidate);
|
|
216
|
+
if (found && atLeast(found, min)) return candidate;
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
183
221
|
function baseUrl() {
|
|
184
222
|
const env = process.env.PROBE_BASE_URL;
|
|
185
223
|
if (env && /^https?:\/\//.test(env)) return env.replace(/\/+$/, "");
|
|
@@ -245,7 +283,11 @@ const LauncherVerb = Object.freeze({
|
|
|
245
283
|
WIZARD: "wizard",
|
|
246
284
|
/** Launcher-only: "straight into the guided install", skipping the menu. */
|
|
247
285
|
INSTALL: "install",
|
|
286
|
+
/** Launcher-only: the install prompt's sign-in (`runSignIn`), before any CLI exists. */
|
|
287
|
+
SIGN_IN: "sign-in",
|
|
248
288
|
});
|
|
289
|
+
/** What `sign-in` takes (the hosted install.md names them; its test reads this list). */
|
|
290
|
+
const SIGN_IN_FLAGS = Object.freeze(["--json", "--wait", "--no-browser"]);
|
|
249
291
|
/** What `install` means -- exactly what `probe install` always ran (`main.py`). */
|
|
250
292
|
const INSTALL_ACTION = Object.freeze(["--action", "configure"]);
|
|
251
293
|
/** The website's retired one-time sign-in code; the CLI ignores the same shape. */
|
|
@@ -359,6 +401,14 @@ function machineId(env) {
|
|
|
359
401
|
|
|
360
402
|
/** POST one `install.unsupported_platform`, awaited and bounded; never throws. */
|
|
361
403
|
async function sendUnsupportedPlatform(env) {
|
|
404
|
+
await sendLauncherEvent(env, UNSUPPORTED_EVENT);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** The install prompt's first funnel step (plan D14), sent by the launcher before any CLI exists. */
|
|
408
|
+
const SIGN_IN_STARTED_EVENT = "agent_install.signin_started";
|
|
409
|
+
|
|
410
|
+
/** POST one anonymous launcher event, awaited and bounded (TELEMETRY_TIMEOUT_MS); never throws. */
|
|
411
|
+
async function sendLauncherEvent(env, event) {
|
|
362
412
|
if (!maySendTelemetry(env)) return;
|
|
363
413
|
try {
|
|
364
414
|
const machine = machineId(env);
|
|
@@ -371,7 +421,7 @@ async function sendUnsupportedPlatform(env) {
|
|
|
371
421
|
body: JSON.stringify({
|
|
372
422
|
api_key: POSTHOG_KEY,
|
|
373
423
|
batch: [{
|
|
374
|
-
event
|
|
424
|
+
event,
|
|
375
425
|
distinct_id: `machine:${machine}`,
|
|
376
426
|
timestamp: new Date().toISOString(),
|
|
377
427
|
properties: {
|
|
@@ -448,7 +498,10 @@ function readGlibc() {
|
|
|
448
498
|
const REPAIR_NEEDS_NETWORK = "probe repair needs the network to fetch a working CLI";
|
|
449
499
|
|
|
450
500
|
async function main() {
|
|
501
|
+
const startedMs = Date.now();
|
|
451
502
|
const args = process.argv.slice(2);
|
|
503
|
+
if (args[0] === download.DOWNLOAD_VERB) return runBackgroundDownload();
|
|
504
|
+
if (args[0] === LauncherVerb.SIGN_IN) return runSignIn(args.slice(1), startedMs);
|
|
452
505
|
// `npx probe-research` with no arguments runs the wizard — that is the entire
|
|
453
506
|
// reason this package exists, so it should not require remembering a verb.
|
|
454
507
|
const forwarded = cliArgs(args);
|
|
@@ -460,6 +513,21 @@ async function main() {
|
|
|
460
513
|
process.exit(1);
|
|
461
514
|
}
|
|
462
515
|
if (signInCodeAt(args) >= 0) console.error(SIGN_IN_CODE_NOTE);
|
|
516
|
+
if (isStatusJson(forwarded) && !has("probe") && !findProbe("0")) {
|
|
517
|
+
// No Probe here: the install prompt's first read (step 1b) answers at once, with no download (D37).
|
|
518
|
+
agentRun.answer({ v: 1, setup: NONE_SETUP }, 0);
|
|
519
|
+
}
|
|
520
|
+
const agentCli = needsAgentCli(forwarded);
|
|
521
|
+
// An agent's call with --json: inside its 110 s, its process group stopped at the deadline (D67).
|
|
522
|
+
const launch = isAgentCall(forwarded)
|
|
523
|
+
? (cmd, cmdArgs) => runAgentCall(cmd, cmdArgs, startedMs) : run;
|
|
524
|
+
if (agentCli) {
|
|
525
|
+
// The first download is still installing the CLI: wait for it within the budget (D41).
|
|
526
|
+
if (isAgentCall(forwarded)) await waitForRunningDownload(startedMs);
|
|
527
|
+
const installed = findProbe(AGENT_MIN_CLI);
|
|
528
|
+
if (installed) return launch(installed, forwarded);
|
|
529
|
+
}
|
|
530
|
+
const fixMin = agentCli ? AGENT_MIN_CLI : FIX_MIN;
|
|
463
531
|
|
|
464
532
|
// Hand off to an installed CLI at or above FIX_MIN at once, with no manifest
|
|
465
533
|
// read before the wizard: such a CLI keeps itself current (its updater), so a
|
|
@@ -473,7 +541,7 @@ async function main() {
|
|
|
473
541
|
let latest = null;
|
|
474
542
|
if (missingBuild && mayUseInstalled(forwarded) && has("probe")) {
|
|
475
543
|
const found = installedVersion();
|
|
476
|
-
if (found && atLeast(found, wanted)) return
|
|
544
|
+
if (found && atLeast(found, agentCli ? AGENT_MIN_CLI : wanted)) return launch("probe", forwarded);
|
|
477
545
|
}
|
|
478
546
|
if (!mayUseInstalled(forwarded)) {
|
|
479
547
|
// A repair runs the NEWEST release, never the floor: the floor predates
|
|
@@ -486,13 +554,13 @@ async function main() {
|
|
|
486
554
|
} else if (has("probe")) {
|
|
487
555
|
const found = installedVersion();
|
|
488
556
|
// A fixed CLI runs at once (plan S8): no manifest read on the way to the browser.
|
|
489
|
-
if (found && atLeast(found,
|
|
557
|
+
if (found && atLeast(found, fixMin)) return launch("probe", forwarded);
|
|
490
558
|
latest = await latestVersion();
|
|
491
559
|
// Unknown latest (offline, no route) means run what we have: see latestVersion's contract.
|
|
492
|
-
if (!latest && found && atLeast(found, wanted)) return
|
|
560
|
+
if (!latest && !agentCli && found && atLeast(found, wanted)) return launch("probe", forwarded);
|
|
493
561
|
console.error(
|
|
494
562
|
`probe-research: installed probe ${found || "(unknown version)"} is older than ` +
|
|
495
|
-
`${
|
|
563
|
+
`${fixMin}; fetching ${latest || "the latest"}…`,
|
|
496
564
|
);
|
|
497
565
|
} else {
|
|
498
566
|
latest = await latestVersion();
|
|
@@ -501,7 +569,7 @@ async function main() {
|
|
|
501
569
|
// uv reuses the env it built for that version, so it is downloaded once, ever. A range let uv hand back
|
|
502
570
|
// the stale tool it already had (a 0.46.0 satisfied `>=0.36.0`: measured). Unknown latest (offline, no
|
|
503
571
|
// route): any fixed CLI uv already has, `>=FIX_MIN`. A repair still asks for the newest, `>=`.
|
|
504
|
-
const pinned = !missingBuild && latest && atLeast(latest,
|
|
572
|
+
const pinned = !missingBuild && latest && atLeast(latest, fixMin) ? latest : null;
|
|
505
573
|
const target = latest && atLeast(latest, wanted) ? latest : wanted;
|
|
506
574
|
// `[all]`: the CLI's dependencies are an extra from the release after
|
|
507
575
|
// 0.188 (plan 2.11); asking for it is harmless while core still has them.
|
|
@@ -515,7 +583,7 @@ async function main() {
|
|
|
515
583
|
}
|
|
516
584
|
const spec = missingBuild ? `${DIST}[all]`
|
|
517
585
|
: !mayUseInstalled(forwarded) ? `${DIST}[all]>=${target}`
|
|
518
|
-
: pinned ? `${DIST}[all]==${pinned}` : `${DIST}[all]>=${
|
|
586
|
+
: pinned ? `${DIST}[all]==${pinned}` : `${DIST}[all]>=${fixMin}`;
|
|
519
587
|
// No pipx: the CLI installs itself for good with uv only, so a pipx run ended
|
|
520
588
|
// in that refusal anyway (install redesign R11). Cache flags: getRefreshFlags.
|
|
521
589
|
const isolated = uvRunFlags(forwarded);
|
|
@@ -523,7 +591,7 @@ async function main() {
|
|
|
523
591
|
const uvOnPath = has("uv");
|
|
524
592
|
const uvVersion = uvOnPath ? getUvVersion() : null;
|
|
525
593
|
if (uvVersion && atLeast(uvVersion, UV_MIN)) {
|
|
526
|
-
return
|
|
594
|
+
return launch("uv", ["tool", "run", ...isolated, "--python", PYTHON_REQUEST, ...refresh, "--from", spec, "probe",
|
|
527
595
|
...forwarded]);
|
|
528
596
|
}
|
|
529
597
|
|
|
@@ -539,11 +607,192 @@ async function main() {
|
|
|
539
607
|
console.error(`probe-research: ${uvVersion ? `uv ${uvVersion} is older than ${UV_MIN}` : "uv on PATH did not say its version"}.`);
|
|
540
608
|
}
|
|
541
609
|
const uv = installUv(process.env, forwarded);
|
|
542
|
-
return
|
|
610
|
+
return launch(uv, [
|
|
543
611
|
"tool", "run", ...isolated, "--python", PYTHON_REQUEST, ...refresh, "--from", spec, "probe", ...forwarded,
|
|
544
612
|
]);
|
|
545
613
|
}
|
|
546
614
|
|
|
615
|
+
// --- the install prompt: `sign-in`, the background download, the agent's calls (plan D1, D3, D36) ---
|
|
616
|
+
|
|
617
|
+
/** What the agent runs after `sign-in`. */
|
|
618
|
+
const SIGN_IN_WAIT = "npx -y probe-research sign-in --wait --json";
|
|
619
|
+
/** `status --json` on a machine with no Probe (D37): what a CLI's `setup` block says there. */
|
|
620
|
+
const NONE_SETUP = Object.freeze({
|
|
621
|
+
state: "none", why: [], profile: null, account: null, team: null, this_chat: null,
|
|
622
|
+
});
|
|
623
|
+
/** Kept back from the budget for the CLI's own work once the download is in. */
|
|
624
|
+
const WAIT_RESERVE_MS = 20 * 1000;
|
|
625
|
+
/** How often a running download is looked at again. */
|
|
626
|
+
const DOWNLOAD_POLL_MS = 1000;
|
|
627
|
+
/** The uninstall barrier (`probe.shared.updates.uninstall_barrier.path`). */
|
|
628
|
+
const BARRIER_FILE = [".local", "state", "probe", "uninstall", "barrier.json"];
|
|
629
|
+
|
|
630
|
+
/** `probe` arguments only AGENT_MIN_CLI runs (D36). */
|
|
631
|
+
function needsAgentCli(forwarded) {
|
|
632
|
+
if (forwarded[0] === "example") return true;
|
|
633
|
+
if (forwarded[0] !== LauncherVerb.WIZARD) return false;
|
|
634
|
+
return forwarded.includes("--pending")
|
|
635
|
+
|| forwarded.some((word) => AGENT_INSTALL_FLAGS.includes(word.split("=")[0]));
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** An agent's call: one of those, answered as JSON, so it runs under the 110 s backstop. */
|
|
639
|
+
function isAgentCall(forwarded) {
|
|
640
|
+
return needsAgentCli(forwarded) && forwarded.includes("--json");
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function isStatusJson(forwarded) {
|
|
644
|
+
return forwarded[0] === "status" && forwarded.includes("--json");
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function hasBarrier() {
|
|
648
|
+
return fs.existsSync(path.join(os.homedir(), ...BARRIER_FILE));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function sleep(ms) {
|
|
652
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** Run an agent's call under the backstop; a call it had to stop answers `run_again` (75). */
|
|
656
|
+
async function runAgentCall(cmd, cmdArgs, startedMs) {
|
|
657
|
+
const ran = await agentRun.runWithBackstop(cmd, cmdArgs, { deadlineMs: startedMs + agentRun.AGENT_BUDGET_MS });
|
|
658
|
+
if (ran.stopped) {
|
|
659
|
+
agentRun.refuse(agentRun.Reason.RUN_AGAIN, "Stopped at the agent's time limit: run the same command again.",
|
|
660
|
+
agentRun.EXIT_AGAIN);
|
|
661
|
+
}
|
|
662
|
+
if (ran.error) agentRun.refuse(agentRun.Reason.INCOMPLETE, `could not run ${cmd}: ${ran.error}`, 1);
|
|
663
|
+
process.exit(ran.code);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** The newest release's `probe` arguments for uv, pinned when the manifest names it. */
|
|
667
|
+
async function getLatestSpec() {
|
|
668
|
+
const latest = await latestVersion();
|
|
669
|
+
const missingBuild = getMissingBuild(process.platform, process.arch,
|
|
670
|
+
process.platform === "linux" ? readGlibc() : null);
|
|
671
|
+
const pinned = !missingBuild && latest && atLeast(latest, AGENT_MIN_CLI) ? latest : null;
|
|
672
|
+
return { pinned, spec: pinned ? `${DIST}[all]==${pinned}` : `${DIST}[all]>=${AGENT_MIN_CLI}`, missingBuild };
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/** A uv this launcher runs: the one on PATH when it is new enough, else the pinned one installed. */
|
|
676
|
+
function getUv() {
|
|
677
|
+
const version = has("uv") ? getUvVersion() : null;
|
|
678
|
+
return version && atLeast(version, UV_MIN) ? "uv" : installUv(process.env, ["--json"]);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** Start the first download in its own session (`background-download.js`): "started" | "running". */
|
|
682
|
+
function startBackgroundDownload() {
|
|
683
|
+
return download.startDownload({ launcher: __filename, args: [] });
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/** The detached download itself: the newest CLI, installed for good by its own bootstrap. */
|
|
687
|
+
async function runBackgroundDownload() {
|
|
688
|
+
const { pinned, spec, missingBuild } = await getLatestSpec();
|
|
689
|
+
const refresh = getRefreshFlags({ repair: false, missingBuild, pinned });
|
|
690
|
+
const uv = getUv();
|
|
691
|
+
process.exit(download.runDownload([[uv, "tool", "run", "--python", PYTHON_REQUEST, ...refresh, "--from", spec,
|
|
692
|
+
"probe", "service", "start", "--min-version", pinned || AGENT_MIN_CLI, "--json"]]));
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** An uninstall stopped halfway is finished (`probe repair`) before the tab opens (D47). */
|
|
696
|
+
async function finishStoppedUninstall(deadlineMs) {
|
|
697
|
+
const { spec } = await getLatestSpec();
|
|
698
|
+
const uv = getUv();
|
|
699
|
+
const refresh = getRefreshFlags({ repair: true });
|
|
700
|
+
spawnSync(uv, ["tool", "run", "--isolated", "--python", PYTHON_REQUEST, ...refresh, "--from", spec, "probe",
|
|
701
|
+
"repair", "--json"],
|
|
702
|
+
{ stdio: ["ignore", 2, 2], timeout: Math.max(1000, deadlineMs - WAIT_RESERVE_MS - Date.now()) });
|
|
703
|
+
if (hasBarrier()) {
|
|
704
|
+
agentRun.refuse(agentRun.Reason.UNINSTALL_RUNNING,
|
|
705
|
+
"An uninstall of Probe stopped halfway and is being finished first: run the same command again.",
|
|
706
|
+
agentRun.EXIT_AGAIN);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/** An agent's call while the first download runs: wait within the budget, else `downloading` (75). */
|
|
711
|
+
async function waitForRunningDownload(startedMs) {
|
|
712
|
+
const until = startedMs + agentRun.AGENT_BUDGET_MS - WAIT_RESERVE_MS;
|
|
713
|
+
for (;;) {
|
|
714
|
+
const record = download.loadDownload();
|
|
715
|
+
if (!record || record.state !== download.DownloadState.RUNNING) return record;
|
|
716
|
+
if (Date.now() >= until) {
|
|
717
|
+
agentRun.refuse(agentRun.Reason.DOWNLOADING, "Probe is still downloading: run the same command again.",
|
|
718
|
+
agentRun.EXIT_AGAIN);
|
|
719
|
+
}
|
|
720
|
+
await sleep(DOWNLOAD_POLL_MS);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/** `sign-in`: the tab within seconds, the download behind it; `sign-in --wait`: the CLI finishes it. */
|
|
725
|
+
async function runSignIn(rest, startedMs) {
|
|
726
|
+
const deadlineMs = startedMs + agentRun.AGENT_BUDGET_MS;
|
|
727
|
+
const unknown = rest.find((word) => !SIGN_IN_FLAGS.includes(word));
|
|
728
|
+
if (unknown) agentRun.refuse(agentRun.Reason.INCOMPLETE, `sign-in takes ${SIGN_IN_FLAGS.join(", ")}, not ${unknown}`, 2);
|
|
729
|
+
if (process.platform === "win32") {
|
|
730
|
+
console.error(UNSUPPORTED_PLATFORM);
|
|
731
|
+
await sendUnsupportedPlatform(process.env);
|
|
732
|
+
process.exit(1);
|
|
733
|
+
}
|
|
734
|
+
const hosted = signIn.findHostedAgent(process.env);
|
|
735
|
+
if (hosted) {
|
|
736
|
+
agentRun.refuse(agentRun.Reason.HOSTED_AGENT, `This chat runs in ${hosted}, not on your computer, so Probe `
|
|
737
|
+
+ "cannot be set up from it. Paste this into an agent on your own computer.", 1);
|
|
738
|
+
}
|
|
739
|
+
if (rest.includes("--wait")) return waitForSignIn(rest.includes("--json"), startedMs);
|
|
740
|
+
if (hasBarrier()) await finishStoppedUninstall(deadlineMs);
|
|
741
|
+
const started = await signIn.startSignIn({ noBrowser: rest.includes("--no-browser") });
|
|
742
|
+
if (!started.ok) agentRun.refuse(agentRun.Reason.INCOMPLETE, started.message, 1);
|
|
743
|
+
const downloading = findProbe(AGENT_MIN_CLI) ? "not_needed" : startBackgroundDownload();
|
|
744
|
+
await sendLauncherEvent(process.env, SIGN_IN_STARTED_EVENT);
|
|
745
|
+
if (!rest.includes("--json")) {
|
|
746
|
+
agentRun.writeLine(`Approve this computer in the browser: ${started.verification_uri_complete}`);
|
|
747
|
+
agentRun.writeLine(`The page shows the code ${started.user_code}. Then run: ${SIGN_IN_WAIT.replace(" --json", "")}`);
|
|
748
|
+
process.exit(0);
|
|
749
|
+
}
|
|
750
|
+
agentRun.answer({ ...started, reason: agentRun.Reason.WAITING_FOR_APPROVAL, download: downloading,
|
|
751
|
+
next: SIGN_IN_WAIT }, 0);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** The downloaded `probe`, asked again while the budget lasts when the download finished (`done`). */
|
|
755
|
+
async function findDownloadedProbe(done, startedMs) {
|
|
756
|
+
const until = startedMs + agentRun.AGENT_BUDGET_MS - WAIT_RESERVE_MS;
|
|
757
|
+
for (;;) {
|
|
758
|
+
const probe = findProbe(AGENT_MIN_CLI);
|
|
759
|
+
if (probe || !done || done.state !== download.DownloadState.DONE || Date.now() >= until) return probe;
|
|
760
|
+
await sleep(DOWNLOAD_POLL_MS);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/** `sign-in --wait`: the download first (within the budget), then the CLI polls for the approval. */
|
|
765
|
+
async function waitForSignIn(json, startedMs) {
|
|
766
|
+
if (!signIn.loadPending()) {
|
|
767
|
+
agentRun.refuse(agentRun.Reason.SIGN_IN_EXPIRED,
|
|
768
|
+
"No sign-in is waiting (or it expired): run `npx -y probe-research sign-in --json` for a new one.", 1);
|
|
769
|
+
}
|
|
770
|
+
if (hasBarrier()) {
|
|
771
|
+
agentRun.refuse(agentRun.Reason.UNINSTALL_RUNNING,
|
|
772
|
+
"An uninstall of Probe stopped halfway: run `npx -y probe-research sign-in --json` again to finish it.",
|
|
773
|
+
agentRun.EXIT_AGAIN);
|
|
774
|
+
}
|
|
775
|
+
let probe = findProbe(AGENT_MIN_CLI);
|
|
776
|
+
if (!probe) {
|
|
777
|
+
const record = download.loadDownload();
|
|
778
|
+
if (!record || record.state === download.DownloadState.FAILED) startBackgroundDownload();
|
|
779
|
+
const done = await waitForRunningDownload(startedMs);
|
|
780
|
+
probe = await findDownloadedProbe(done, startedMs);
|
|
781
|
+
if (!probe && done && done.state === download.DownloadState.DONE) {
|
|
782
|
+
// Installed, but its `probe` did not answer yet: the Probe service it just started restarts
|
|
783
|
+
// once for its first update, and `probe --version` goes through it (PR3b dry run, 1 in 4).
|
|
784
|
+
agentRun.refuse(agentRun.Reason.DOWNLOADING, "Probe is finishing its install: run the same command again.",
|
|
785
|
+
agentRun.EXIT_AGAIN);
|
|
786
|
+
}
|
|
787
|
+
if (!probe) {
|
|
788
|
+
agentRun.refuse(agentRun.Reason.INCOMPLETE,
|
|
789
|
+
`Probe did not download (${(done && done.error) || "no probe command after it"}); ` +
|
|
790
|
+
`its log: ${download.getFile(download.LOG_NAME)}`, 1);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return runAgentCall(probe, ["wizard", "--action", "login", "--pending", ...(json ? ["--json"] : [])], startedMs);
|
|
794
|
+
}
|
|
795
|
+
|
|
547
796
|
/**
|
|
548
797
|
* uv's cache flags for a throwaway run. A pinned release builds once and is reused from uv's cache:
|
|
549
798
|
* `--refresh-package` reads only probe-research's index again (and the compiled CLI's, which `[all]` pins
|
|
@@ -562,6 +811,13 @@ function hashFile(file) {
|
|
|
562
811
|
return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
|
563
812
|
}
|
|
564
813
|
|
|
814
|
+
/** Where `uv tool install` links a tool's commands (`UV_TOOL_BIN_DIR`, then uv's own order). */
|
|
815
|
+
function getUvBinFolders(env) {
|
|
816
|
+
return [env.UV_TOOL_BIN_DIR, env.XDG_BIN_HOME,
|
|
817
|
+
env.XDG_DATA_HOME ? path.join(env.XDG_DATA_HOME, "..", "bin") : null,
|
|
818
|
+
path.join(os.homedir(), ".local", "bin")].filter(Boolean);
|
|
819
|
+
}
|
|
820
|
+
|
|
565
821
|
/**
|
|
566
822
|
* Where uv's installer puts uv, in its own order (UV_INSTALL_DIR, XDG_BIN_HOME,
|
|
567
823
|
* XDG_DATA_HOME/../bin, ~/.local/bin): none of them is on THIS process's PATH,
|
package/lib/agent-run.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's command, kept inside its 110 s (plan D3, D67): the CLI stops itself between steps
|
|
3
|
+
* at the deadline it is handed (`PROBE_AGENT_DEADLINE`); this is only the backstop for a step that
|
|
4
|
+
* hangs. The child runs in its own process group so the whole group can be stopped: SIGTERM at the
|
|
5
|
+
* deadline, SIGKILL 5 s later, then one JSON line saying to run it again. Never the interactive
|
|
6
|
+
* wizard: a detached group loses the terminal.
|
|
7
|
+
*
|
|
8
|
+
* Every answer the launcher gives itself is one JSON line, `{ok, reason, message?}`, with a reason
|
|
9
|
+
* from the CLI's closed list (`probe.core.events.AgentInstallReason`): the agent branches on it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const { spawn } = require("node:child_process");
|
|
14
|
+
|
|
15
|
+
/** The whole command's time, the download wait included. */
|
|
16
|
+
const AGENT_BUDGET_MS = 110 * 1000;
|
|
17
|
+
/** After SIGTERM, this long before SIGKILL. */
|
|
18
|
+
const KILL_GRACE_MS = 5 * 1000;
|
|
19
|
+
/** The variable the CLI reads its deadline from (epoch seconds; `agent_install.budget.DEADLINE_ENV`). */
|
|
20
|
+
const DEADLINE_ENV = "PROBE_AGENT_DEADLINE";
|
|
21
|
+
/** The CLI's own reserve: it is told a deadline this much before the backstop's. */
|
|
22
|
+
const CLI_MARGIN_MS = 3 * 1000;
|
|
23
|
+
|
|
24
|
+
/** The reasons the launcher answers itself (each is an `AgentInstallReason`). */
|
|
25
|
+
const Reason = Object.freeze({
|
|
26
|
+
WAITING_FOR_APPROVAL: "waiting_for_approval",
|
|
27
|
+
DOWNLOADING: "downloading",
|
|
28
|
+
UNINSTALL_RUNNING: "uninstall_running",
|
|
29
|
+
SIGN_IN_EXPIRED: "sign_in_expired",
|
|
30
|
+
INCOMPLETE: "incomplete",
|
|
31
|
+
RUN_AGAIN: "run_again",
|
|
32
|
+
HOSTED_AGENT: "hosted_agent",
|
|
33
|
+
});
|
|
34
|
+
/** Exit statuses: 75 means "run the same command again" (the CLI's `AGENT_EXIT_CODES`). */
|
|
35
|
+
const EXIT_AGAIN = 75;
|
|
36
|
+
|
|
37
|
+
/** One JSON answer on stdout, then exit `code`. Written synchronously: on a macOS pipe
|
|
38
|
+
* `process.stdout` is asynchronous, and `process.exit` would drop the line it still queues. */
|
|
39
|
+
function answer(fields, code) {
|
|
40
|
+
writeLine(JSON.stringify(fields));
|
|
41
|
+
process.exit(code);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One line on stdout, written before this returns (a full pipe falls back to the stream). */
|
|
45
|
+
function writeLine(text) {
|
|
46
|
+
try {
|
|
47
|
+
fs.writeSync(1, `${text}\n`);
|
|
48
|
+
} catch {
|
|
49
|
+
process.stdout.write(`${text}\n`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Exit with `code` after one `{ok: false, reason, message}` line. */
|
|
54
|
+
function refuse(reason, message, code, extra = {}) {
|
|
55
|
+
answer({ ok: false, reason, message, ...extra }, code);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Run `cmd args` with the terminal's stdio, in its own process group, until `deadlineMs` (epoch
|
|
60
|
+
* ms): the child's own exit status, or the backstop's `run_again` when it had to be stopped.
|
|
61
|
+
*/
|
|
62
|
+
function runWithBackstop(cmd, args, { deadlineMs, env = process.env } = {}) {
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
const child = spawn(cmd, args, {
|
|
65
|
+
stdio: "inherit",
|
|
66
|
+
detached: true,
|
|
67
|
+
env: { ...env, [DEADLINE_ENV]: String((deadlineMs - CLI_MARGIN_MS) / 1000) },
|
|
68
|
+
});
|
|
69
|
+
let stopped = false;
|
|
70
|
+
const signalGroup = (signal) => {
|
|
71
|
+
try {
|
|
72
|
+
process.kill(-child.pid, signal);
|
|
73
|
+
} catch {}
|
|
74
|
+
};
|
|
75
|
+
// The agent's own Ctrl-C or kill reaches the launcher only: pass it on to the group.
|
|
76
|
+
const forward = (signal) => () => signalGroup(signal);
|
|
77
|
+
const handlers = { SIGINT: forward("SIGINT"), SIGTERM: forward("SIGTERM"), SIGHUP: forward("SIGHUP") };
|
|
78
|
+
for (const [signal, handler] of Object.entries(handlers)) process.on(signal, handler);
|
|
79
|
+
let killTimer = null;
|
|
80
|
+
const stopTimer = setTimeout(() => {
|
|
81
|
+
stopped = true;
|
|
82
|
+
signalGroup("SIGTERM");
|
|
83
|
+
killTimer = setTimeout(() => signalGroup("SIGKILL"), KILL_GRACE_MS);
|
|
84
|
+
}, Math.max(0, deadlineMs - Date.now()));
|
|
85
|
+
child.on("error", (err) => {
|
|
86
|
+
clearTimeout(stopTimer);
|
|
87
|
+
for (const [signal, handler] of Object.entries(handlers)) process.off(signal, handler);
|
|
88
|
+
resolve({ code: 1, error: err.message });
|
|
89
|
+
});
|
|
90
|
+
child.on("exit", (code, signal) => {
|
|
91
|
+
clearTimeout(stopTimer);
|
|
92
|
+
if (killTimer) clearTimeout(killTimer);
|
|
93
|
+
for (const [name, handler] of Object.entries(handlers)) process.off(name, handler);
|
|
94
|
+
resolve({ code: code === null ? 128 + (signal === "SIGKILL" ? 9 : 15) : code, stopped });
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
AGENT_BUDGET_MS,
|
|
101
|
+
CLI_MARGIN_MS,
|
|
102
|
+
DEADLINE_ENV,
|
|
103
|
+
EXIT_AGAIN,
|
|
104
|
+
KILL_GRACE_MS,
|
|
105
|
+
Reason,
|
|
106
|
+
answer,
|
|
107
|
+
refuse,
|
|
108
|
+
runWithBackstop,
|
|
109
|
+
writeLine,
|
|
110
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first download, behind the sign-in (plan D3): uv, Python 3.13 and the CLI, installed for good
|
|
3
|
+
* by the CLI's own bootstrap (`probe service start --min-version`, the Mac app's), while the person
|
|
4
|
+
* is in the browser tab.
|
|
5
|
+
*
|
|
6
|
+
* Its own process, in its own session (`detached`), so an agent's 110 s kill of the command that
|
|
7
|
+
* started it never takes it; it ends by itself after DOWNLOAD_CAP_MS. One at a time
|
|
8
|
+
* (`download.lock`, the holder's pid), one log (`download.log`), one record the later commands read
|
|
9
|
+
* (`download.json`: running | done | failed). A machine with an uninstall stopped halfway runs
|
|
10
|
+
* `probe repair` instead: it finishes that uninstall before anything is signed in (D47).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const fs = require("node:fs");
|
|
14
|
+
const path = require("node:path");
|
|
15
|
+
const { spawn, spawnSync } = require("node:child_process");
|
|
16
|
+
|
|
17
|
+
const { getStateFolder } = require("./sign-in");
|
|
18
|
+
|
|
19
|
+
const RECORD_NAME = "download.json";
|
|
20
|
+
const LOG_NAME = "download.log";
|
|
21
|
+
const LOCK_NAME = "download.lock";
|
|
22
|
+
/** The whole download, every step: past it the process stops (its children too). */
|
|
23
|
+
const DOWNLOAD_CAP_MS = 10 * 60 * 1000;
|
|
24
|
+
/** The hidden word the launcher re-runs itself with, detached, to do the download. */
|
|
25
|
+
const DOWNLOAD_VERB = "--probe-background-download";
|
|
26
|
+
|
|
27
|
+
const DownloadState = Object.freeze({ RUNNING: "running", DONE: "done", FAILED: "failed" });
|
|
28
|
+
|
|
29
|
+
function getFile(name) {
|
|
30
|
+
return path.join(getStateFolder(), name);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The download's record, or null (none yet). A running one whose process is gone reads failed. */
|
|
34
|
+
function loadDownload() {
|
|
35
|
+
let record;
|
|
36
|
+
try {
|
|
37
|
+
record = JSON.parse(fs.readFileSync(getFile(RECORD_NAME), "utf8"));
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (!record || typeof record !== "object") return null;
|
|
42
|
+
if (record.state === DownloadState.RUNNING && !isAlive(record.pid)) {
|
|
43
|
+
return { ...record, state: DownloadState.FAILED, error: "the download stopped before it finished" };
|
|
44
|
+
}
|
|
45
|
+
return record;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function saveDownload(record) {
|
|
49
|
+
fs.mkdirSync(getStateFolder(), { recursive: true, mode: 0o700 });
|
|
50
|
+
const file = getFile(RECORD_NAME);
|
|
51
|
+
const temp = `${file}.${process.pid}`;
|
|
52
|
+
fs.writeFileSync(temp, JSON.stringify(record), { mode: 0o600 });
|
|
53
|
+
fs.renameSync(temp, file);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isAlive(pid) {
|
|
57
|
+
if (!Number.isInteger(pid) || pid <= 1) return false;
|
|
58
|
+
try {
|
|
59
|
+
process.kill(pid, 0);
|
|
60
|
+
return true;
|
|
61
|
+
} catch (err) {
|
|
62
|
+
return err && err.code === "EPERM";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Take the one download's lock; false while a live download holds it (a stale one is broken). */
|
|
67
|
+
function takeLock() {
|
|
68
|
+
const lock = getFile(LOCK_NAME);
|
|
69
|
+
fs.mkdirSync(getStateFolder(), { recursive: true, mode: 0o700 });
|
|
70
|
+
for (let tries = 0; tries < 2; tries++) {
|
|
71
|
+
try {
|
|
72
|
+
const fd = fs.openSync(lock, "wx", 0o600);
|
|
73
|
+
fs.writeSync(fd, String(process.pid));
|
|
74
|
+
fs.closeSync(fd);
|
|
75
|
+
return true;
|
|
76
|
+
} catch {
|
|
77
|
+
let holder = NaN;
|
|
78
|
+
let age = Infinity;
|
|
79
|
+
try {
|
|
80
|
+
holder = parseInt(fs.readFileSync(lock, "utf8"), 10);
|
|
81
|
+
age = Date.now() - fs.statSync(lock).mtimeMs;
|
|
82
|
+
} catch {}
|
|
83
|
+
if (isAlive(holder) && age < DOWNLOAD_CAP_MS) return false;
|
|
84
|
+
try {
|
|
85
|
+
fs.unlinkSync(lock);
|
|
86
|
+
} catch {}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function readLockHolder() {
|
|
93
|
+
try {
|
|
94
|
+
return fs.readFileSync(getFile(LOCK_NAME), "utf8");
|
|
95
|
+
} catch {
|
|
96
|
+
return "";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function releaseLock() {
|
|
101
|
+
try {
|
|
102
|
+
if (parseInt(fs.readFileSync(getFile(LOCK_NAME), "utf8"), 10) === process.pid) fs.unlinkSync(getFile(LOCK_NAME));
|
|
103
|
+
} catch {}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Start the download in its own session, unless one runs: `"started" | "running"`. `args` are what
|
|
108
|
+
* the detached launcher runs (`downloadArgs`), `launcher` its own file.
|
|
109
|
+
*/
|
|
110
|
+
function startDownload({ launcher, args, env = process.env }) {
|
|
111
|
+
const record = loadDownload();
|
|
112
|
+
if (record && record.state === DownloadState.RUNNING) return "running";
|
|
113
|
+
fs.mkdirSync(getStateFolder(), { recursive: true, mode: 0o700 });
|
|
114
|
+
const log = fs.openSync(getFile(LOG_NAME), "a", 0o600);
|
|
115
|
+
const child = spawn(process.execPath, [launcher, DOWNLOAD_VERB, ...args], {
|
|
116
|
+
detached: true,
|
|
117
|
+
stdio: ["ignore", log, log],
|
|
118
|
+
env,
|
|
119
|
+
});
|
|
120
|
+
child.on("error", () => {});
|
|
121
|
+
saveDownload({ state: DownloadState.RUNNING, pid: child.pid, started_at: Date.now() / 1000 });
|
|
122
|
+
child.unref();
|
|
123
|
+
fs.closeSync(log);
|
|
124
|
+
return "started";
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The detached process's work: each step (`[cmd, ...args]`) in turn within DOWNLOAD_CAP_MS, its
|
|
129
|
+
* output in the log, its end in the record. Returns the exit status.
|
|
130
|
+
*/
|
|
131
|
+
function runDownload(steps) {
|
|
132
|
+
if (!takeLock()) {
|
|
133
|
+
// Another download runs: the record names it (the starter wrote this process's pid there).
|
|
134
|
+
const holder = parseInt(readLockHolder(), 10);
|
|
135
|
+
if (isAlive(holder)) saveDownload({ state: DownloadState.RUNNING, pid: holder, started_at: Date.now() / 1000 });
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
const started = Date.now();
|
|
139
|
+
saveDownload({ state: DownloadState.RUNNING, pid: process.pid, started_at: started / 1000 });
|
|
140
|
+
try {
|
|
141
|
+
for (const [cmd, ...args] of steps) {
|
|
142
|
+
const left = DOWNLOAD_CAP_MS - (Date.now() - started);
|
|
143
|
+
const ran = left > 0 ? spawnSync(cmd, args, { stdio: "inherit", timeout: left, killSignal: "SIGKILL" }) : null;
|
|
144
|
+
if (!ran || ran.error || ran.status !== 0) {
|
|
145
|
+
const why = !ran ? "the download ran out of time"
|
|
146
|
+
: ran.error ? `${cmd}: ${ran.error.message}` : `${path.basename(cmd)} exited ${ran.status}`;
|
|
147
|
+
saveDownload({ state: DownloadState.FAILED, pid: process.pid, error: why, finished_at: Date.now() / 1000 });
|
|
148
|
+
return 1;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
saveDownload({ state: DownloadState.DONE, pid: process.pid, finished_at: Date.now() / 1000 });
|
|
152
|
+
return 0;
|
|
153
|
+
} finally {
|
|
154
|
+
releaseLock();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module.exports = {
|
|
159
|
+
DOWNLOAD_CAP_MS,
|
|
160
|
+
DOWNLOAD_VERB,
|
|
161
|
+
DownloadState,
|
|
162
|
+
LOG_NAME,
|
|
163
|
+
getFile,
|
|
164
|
+
loadDownload,
|
|
165
|
+
runDownload,
|
|
166
|
+
startDownload,
|
|
167
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This machine's device id, read (or minted) exactly as the CLI does: a port of
|
|
3
|
+
* `probe.sdk.settings.device_identity.device_instance_id`.
|
|
4
|
+
*
|
|
5
|
+
* The agent's sign-in starts before any CLI exists (D1), and the server binds the key it mints
|
|
6
|
+
* to the device the request names: a key with no device cannot mint the capture and daemon keys
|
|
7
|
+
* an install adds, so the install would open a second tab. Both languages must therefore land on
|
|
8
|
+
* ONE id. The rules kept: `PROBE_DEVICE_ID_PATH` / `PROBE_CONFIG_PATH` overrides, the stable
|
|
9
|
+
* machine witness (`m1:` + sha256 of `<machine id>:<home>`), a namespaced file for a second
|
|
10
|
+
* machine on a shared home, the legacy `<host>:<home>` witness, and an `O_EXCL` lock on the first
|
|
11
|
+
* mint. agent/tests/test_launcher_device_identity.py reads a file this wrote with the CLI's code.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const crypto = require("node:crypto");
|
|
15
|
+
const fs = require("node:fs");
|
|
16
|
+
const os = require("node:os");
|
|
17
|
+
const path = require("node:path");
|
|
18
|
+
const { spawnSync } = require("node:child_process");
|
|
19
|
+
|
|
20
|
+
const FILENAME = "device.json";
|
|
21
|
+
const ID_RE = /^[A-Za-z0-9_-]{16,128}$/;
|
|
22
|
+
const MACHINE_ID_RE = /^[0-9a-f]{32}$/;
|
|
23
|
+
const MAX_FILE_BYTES = 64 * 1024;
|
|
24
|
+
const WITNESS_HEX_LEN = 32;
|
|
25
|
+
const LOCK_WAIT_MS = 2000;
|
|
26
|
+
|
|
27
|
+
function getDeviceFile(env) {
|
|
28
|
+
if (env.PROBE_DEVICE_ID_PATH) return env.PROBE_DEVICE_ID_PATH;
|
|
29
|
+
if (env.PROBE_CONFIG_PATH) return path.join(path.dirname(env.PROBE_CONFIG_PATH), FILENAME);
|
|
30
|
+
const base = env.XDG_STATE_HOME || path.join(os.homedir(), ".local", "state");
|
|
31
|
+
return path.join(base, "probe", FILENAME);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `<host>:<home>`, the CLI's `_home_fingerprint`. */
|
|
35
|
+
function getHomeFingerprint() {
|
|
36
|
+
let host = "";
|
|
37
|
+
try {
|
|
38
|
+
host = os.hostname().split(".")[0].trim();
|
|
39
|
+
} catch {}
|
|
40
|
+
return `${host || "unknown-host"}:${os.homedir()}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isInContainer() {
|
|
44
|
+
if (fs.existsSync("/.dockerenv")) return true;
|
|
45
|
+
try {
|
|
46
|
+
const cgroup = fs.readFileSync("/proc/self/cgroup", "utf8");
|
|
47
|
+
return ["docker", "kubepods", "containerd", "lxc"].some((marker) => cgroup.includes(marker));
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isUsableMachineId(value) {
|
|
54
|
+
return MACHINE_ID_RE.test(value) && value !== "0".repeat(32);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** `/etc/machine-id` on Linux (never in a container), the hardware UUID on macOS, else "". */
|
|
58
|
+
function getMachineId() {
|
|
59
|
+
if (process.platform === "linux" && !isInContainer()) {
|
|
60
|
+
for (const candidate of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
|
61
|
+
try {
|
|
62
|
+
const value = fs.readFileSync(candidate, "utf8").trim();
|
|
63
|
+
if (isUsableMachineId(value)) return value;
|
|
64
|
+
} catch {}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (process.platform === "darwin") {
|
|
68
|
+
const ran = spawnSync("/usr/sbin/ioreg", ["-rd1", "-c", "IOPlatformExpertDevice"],
|
|
69
|
+
{ encoding: "utf8", timeout: 2000 });
|
|
70
|
+
const found = ran.status === 0 ? (ran.stdout.match(/"IOPlatformUUID"\s*=\s*"([0-9A-Fa-f-]+)"/) || [])[1] : null;
|
|
71
|
+
const value = found ? found.replace(/-/g, "").toLowerCase() : "";
|
|
72
|
+
if (isUsableMachineId(value)) return value;
|
|
73
|
+
}
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** `m1:<sha256(machine:home)[:32]>`, or null where no stable machine id exists. */
|
|
78
|
+
function getMachineWitness() {
|
|
79
|
+
const machine = getMachineId();
|
|
80
|
+
if (!machine) return null;
|
|
81
|
+
return `m1:${crypto.createHash("sha256").update(`${machine}:${os.homedir()}`).digest("hex").slice(0, WITNESS_HEX_LEN)}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The file as an object, or {} (absent, a link, not a regular file, too big, not JSON). */
|
|
85
|
+
function readFile(file) {
|
|
86
|
+
try {
|
|
87
|
+
const stat = fs.lstatSync(file);
|
|
88
|
+
if (!stat.isFile() || stat.size > MAX_FILE_BYTES) return {};
|
|
89
|
+
const data = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
90
|
+
return data && typeof data === "object" && !Array.isArray(data) ? data : {};
|
|
91
|
+
} catch {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function writeFile(file, payload) {
|
|
97
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
98
|
+
const temp = path.join(path.dirname(file), `.device-${process.pid}-${Date.now()}.json`);
|
|
99
|
+
fs.writeFileSync(temp, JSON.stringify(payload, Object.keys(payload).sort(), 2), { mode: 0o600 });
|
|
100
|
+
fs.renameSync(temp, file);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getNamespaced(file, witness) {
|
|
104
|
+
const digest = crypto.createHash("sha256").update(witness).digest("hex").slice(0, 12);
|
|
105
|
+
const ext = path.extname(file);
|
|
106
|
+
return path.join(path.dirname(file), `${path.basename(file, ext)}-${digest}${ext}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function validId(value) {
|
|
110
|
+
return typeof value === "string" && ID_RE.test(value) ? value : null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* This machine's id, minted on first use; null when it cannot be kept (the request then names no
|
|
115
|
+
* device, as an unpersistable CLI's does).
|
|
116
|
+
*/
|
|
117
|
+
function getDeviceInstanceId(env = process.env) {
|
|
118
|
+
let file = getDeviceFile(env);
|
|
119
|
+
const fingerprint = getHomeFingerprint();
|
|
120
|
+
const witness = getMachineWitness();
|
|
121
|
+
const claimed = (payload) => {
|
|
122
|
+
const value = validId(payload.device_instance_id);
|
|
123
|
+
return value && witness && payload.machine === witness ? value : null;
|
|
124
|
+
};
|
|
125
|
+
const ours = (payload) => {
|
|
126
|
+
const value = validId(payload.device_instance_id);
|
|
127
|
+
if (!value) return null;
|
|
128
|
+
if (witness && payload.machine) return claimed(payload);
|
|
129
|
+
if (payload.home !== undefined && payload.home !== null && payload.home !== fingerprint) return null;
|
|
130
|
+
return value;
|
|
131
|
+
};
|
|
132
|
+
const canonical = readFile(file);
|
|
133
|
+
const namespaced = witness ? getNamespaced(file, witness) : null;
|
|
134
|
+
const found = claimed(canonical) || (namespaced && claimed(readFile(namespaced))) || ours(canonical);
|
|
135
|
+
if (found) return found;
|
|
136
|
+
if (validId(canonical.device_instance_id)) {
|
|
137
|
+
// Another machine's file on a shared home: this one gets its own beside it.
|
|
138
|
+
file = namespaced || getNamespaced(file, fingerprint);
|
|
139
|
+
const mine = ours(readFile(file));
|
|
140
|
+
if (mine) return mine;
|
|
141
|
+
}
|
|
142
|
+
const lock = file.replace(/\.json$/, "") + ".lock";
|
|
143
|
+
let held = null;
|
|
144
|
+
try {
|
|
145
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
146
|
+
held = fs.openSync(lock, "wx");
|
|
147
|
+
} catch {
|
|
148
|
+
// Someone else is minting: read theirs once they are done.
|
|
149
|
+
const until = Date.now() + LOCK_WAIT_MS;
|
|
150
|
+
while (Date.now() < until) {
|
|
151
|
+
const theirs = ours(readFile(file));
|
|
152
|
+
if (theirs) return theirs;
|
|
153
|
+
spawnSync(process.execPath, ["-e", "setTimeout(() => {}, 50)"]);
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const again = ours(readFile(file));
|
|
159
|
+
if (again) return again;
|
|
160
|
+
const minted = crypto.randomBytes(16).toString("hex");
|
|
161
|
+
const payload = { device_instance_id: minted, created_at: Math.floor(Date.now() / 1000), home: fingerprint };
|
|
162
|
+
if (witness) payload.machine = witness;
|
|
163
|
+
writeFile(file, payload);
|
|
164
|
+
return minted;
|
|
165
|
+
} catch {
|
|
166
|
+
return null;
|
|
167
|
+
} finally {
|
|
168
|
+
try {
|
|
169
|
+
fs.closeSync(held);
|
|
170
|
+
fs.unlinkSync(lock);
|
|
171
|
+
} catch {}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
module.exports = { getDeviceInstanceId, getDeviceFile, getMachineWitness };
|
package/lib/sign-in.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `npx probe-research sign-in`: the agent's sign-in, asked for before anything downloads (plan D1).
|
|
3
|
+
*
|
|
4
|
+
* One POST for a device code (PKCE S256, the request the CLI sends for an agent: see
|
|
5
|
+
* tests/fixtures/device_code_request.json), the tab opened, and the secret half -- the device code
|
|
6
|
+
* and the PKCE verifier -- kept in a 0600 file for the CLI's `--action login --pending`, which
|
|
7
|
+
* polls for the approval. Nothing secret is printed: the answer names the code to read and the
|
|
8
|
+
* link, as the tab shows them.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const crypto = require("node:crypto");
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const os = require("node:os");
|
|
14
|
+
const path = require("node:path");
|
|
15
|
+
const { spawn } = require("node:child_process");
|
|
16
|
+
|
|
17
|
+
const { getDeviceInstanceId } = require("./device-identity");
|
|
18
|
+
|
|
19
|
+
/** The folder the launcher and the CLI share (`probe.cli.install.attempt.get_folder`). */
|
|
20
|
+
const STATE_FOLDER = [".local", "state", "probe", "agent-install"];
|
|
21
|
+
const PENDING_NAME = "sign-in.json";
|
|
22
|
+
const PENDING_VERSION = 1;
|
|
23
|
+
const START_PATH = "/auth/device/code";
|
|
24
|
+
/** The request, as the CLI's `AGENT_CLIENT_CONTEXT` / `AGENT_GRANTS` spell it. */
|
|
25
|
+
const AGENT_CLIENT_CONTEXT = Object.freeze({ install: true, surface: "agent" });
|
|
26
|
+
const AGENT_GRANTS = Object.freeze(["api", "mcp"]);
|
|
27
|
+
const TOKEN_NAME_PREFIX = "Probe Research CLI · ";
|
|
28
|
+
/**
|
|
29
|
+
* Each coding agent's markers, in the harness registry's order (`harnesses.json`: id, detect_env,
|
|
30
|
+
* session_env): the agent this sign-in runs in, named on the approval page (`client_context.agent`,
|
|
31
|
+
* display only, D79). agent/tests/test_launcher_matches_cli.py holds this table to the registry.
|
|
32
|
+
*/
|
|
33
|
+
const AGENT_MARKERS = Object.freeze([
|
|
34
|
+
["claude_code", ["CLAUDECODE", "CLAUDE_CODE_ENTRYPOINT"], "CLAUDE_CODE_SESSION_ID"],
|
|
35
|
+
["codex", ["CODEX_SANDBOX", "CODEX_THREAD_ID"], "CODEX_THREAD_ID"],
|
|
36
|
+
["pi", ["PI_CODING_AGENT"], "PI_SESSION_ID"],
|
|
37
|
+
["kimi_code", ["PROBE_KIMI_SESSION_ID"], "PROBE_KIMI_SESSION_ID"],
|
|
38
|
+
["cursor_agent", ["CURSOR_AGENT"], "CURSOR_CONVERSATION_ID"],
|
|
39
|
+
]);
|
|
40
|
+
/**
|
|
41
|
+
* Hosted agents, whose chats run on the agent maker's computers, never the person's (plan D12): a
|
|
42
|
+
* marker each sets itself, never a guess from the machine (a Docker container on the person's own
|
|
43
|
+
* computer is no hosted agent). Claude Code on the web: `CLAUDE_CODE_REMOTE=true` (Claude Code
|
|
44
|
+
* 2.1.296's own check). Codex cloud: `CODEX_PROXY_CERT`, its proxy's CA, set in every cloud task.
|
|
45
|
+
*/
|
|
46
|
+
const HOSTED_AGENTS = Object.freeze([
|
|
47
|
+
["Claude Code on the web", "CLAUDE_CODE_REMOTE", "true"],
|
|
48
|
+
["Codex cloud", "CODEX_PROXY_CERT", null],
|
|
49
|
+
]);
|
|
50
|
+
/** How long the code request may take before the sign-in says it could not start. */
|
|
51
|
+
const START_TIMEOUT_MS = 10000;
|
|
52
|
+
const DEFAULT_BASE = "https://api.research.prbe.ai";
|
|
53
|
+
|
|
54
|
+
function getStateFolder() {
|
|
55
|
+
return path.join(os.homedir(), ...STATE_FOLDER);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A PKCE pair: a 43-character verifier from 32 random bytes, and its unpadded base64url S256. */
|
|
59
|
+
function makePkcePair() {
|
|
60
|
+
const verifier = crypto.randomBytes(32).toString("base64url");
|
|
61
|
+
const challenge = crypto.createHash("sha256").update(verifier).digest("base64url");
|
|
62
|
+
return { verifier, challenge };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The machine's short name, as the CLI labels a key (`device.hostname`, without its macOS read). */
|
|
66
|
+
function getHostname() {
|
|
67
|
+
try {
|
|
68
|
+
return os.hostname().split(".")[0].trim() || "unknown-host";
|
|
69
|
+
} catch {
|
|
70
|
+
return "unknown-host";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The coding agent this runs in, or null: a marker that is only a marker first, then any (the CLI's
|
|
76
|
+
* `agent_session.session_agent_from_env`: a stale Codex id in a pi shell is no Codex).
|
|
77
|
+
*/
|
|
78
|
+
function detectAgent(env) {
|
|
79
|
+
for (const [id, markers, sessionEnv] of AGENT_MARKERS) {
|
|
80
|
+
if (markers.some((name) => name !== sessionEnv && env[name])) return id;
|
|
81
|
+
}
|
|
82
|
+
for (const [id, markers] of AGENT_MARKERS) {
|
|
83
|
+
if (markers.some((name) => env[name])) return id;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The hosted agent this runs in (its name), or null: one on the person's own computer. */
|
|
89
|
+
function findHostedAgent(env) {
|
|
90
|
+
for (const [name, variable, value] of HOSTED_AGENTS) {
|
|
91
|
+
if (env[variable] && (value === null || env[variable] === value)) return name;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The one line the agent shows the person at once: the link and the code (PR3b, finding 2). */
|
|
97
|
+
function getSayLine(uri, code) {
|
|
98
|
+
return `Approve Probe in your browser: ${uri} (code ${code})`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The body of the agent's device request (the fixture's keys, nothing else). */
|
|
102
|
+
function buildRequestBody({ challenge, deviceInstanceId, agent = null }) {
|
|
103
|
+
const body = {
|
|
104
|
+
token_name: `${TOKEN_NAME_PREFIX}${getHostname()}`,
|
|
105
|
+
scopes: null,
|
|
106
|
+
code_challenge: challenge,
|
|
107
|
+
grants: [...AGENT_GRANTS],
|
|
108
|
+
client_context: { ...AGENT_CLIENT_CONTEXT, ...(agent ? { agent } : {}) },
|
|
109
|
+
};
|
|
110
|
+
if (deviceInstanceId) body.device_instance_id = deviceInstanceId;
|
|
111
|
+
return body;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The CLI config's file (`settings.config_path`). */
|
|
115
|
+
function getConfigFile(env) {
|
|
116
|
+
if (env.PROBE_CONFIG_PATH) return env.PROBE_CONFIG_PATH;
|
|
117
|
+
return path.join(env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config"), "probe", "config.json");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The API this computer signs in to: `PROBE_BASE_URL`, else the saved account's, else Probe's.
|
|
122
|
+
* Never a key: only `base_url` is read from the config.
|
|
123
|
+
*/
|
|
124
|
+
function getSignInBase(env) {
|
|
125
|
+
const fromEnv = env.PROBE_BASE_URL;
|
|
126
|
+
if (fromEnv && /^https?:\/\//.test(fromEnv)) return fromEnv.replace(/\/+$/, "");
|
|
127
|
+
try {
|
|
128
|
+
const data = JSON.parse(fs.readFileSync(getConfigFile(env), "utf8"));
|
|
129
|
+
const contexts = data && typeof data.contexts === "object" ? data.contexts : null;
|
|
130
|
+
const active = contexts ? contexts[data.current_context || "default"] : data;
|
|
131
|
+
const saved = active && typeof active.base_url === "string" ? active.base_url : null;
|
|
132
|
+
if (saved && /^https?:\/\//.test(saved)) return saved.replace(/\/+$/, "");
|
|
133
|
+
} catch {}
|
|
134
|
+
return DEFAULT_BASE;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** `content` written whole into `file`, readable by this user only. */
|
|
138
|
+
function savePrivate(file, content) {
|
|
139
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
140
|
+
const temp = `${file}.${process.pid}.${Date.now()}`;
|
|
141
|
+
fs.writeFileSync(temp, content, { mode: 0o600, flag: "wx" });
|
|
142
|
+
fs.renameSync(temp, file);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Open the link where a browser can open (never where PROBE_NO_BROWSER is set). True if tried. */
|
|
146
|
+
function openBrowser(url, env) {
|
|
147
|
+
if (env.PROBE_NO_BROWSER) return false;
|
|
148
|
+
const opener = process.platform === "darwin" ? "open"
|
|
149
|
+
: process.platform === "linux" && (env.DISPLAY || env.WAYLAND_DISPLAY) ? "xdg-open" : null;
|
|
150
|
+
if (!opener) return false;
|
|
151
|
+
try {
|
|
152
|
+
const child = spawn(opener, [url], { detached: true, stdio: "ignore" });
|
|
153
|
+
child.on("error", () => {});
|
|
154
|
+
child.unref();
|
|
155
|
+
return true;
|
|
156
|
+
} catch {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Ask for a code, keep the secret half, open the tab: `{say, ok, attempt, user_code,
|
|
163
|
+
* verification_uri_complete, expires_in, browser_opened}` (`say` first: the line the agent shows
|
|
164
|
+
* before anything else), or `{ok: false, message}`.
|
|
165
|
+
*/
|
|
166
|
+
async function startSignIn({ env = process.env, fetchImpl = fetch, noBrowser = false } = {}) {
|
|
167
|
+
const base = getSignInBase(env);
|
|
168
|
+
const { verifier, challenge } = makePkcePair();
|
|
169
|
+
const body = buildRequestBody({ challenge, deviceInstanceId: getDeviceInstanceId(env), agent: detectAgent(env) });
|
|
170
|
+
let data;
|
|
171
|
+
try {
|
|
172
|
+
const response = await fetchImpl(`${base}${START_PATH}`, {
|
|
173
|
+
method: "POST",
|
|
174
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
175
|
+
body: JSON.stringify(body),
|
|
176
|
+
signal: AbortSignal.timeout(START_TIMEOUT_MS),
|
|
177
|
+
});
|
|
178
|
+
data = await response.json().catch(() => null);
|
|
179
|
+
if (response.status !== 201 || !data || typeof data.device_code !== "string") {
|
|
180
|
+
const detail = data && data.detail && (data.detail.error_description || data.detail.error);
|
|
181
|
+
return { ok: false, message: `could not start the sign-in at ${base} (${detail || response.status})` };
|
|
182
|
+
}
|
|
183
|
+
} catch (err) {
|
|
184
|
+
return { ok: false, message: `could not reach ${base} (${err && err.message ? err.message : err})` };
|
|
185
|
+
}
|
|
186
|
+
const attempt = crypto.randomUUID();
|
|
187
|
+
const expiresIn = Number(data.expires_in) || 600;
|
|
188
|
+
const pending = {
|
|
189
|
+
v: PENDING_VERSION,
|
|
190
|
+
attempt,
|
|
191
|
+
base_url: base,
|
|
192
|
+
device_code: data.device_code,
|
|
193
|
+
code_verifier: verifier,
|
|
194
|
+
user_code: data.user_code,
|
|
195
|
+
verification_uri: data.verification_uri,
|
|
196
|
+
verification_uri_complete: data.verification_uri_complete,
|
|
197
|
+
interval: Number(data.interval) || 5,
|
|
198
|
+
expires_at: Date.now() / 1000 + expiresIn,
|
|
199
|
+
};
|
|
200
|
+
savePrivate(path.join(getStateFolder(), PENDING_NAME), JSON.stringify(pending));
|
|
201
|
+
const opened = noBrowser ? false : openBrowser(data.verification_uri_complete, env);
|
|
202
|
+
return {
|
|
203
|
+
say: getSayLine(data.verification_uri_complete, data.user_code),
|
|
204
|
+
ok: true,
|
|
205
|
+
attempt,
|
|
206
|
+
user_code: data.user_code,
|
|
207
|
+
verification_uri_complete: data.verification_uri_complete,
|
|
208
|
+
expires_in: expiresIn,
|
|
209
|
+
browser_opened: opened,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** The request `startSignIn` left, or null (none, unreadable, expired). Its secret is never printed. */
|
|
214
|
+
function loadPending(now = Date.now() / 1000) {
|
|
215
|
+
try {
|
|
216
|
+
const data = JSON.parse(fs.readFileSync(path.join(getStateFolder(), PENDING_NAME), "utf8"));
|
|
217
|
+
if (!data || data.v !== PENDING_VERSION || typeof data.expires_at !== "number") return null;
|
|
218
|
+
return data.expires_at > now ? data : null;
|
|
219
|
+
} catch {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
module.exports = {
|
|
225
|
+
AGENT_CLIENT_CONTEXT,
|
|
226
|
+
AGENT_MARKERS,
|
|
227
|
+
AGENT_GRANTS,
|
|
228
|
+
PENDING_NAME,
|
|
229
|
+
STATE_FOLDER,
|
|
230
|
+
START_PATH,
|
|
231
|
+
TOKEN_NAME_PREFIX,
|
|
232
|
+
HOSTED_AGENTS,
|
|
233
|
+
buildRequestBody,
|
|
234
|
+
detectAgent,
|
|
235
|
+
findHostedAgent,
|
|
236
|
+
getSayLine,
|
|
237
|
+
getSignInBase,
|
|
238
|
+
getStateFolder,
|
|
239
|
+
loadPending,
|
|
240
|
+
makePkcePair,
|
|
241
|
+
startSignIn,
|
|
242
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "probe-research",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
-
"bin"
|
|
9
|
+
"bin",
|
|
10
|
+
"lib"
|
|
10
11
|
],
|
|
11
12
|
"engines": {
|
|
12
13
|
"node": ">=18"
|
|
@@ -25,6 +26,6 @@
|
|
|
25
26
|
"probe-research"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
|
-
"test": "node --test test/resolve.test.js"
|
|
29
|
+
"test": "node --test test/resolve.test.js test/sign-in.test.js"
|
|
29
30
|
}
|
|
30
31
|
}
|