@youdie006/prodex 0.26.0 → 0.26.1
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 +25 -0
- package/dist/cli-pro.js +13 -2
- package/package.json +1 -1
package/dist/chatgpt-browser.js
CHANGED
|
@@ -990,6 +990,31 @@ export function openChatGptBrowser(options = {}) {
|
|
|
990
990
|
}
|
|
991
991
|
};
|
|
992
992
|
}
|
|
993
|
+
/**
|
|
994
|
+
* Open a ChatGPT tab in the already-running dedicated Chrome.
|
|
995
|
+
*
|
|
996
|
+
* Reported from a live machine: Chrome was up but had no chatgpt.com tab, so
|
|
997
|
+
* login reused it ("no new window opened"), told the user to finish logging in
|
|
998
|
+
* "in the opened window", and then blocked forever on a tab that nobody was
|
|
999
|
+
* going to create. Opening it is the whole fix.
|
|
1000
|
+
*/
|
|
1001
|
+
export async function openChatGptTab(port = DEFAULT_CDP_PORT, url = "https://chatgpt.com/") {
|
|
1002
|
+
const endpoint = `http://127.0.0.1:${port}/json/new?${encodeURIComponent(url)}`;
|
|
1003
|
+
// Chrome moved /json/new from GET to PUT; try the current verb first and fall
|
|
1004
|
+
// back so this keeps working on either.
|
|
1005
|
+
for (const method of ["PUT", "GET"]) {
|
|
1006
|
+
try {
|
|
1007
|
+
const response = await fetch(endpoint, { method, signal: AbortSignal.timeout(5_000) });
|
|
1008
|
+
if (response.ok)
|
|
1009
|
+
return true;
|
|
1010
|
+
}
|
|
1011
|
+
catch {
|
|
1012
|
+
// Try the next verb, then give up quietly: the caller keeps polling and
|
|
1013
|
+
// the user can still open the tab by hand.
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
993
1018
|
export async function getChatGptBrowserStatus(options = {}) {
|
|
994
1019
|
const port = resolveCdpPort(options.port);
|
|
995
1020
|
const page = await findChatGptPage(port, options.timeoutMs ?? 1500);
|
package/dist/cli-pro.js
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync, statSync } from "node:fs";
|
|
|
2
2
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { buildDryRunBundle } from "./bundle.js";
|
|
5
|
-
import { DEFAULT_CDP_PORT, resolveCdpPort, chatGptVisibilityBlocker, defaultChatGptProfileDir, formatDurationMs, getChatGptBrowserStatus, listChatGptModelOptions, listChatGptSidebarProjects, normalizeChatGptTargetUrl, openChatGptBrowser, parseProMode, parseReasoningEffort, defaultTimeoutForTools, ensureVirtualDisplay, minimizeChatGptWindow, readLastBrowserLoginLaunch, resolveVirtualDisplayPreference, resolveBrowserWindowMode, resolveHeadlessPreference, recordBrowserLoginLaunch, recoverChatGptAnswerFromThread, sendChatGptPrompt } from "./chatgpt-browser.js";
|
|
5
|
+
import { DEFAULT_CDP_PORT, resolveCdpPort, chatGptVisibilityBlocker, defaultChatGptProfileDir, formatDurationMs, getChatGptBrowserStatus, listChatGptModelOptions, listChatGptSidebarProjects, normalizeChatGptTargetUrl, openChatGptBrowser, openChatGptTab, parseProMode, parseReasoningEffort, defaultTimeoutForTools, ensureVirtualDisplay, minimizeChatGptWindow, readLastBrowserLoginLaunch, resolveVirtualDisplayPreference, resolveBrowserWindowMode, resolveHeadlessPreference, recordBrowserLoginLaunch, recoverChatGptAnswerFromThread, sendChatGptPrompt } from "./chatgpt-browser.js";
|
|
6
6
|
import { ASK_PRO_BOOLEAN_FLAGS, ASK_PRO_PREVIEW_VALUE_FLAGS, ASK_PRO_VALUE_FLAGS, assertHelpRequestArgs, assertNoExtraArgs, assertOnlyOptions, findHelpFlagIndexBeforePromptDelimiter, formatCliCommand, hasAskProDryRunMode, hasAskProMode, hasAskProSendMode, isHelpSubcommand, parseAskProArgs, printHelpIfRequested, readFlag, readPortFlag, readPositionalsWithOptions, readNonNegativeIntegerFlag, readPositiveIntegerFlag, readRepeatedFlag, resolveCwdFlag, resolveOptionalFileFlag, unknownSubcommandError } from "./cli-args.js";
|
|
7
7
|
import { printProBrowserHelp, printProHelp } from "./cli-help.js";
|
|
8
8
|
import { listRawResultsForInspection, listTasksForInspection } from "./cli-ledger.js";
|
|
@@ -1302,13 +1302,24 @@ export async function waitForChatGptLoginReady(stderr, options, deps = {}) {
|
|
|
1302
1302
|
const statusFn = deps.statusFn ?? getChatGptBrowserStatus;
|
|
1303
1303
|
const sleepFn = deps.sleepFn ?? sleep;
|
|
1304
1304
|
const now = deps.now ?? Date.now;
|
|
1305
|
+
const openTabFn = deps.openTabFn ?? openChatGptTab;
|
|
1305
1306
|
const timeoutMs = options.timeoutMs ?? 300_000;
|
|
1306
1307
|
const pollMs = options.pollMs ?? 2_000;
|
|
1307
1308
|
const startedAt = now();
|
|
1308
|
-
stderr("login: waiting for a logged-in ChatGPT tab (finish login in the
|
|
1309
|
+
stderr("login: waiting for a logged-in ChatGPT tab (finish login in the dedicated Chrome window; Ctrl+C stops waiting)...");
|
|
1309
1310
|
let lastState = "";
|
|
1311
|
+
let openedMissingTab = false;
|
|
1310
1312
|
while (now() - startedAt < timeoutMs) {
|
|
1311
1313
|
const status = await statusFn({ port: options.port, timeoutMs: 1_500 });
|
|
1314
|
+
// A running Chrome with no chatgpt.com tab leaves the user nothing to log
|
|
1315
|
+
// into. Open the tab once rather than waiting for one to appear.
|
|
1316
|
+
if (status.reachable && status.blocker?.code === "chatgpt_page_missing" && !openedMissingTab) {
|
|
1317
|
+
openedMissingTab = true;
|
|
1318
|
+
stderr("login: the running Chrome had no ChatGPT tab - opening a ChatGPT tab in it...");
|
|
1319
|
+
await openTabFn(options.port);
|
|
1320
|
+
await sleepFn(pollMs);
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1312
1323
|
const state = !status.reachable
|
|
1313
1324
|
? "login: browser starting..."
|
|
1314
1325
|
: status.blocker
|