probe-research 0.17.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 +25 -2
- package/lib/agent-run.js +1 -0
- package/lib/sign-in.js +30 -2
- package/package.json +1 -1
package/bin/probe-research.js
CHANGED
|
@@ -124,8 +124,10 @@ 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.
|
|
127
129
|
*/
|
|
128
|
-
const AGENT_MIN_CLI = "0.
|
|
130
|
+
const AGENT_MIN_CLI = "0.421.0";
|
|
129
131
|
/** `install` flags only AGENT_MIN_CLI knows (D36). */
|
|
130
132
|
const AGENT_INSTALL_FLAGS = Object.freeze(["--recommended", "--who-records", "--session-default", "--profile",
|
|
131
133
|
"--attempt"]);
|
|
@@ -729,6 +731,11 @@ async function runSignIn(rest, startedMs) {
|
|
|
729
731
|
await sendUnsupportedPlatform(process.env);
|
|
730
732
|
process.exit(1);
|
|
731
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
|
+
}
|
|
732
739
|
if (rest.includes("--wait")) return waitForSignIn(rest.includes("--json"), startedMs);
|
|
733
740
|
if (hasBarrier()) await finishStoppedUninstall(deadlineMs);
|
|
734
741
|
const started = await signIn.startSignIn({ noBrowser: rest.includes("--no-browser") });
|
|
@@ -744,6 +751,16 @@ async function runSignIn(rest, startedMs) {
|
|
|
744
751
|
next: SIGN_IN_WAIT }, 0);
|
|
745
752
|
}
|
|
746
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
|
+
|
|
747
764
|
/** `sign-in --wait`: the download first (within the budget), then the CLI polls for the approval. */
|
|
748
765
|
async function waitForSignIn(json, startedMs) {
|
|
749
766
|
if (!signIn.loadPending()) {
|
|
@@ -760,7 +777,13 @@ async function waitForSignIn(json, startedMs) {
|
|
|
760
777
|
const record = download.loadDownload();
|
|
761
778
|
if (!record || record.state === download.DownloadState.FAILED) startBackgroundDownload();
|
|
762
779
|
const done = await waitForRunningDownload(startedMs);
|
|
763
|
-
probe =
|
|
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
|
+
}
|
|
764
787
|
if (!probe) {
|
|
765
788
|
agentRun.refuse(agentRun.Reason.INCOMPLETE,
|
|
766
789
|
`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}
|
|
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,
|