ask-pro 0.1.47 → 0.1.48
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.
|
@@ -100,6 +100,8 @@ async function waitForAssistantResponseOnce(Runtime, timeoutMs, logger, minTurnI
|
|
|
100
100
|
const winner = await Promise.race([raceReadyEvaluation, pollerPromise]);
|
|
101
101
|
if (winner.kind === "poll") {
|
|
102
102
|
if (!winner.value) {
|
|
103
|
+
evaluationPromise.catch(() => undefined);
|
|
104
|
+
await terminateRuntimeExecution(Runtime);
|
|
103
105
|
throw { source: "poll", error: new Error(ASSISTANT_POLL_TIMEOUT_ERROR) };
|
|
104
106
|
}
|
|
105
107
|
logger("Captured assistant response via snapshot watchdog");
|
|
@@ -120,7 +122,7 @@ async function waitForAssistantResponseOnce(Runtime, timeoutMs, logger, minTurnI
|
|
|
120
122
|
if (source === "poll" &&
|
|
121
123
|
error instanceof Error &&
|
|
122
124
|
error.message === ASSISTANT_POLL_TIMEOUT_ERROR) {
|
|
123
|
-
|
|
125
|
+
throw new Error("Timed out waiting for assistant response");
|
|
124
126
|
}
|
|
125
127
|
else if (source === "poll") {
|
|
126
128
|
pollerAbort.abort();
|
|
@@ -20,7 +20,7 @@ import { CHATGPT_URL, CONVERSATION_TURN_SELECTOR, DEFAULT_MODEL_STRATEGY } from
|
|
|
20
20
|
import { AssistantStoppedError, BrowserAutomationError } from "./errors.js";
|
|
21
21
|
import { defaultAskProBrowserProfileDir } from "./profilePaths.js";
|
|
22
22
|
import { applyPageLanguageOverrides, seedChromeProfileLanguage } from "./language.js";
|
|
23
|
-
import { alignPromptEchoPair, buildPromptEchoMatcher, withTimeout } from "./reattachHelpers.js";
|
|
23
|
+
import { alignPromptEchoPair, buildPromptEchoMatcher, extractConversationIdFromUrl, withTimeout, } from "./reattachHelpers.js";
|
|
24
24
|
import { cleanupStaleProfileState, acquireProfileRunLock, createManagedChromeRunLease, releaseManagedChromeRunLeaseAndCountPeers, readDevToolsPort, shouldCleanupManualLoginProfileState, verifyDevToolsReachable, writeChromePid, writeDevToolsActivePort, } from "./profileState.js";
|
|
25
25
|
import { runProviderSubmissionFlow } from "./providerDomFlow.js";
|
|
26
26
|
import { chatgptDomProvider } from "./providers/chatgptDomProvider.js";
|
|
@@ -2369,7 +2369,9 @@ export const __test__ = {
|
|
|
2369
2369
|
isLoginRecoveryUrl,
|
|
2370
2370
|
isEligibleManualLoginRecoveryTarget,
|
|
2371
2371
|
isRecoveredTargetOwned,
|
|
2372
|
+
isConversationUrl,
|
|
2372
2373
|
waitForLogin,
|
|
2374
|
+
waitForAssistantResponseWithReload,
|
|
2373
2375
|
};
|
|
2374
2376
|
export { syncCookies } from "./cookies.js";
|
|
2375
2377
|
export { navigateToChatGPT, ensureNotBlocked, ensurePromptReady, ensureModelSelection, submitPrompt, waitForAssistantResponse, captureAssistantMarkdown, uploadAttachmentFile, waitForAttachmentCompletion, } from "./pageActions.js";
|
|
@@ -2382,6 +2384,7 @@ export function isWebSocketClosureError(error) {
|
|
|
2382
2384
|
message.includes("target closed"));
|
|
2383
2385
|
}
|
|
2384
2386
|
async function waitForAssistantResponseWithReload(Runtime, Page, timeoutMs, logger, minTurnIndex, expectedConversationUrl, expectedConversationId, continueResponse) {
|
|
2387
|
+
const deadline = Date.now() + timeoutMs;
|
|
2385
2388
|
try {
|
|
2386
2389
|
return await waitForAssistantResponse(Runtime, timeoutMs, logger, minTurnIndex, expectedConversationId, continueResponse);
|
|
2387
2390
|
}
|
|
@@ -2393,10 +2396,13 @@ async function waitForAssistantResponseWithReload(Runtime, Page, timeoutMs, logg
|
|
|
2393
2396
|
if (!conversationUrl || !isConversationUrl(conversationUrl)) {
|
|
2394
2397
|
throw error;
|
|
2395
2398
|
}
|
|
2399
|
+
const remainingMs = deadline - Date.now();
|
|
2400
|
+
if (remainingMs <= 0)
|
|
2401
|
+
throw error;
|
|
2396
2402
|
logger("Assistant response stalled; reloading conversation and retrying once");
|
|
2397
2403
|
await Page.navigate({ url: conversationUrl });
|
|
2398
2404
|
await delay(1000);
|
|
2399
|
-
return await waitForAssistantResponse(Runtime,
|
|
2405
|
+
return await waitForAssistantResponse(Runtime, Math.max(1, deadline - Date.now()), logger, minTurnIndex, expectedConversationId, continueResponse);
|
|
2400
2406
|
}
|
|
2401
2407
|
}
|
|
2402
2408
|
function shouldReloadAfterAssistantError(error) {
|
|
@@ -2561,7 +2567,7 @@ async function readConversationTurnCount(Runtime, logger) {
|
|
|
2561
2567
|
return null;
|
|
2562
2568
|
}
|
|
2563
2569
|
function isConversationUrl(url) {
|
|
2564
|
-
return
|
|
2570
|
+
return Boolean(extractConversationIdFromUrl(url));
|
|
2565
2571
|
}
|
|
2566
2572
|
function describeDevtoolsFirewallHint(host, port) {
|
|
2567
2573
|
if (!isWsl())
|
|
@@ -2583,10 +2589,6 @@ function isWsl() {
|
|
|
2583
2589
|
return true;
|
|
2584
2590
|
return os.release().toLowerCase().includes("microsoft");
|
|
2585
2591
|
}
|
|
2586
|
-
function extractConversationIdFromUrl(url) {
|
|
2587
|
-
const match = url.match(/\/c\/([a-zA-Z0-9-]+)/);
|
|
2588
|
-
return match?.[1];
|
|
2589
|
-
}
|
|
2590
2592
|
async function resolveUserDataBaseDir() {
|
|
2591
2593
|
// On WSL, Chrome launched via Windows can choke on UNC paths; prefer a Windows-backed temp folder.
|
|
2592
2594
|
if (isWsl()) {
|
|
@@ -89,6 +89,9 @@ async function closeManagedChromeIfUnused(chrome, userDataDir, inspectRemainingP
|
|
|
89
89
|
await cleanupStaleProfileState(userDataDir, logger, { lockRemovalMode: "never" }).catch(() => undefined);
|
|
90
90
|
}
|
|
91
91
|
export async function resumeBrowserSession(runtime, config, logger, deps = {}) {
|
|
92
|
+
if (runtime.conversationId === "WEB" && runtime.tabUrl?.includes("/c/WEB:")) {
|
|
93
|
+
runtime = { ...runtime, conversationId: undefined, tabUrl: undefined };
|
|
94
|
+
}
|
|
92
95
|
deps = { ...deps, continuationState: deps.continuationState ?? { used: false } };
|
|
93
96
|
const recoverSession = deps.recoverSession ??
|
|
94
97
|
(async (runtimeMeta, configMeta) => resumeBrowserSessionViaNewChrome(runtimeMeta, configMeta, logger, deps));
|
|
@@ -21,12 +21,12 @@ export function pickTarget(targets, runtime) {
|
|
|
21
21
|
export function extractConversationIdFromUrl(url) {
|
|
22
22
|
if (!url)
|
|
23
23
|
return undefined;
|
|
24
|
-
const match = url.match(/\/c\/([a-zA-Z0-9-]+)/);
|
|
24
|
+
const match = url.match(/\/c\/([a-zA-Z0-9-]+)(?:[/?#]|$)/);
|
|
25
25
|
return match?.[1];
|
|
26
26
|
}
|
|
27
27
|
export function buildConversationUrl(runtime, baseUrl) {
|
|
28
28
|
if (runtime.tabUrl) {
|
|
29
|
-
if (runtime.tabUrl
|
|
29
|
+
if (extractConversationIdFromUrl(runtime.tabUrl)) {
|
|
30
30
|
return runtime.tabUrl;
|
|
31
31
|
}
|
|
32
32
|
return null;
|