probe-research 0.32.0 → 0.33.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 +33 -3
- package/lib/sign-in.js +1 -0
- package/package.json +1 -1
package/bin/probe-research.js
CHANGED
|
@@ -913,8 +913,28 @@ async function waitForRunningDownload(startedMs, step, watch = null) {
|
|
|
913
913
|
const isRunning = record && record.state === download.DownloadState.RUNNING;
|
|
914
914
|
await updateWatch(watch, step, isRunning ? record.stage || download.DownloadStage.DOWNLOADING : null);
|
|
915
915
|
if (!isRunning) return record;
|
|
916
|
-
|
|
916
|
+
// Not approved yet: the approval is read on to the budget's end, the download with it (fixes-1108b).
|
|
917
|
+
if (Date.now() >= (watch && watch.isPending() ? getWatchEndMs(startedMs) : until)) {
|
|
918
|
+
await refuseUnfinished(step, watch, record.stage || download.DownloadStage.DOWNLOADING);
|
|
919
|
+
}
|
|
920
|
+
await sleep(DOWNLOAD_POLL_MS);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/** When a call still waiting for the approval stops reading it: its last read and its answer inside the budget. */
|
|
925
|
+
function getWatchEndMs(startedMs) {
|
|
926
|
+
return startedMs + agentRun.AGENT_BUDGET_MS - agentRun.CLI_MARGIN_MS - signIn.APPROVAL_TIMEOUT_MS;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Not approved yet, with no time left to hand the CLI anything: the approval is read here until the budget's end,
|
|
931
|
+
* so a call waits for it the whole budget and never answers `waiting_for_approval` early (fixes-1108b). An approval
|
|
932
|
+
* that comes meanwhile while Probe still installs is answered at once, as PR39b's.
|
|
933
|
+
*/
|
|
934
|
+
async function watchUntilBudgetEnd(watch, startedMs, step, stage) {
|
|
935
|
+
while (watch && watch.isPending() && Date.now() + DOWNLOAD_POLL_MS < getWatchEndMs(startedMs)) {
|
|
917
936
|
await sleep(DOWNLOAD_POLL_MS);
|
|
937
|
+
await updateWatch(watch, step, stage);
|
|
918
938
|
}
|
|
919
939
|
}
|
|
920
940
|
|
|
@@ -1042,10 +1062,19 @@ async function waitForSignIn(json, startedMs) {
|
|
|
1042
1062
|
AgentStep.SIGN_IN_WAIT, watch);
|
|
1043
1063
|
}
|
|
1044
1064
|
|
|
1045
|
-
/** Probe installed during the wait (PR39): approved, say so, and hand the CLI the save only with time for it.
|
|
1065
|
+
/** Probe installed during the wait (PR39): approved, say so, and hand the CLI the save only with time for it. Too
|
|
1066
|
+
* little left and not approved yet: the approval is waited for here (fixes-1108b), never handed to a CLI that would
|
|
1067
|
+
* answer `waiting_for_approval` the moment it started. */
|
|
1046
1068
|
async function sayInstalled(watch, startedMs) {
|
|
1047
1069
|
await updateWatch(watch, AgentStep.SIGN_IN_WAIT, approval.InstallStage.DONE);
|
|
1048
|
-
if (
|
|
1070
|
+
if (startedMs + agentRun.AGENT_BUDGET_MS - Date.now() >= APPROVED_RESERVE_MS) return;
|
|
1071
|
+
await watchUntilBudgetEnd(watch, startedMs, AgentStep.SIGN_IN_WAIT, approval.InstallStage.DONE);
|
|
1072
|
+
if (watch.isPending()) {
|
|
1073
|
+
await refuseAgent(AgentStep.SIGN_IN_WAIT, agentRun.Reason.WAITING_FOR_APPROVAL,
|
|
1074
|
+
"Waiting for the browser approval: run this again.", agentRun.EXIT_AGAIN,
|
|
1075
|
+
watch.getRunAgainFacts(approval.InstallStage.DONE));
|
|
1076
|
+
}
|
|
1077
|
+
if (!watch.isApproved()) return;
|
|
1049
1078
|
watch.markSaid(approval.InstallStage.DONE);
|
|
1050
1079
|
await refuseAgent(AgentStep.SIGN_IN_WAIT, agentRun.Reason.RUN_AGAIN,
|
|
1051
1080
|
"Probe is installed, with too little time left to save the sign-in: run the same command again.",
|
|
@@ -1068,6 +1097,7 @@ async function getAgentProbe(startedMs, step, watch = null) {
|
|
|
1068
1097
|
if (!probe && done && done.state === download.DownloadState.DONE) {
|
|
1069
1098
|
// Installed, but its `probe` did not answer yet: the Probe service it just started restarts
|
|
1070
1099
|
// once for its first update, and `probe --version` goes through it (PR3b dry run, 1 in 4).
|
|
1100
|
+
await watchUntilBudgetEnd(watch, startedMs, step, approval.InstallStage.STARTING);
|
|
1071
1101
|
await refuseUnfinished(step, watch, approval.InstallStage.STARTING,
|
|
1072
1102
|
"Probe is finishing its install: run the same command again.");
|
|
1073
1103
|
}
|
package/lib/sign-in.js
CHANGED