@youdie006/prodex 0.21.1 → 0.21.2
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/dist/chatgpt-browser.js +26 -1
- package/package.json +1 -1
package/dist/chatgpt-browser.js
CHANGED
|
@@ -1998,13 +1998,38 @@ export async function sendChatGptPrompt(options) {
|
|
|
1998
1998
|
}
|
|
1999
1999
|
throw acceptanceTimeoutError({ timeoutMs, composerStillHasText, submitButtonFound });
|
|
2000
2000
|
}
|
|
2001
|
+
// Pin the conversation the prompt actually landed in. The browser is shared
|
|
2002
|
+
// (other agents, the user, tooling), and a tab that moves mid-wait made
|
|
2003
|
+
// prodex read a DIFFERENT conversation and save it as this consult's answer -
|
|
2004
|
+
// silently, with a receipt (caught live). Nothing about that is recoverable
|
|
2005
|
+
// after the fact, so the wait either stays on this thread or fails loudly.
|
|
2006
|
+
const pinnedThreadUrl = finalState?.url;
|
|
2007
|
+
let recoveredNavigations = 0;
|
|
2001
2008
|
const answerIsStable = createChatGptAnswerStabilityTracker();
|
|
2002
2009
|
while (Date.now() - started < timeoutMs) {
|
|
2003
2010
|
await sleep(1000);
|
|
2004
2011
|
try {
|
|
2005
2012
|
finalState = await evaluateOnPage(page, answerExpression());
|
|
2013
|
+
if (pinnedThreadUrl && finalState?.url && !chatGptUrlsReferToSameTarget(finalState.url, pinnedThreadUrl)) {
|
|
2014
|
+
if (recoveredNavigations >= 2) {
|
|
2015
|
+
throw new ChatGptBrowserBlockerError({
|
|
2016
|
+
code: "thread_navigated_away",
|
|
2017
|
+
message: "The browser tab was moved to a different ChatGPT conversation while this consult was waiting for its answer.",
|
|
2018
|
+
retryable: true,
|
|
2019
|
+
next_step: `Keep the dedicated browser on the consult thread, then fetch the answer with \`prodex pro browser recover --target-url ${pinnedThreadUrl}\`.`,
|
|
2020
|
+
thread: pinnedThreadUrl
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
recoveredNavigations += 1;
|
|
2024
|
+
sendWarnings.push(`thread_navigated_away_recovered: something moved the tab to another conversation mid-wait; prodex navigated back to ${pinnedThreadUrl}.`);
|
|
2025
|
+
await evaluateOnPage(page, `location.assign(${JSON.stringify(pinnedThreadUrl)})`);
|
|
2026
|
+
await sleep(3_000);
|
|
2027
|
+
continue;
|
|
2028
|
+
}
|
|
2006
2029
|
}
|
|
2007
|
-
catch {
|
|
2030
|
+
catch (error) {
|
|
2031
|
+
if (error instanceof ChatGptBrowserBlockerError)
|
|
2032
|
+
throw error;
|
|
2008
2033
|
// Transient CDP failure while the answer is streaming: retry. A throw here
|
|
2009
2034
|
// would discard an already-streamed partial answer and skip the salvage
|
|
2010
2035
|
// path below, so keep the last good state and poll again until timeout.
|