probe-research 0.17.0 → 0.19.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.
@@ -124,8 +124,14 @@ const FIX_MIN = "0.385.0";
124
124
  * (downloaded once), as below FIX_MIN. Same rule as the floors above: a release already on PyPI
125
125
  * when this launcher publishes (release.yml publishes the launcher after PyPI, in the same run).
126
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
+ * 0.423.0 since PR4b: example.md's keep step runs `probe example keep`, which 0.422.0 (cut before it
130
+ * merged) lacks.
131
+ * 0.424.0 since PR12 (#4381): runs-only.md's `install --profile runs` and already-set-up.md's
132
+ * `install --profile` and `status --repaste-choice`; 0.423.0 was cut from the commit before it merged.
127
133
  */
128
- const AGENT_MIN_CLI = "0.418.0";
134
+ const AGENT_MIN_CLI = "0.424.0";
129
135
  /** `install` flags only AGENT_MIN_CLI knows (D36). */
130
136
  const AGENT_INSTALL_FLAGS = Object.freeze(["--recommended", "--who-records", "--session-default", "--profile",
131
137
  "--attempt"]);
@@ -625,9 +631,13 @@ const DOWNLOAD_POLL_MS = 1000;
625
631
  /** The uninstall barrier (`probe.shared.updates.uninstall_barrier.path`). */
626
632
  const BARRIER_FILE = [".local", "state", "probe", "uninstall", "barrier.json"];
627
633
 
634
+ /** `status` flags only AGENT_MIN_CLI knows: the re-paste menu's answer (D84). */
635
+ const AGENT_STATUS_FLAGS = Object.freeze(["--repaste-choice"]);
636
+
628
637
  /** `probe` arguments only AGENT_MIN_CLI runs (D36). */
629
638
  function needsAgentCli(forwarded) {
630
639
  if (forwarded[0] === "example") return true;
640
+ if (forwarded[0] === "status") return forwarded.some((word) => AGENT_STATUS_FLAGS.includes(word.split("=")[0]));
631
641
  if (forwarded[0] !== LauncherVerb.WIZARD) return false;
632
642
  return forwarded.includes("--pending")
633
643
  || forwarded.some((word) => AGENT_INSTALL_FLAGS.includes(word.split("=")[0]));
@@ -729,6 +739,11 @@ async function runSignIn(rest, startedMs) {
729
739
  await sendUnsupportedPlatform(process.env);
730
740
  process.exit(1);
731
741
  }
742
+ const hosted = signIn.findHostedAgent(process.env);
743
+ if (hosted) {
744
+ agentRun.refuse(agentRun.Reason.HOSTED_AGENT, `This chat runs in ${hosted}, not on your computer, so Probe `
745
+ + "cannot be set up from it. Paste this into an agent on your own computer.", 1);
746
+ }
732
747
  if (rest.includes("--wait")) return waitForSignIn(rest.includes("--json"), startedMs);
733
748
  if (hasBarrier()) await finishStoppedUninstall(deadlineMs);
734
749
  const started = await signIn.startSignIn({ noBrowser: rest.includes("--no-browser") });
@@ -744,6 +759,16 @@ async function runSignIn(rest, startedMs) {
744
759
  next: SIGN_IN_WAIT }, 0);
745
760
  }
746
761
 
762
+ /** The downloaded `probe`, asked again while the budget lasts when the download finished (`done`). */
763
+ async function findDownloadedProbe(done, startedMs) {
764
+ const until = startedMs + agentRun.AGENT_BUDGET_MS - WAIT_RESERVE_MS;
765
+ for (;;) {
766
+ const probe = findProbe(AGENT_MIN_CLI);
767
+ if (probe || !done || done.state !== download.DownloadState.DONE || Date.now() >= until) return probe;
768
+ await sleep(DOWNLOAD_POLL_MS);
769
+ }
770
+ }
771
+
747
772
  /** `sign-in --wait`: the download first (within the budget), then the CLI polls for the approval. */
748
773
  async function waitForSignIn(json, startedMs) {
749
774
  if (!signIn.loadPending()) {
@@ -760,7 +785,13 @@ async function waitForSignIn(json, startedMs) {
760
785
  const record = download.loadDownload();
761
786
  if (!record || record.state === download.DownloadState.FAILED) startBackgroundDownload();
762
787
  const done = await waitForRunningDownload(startedMs);
763
- probe = findProbe(AGENT_MIN_CLI);
788
+ probe = await findDownloadedProbe(done, startedMs);
789
+ if (!probe && done && done.state === download.DownloadState.DONE) {
790
+ // Installed, but its `probe` did not answer yet: the Probe service it just started restarts
791
+ // once for its first update, and `probe --version` goes through it (PR3b dry run, 1 in 4).
792
+ agentRun.refuse(agentRun.Reason.DOWNLOADING, "Probe is finishing its install: run the same command again.",
793
+ agentRun.EXIT_AGAIN);
794
+ }
764
795
  if (!probe) {
765
796
  agentRun.refuse(agentRun.Reason.INCOMPLETE,
766
797
  `Probe did not download (${(done && done.error) || "no probe command after it"}); ` +
package/lib/agent-run.js CHANGED
@@ -29,6 +29,7 @@ const Reason = Object.freeze({
29
29
  SIGN_IN_EXPIRED: "sign_in_expired",
30
30
  INCOMPLETE: "incomplete",
31
31
  RUN_AGAIN: "run_again",
32
+ HOSTED_AGENT: "hosted_agent",
32
33
  });
33
34
  /** Exit statuses: 75 means "run the same command again" (the CLI's `AGENT_EXIT_CODES`). */
34
35
  const EXIT_AGAIN = 75;
package/lib/sign-in.js CHANGED
@@ -37,6 +37,16 @@ const AGENT_MARKERS = Object.freeze([
37
37
  ["kimi_code", ["PROBE_KIMI_SESSION_ID"], "PROBE_KIMI_SESSION_ID"],
38
38
  ["cursor_agent", ["CURSOR_AGENT"], "CURSOR_CONVERSATION_ID"],
39
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
+ ]);
40
50
  /** How long the code request may take before the sign-in says it could not start. */
41
51
  const START_TIMEOUT_MS = 10000;
42
52
  const DEFAULT_BASE = "https://api.research.prbe.ai";
@@ -75,6 +85,19 @@ function detectAgent(env) {
75
85
  return null;
76
86
  }
77
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
+
78
101
  /** The body of the agent's device request (the fixture's keys, nothing else). */
79
102
  function buildRequestBody({ challenge, deviceInstanceId, agent = null }) {
80
103
  const body = {
@@ -136,8 +159,9 @@ function openBrowser(url, env) {
136
159
  }
137
160
 
138
161
  /**
139
- * Ask for a code, keep the secret half, open the tab: `{ok, attempt, user_code,
140
- * verification_uri_complete, expires_in, browser_opened}`, or `{ok: false, message}`.
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}`.
141
165
  */
142
166
  async function startSignIn({ env = process.env, fetchImpl = fetch, noBrowser = false } = {}) {
143
167
  const base = getSignInBase(env);
@@ -176,6 +200,7 @@ async function startSignIn({ env = process.env, fetchImpl = fetch, noBrowser = f
176
200
  savePrivate(path.join(getStateFolder(), PENDING_NAME), JSON.stringify(pending));
177
201
  const opened = noBrowser ? false : openBrowser(data.verification_uri_complete, env);
178
202
  return {
203
+ say: getSayLine(data.verification_uri_complete, data.user_code),
179
204
  ok: true,
180
205
  attempt,
181
206
  user_code: data.user_code,
@@ -204,8 +229,11 @@ module.exports = {
204
229
  STATE_FOLDER,
205
230
  START_PATH,
206
231
  TOKEN_NAME_PREFIX,
232
+ HOSTED_AGENTS,
207
233
  buildRequestBody,
208
234
  detectAgent,
235
+ findHostedAgent,
236
+ getSayLine,
209
237
  getSignInBase,
210
238
  getStateFolder,
211
239
  loadPending,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "probe-research",
3
- "version": "0.17.0",
3
+ "version": "0.19.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"