rechrome 1.8.1 → 1.9.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/package.json +1 -1
- package/rech.js +30 -23
- package/rech.ts +30 -23
- package/serve.js +5 -0
- package/serve.ts +5 -0
package/package.json
CHANGED
package/rech.js
CHANGED
|
@@ -535,15 +535,19 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
|
|
|
535
535
|
const url = await getOrCreateUrl();
|
|
536
536
|
const { host, port, protocol } = parseUrl(url);
|
|
537
537
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
538
|
+
const { key: serveKey } = parseUrl(url);
|
|
539
|
+
const authPing = await fetch(`${protocol}://${host}:${port}/ping`, {
|
|
540
|
+
headers: { Authorization: `Bearer ${serveKey}` },
|
|
541
|
+
signal: AbortSignal.timeout(2000),
|
|
542
|
+
}).catch(() => null);
|
|
543
|
+
if (authPing?.ok) {
|
|
544
|
+
console.log(` Already running at ${protocol}://${host}:${port} — skipping reinstall`);
|
|
545
|
+
await runOxmgr(["service", "install"]);
|
|
543
546
|
} else {
|
|
544
547
|
await daemonInstall(url);
|
|
545
548
|
console.log(` Registered daemon: ${OXMGR_PROCESS_NAME}`);
|
|
546
549
|
process.stdout.write(" Starting");
|
|
550
|
+
let ping = null;
|
|
547
551
|
for (let i = 0; i < 15; i++) {
|
|
548
552
|
await Bun.sleep(1000);
|
|
549
553
|
ping = await fetch(`${protocol}://${host}:${port}/`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
|
|
@@ -635,16 +639,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
|
|
|
635
639
|
const { extId, token } = primary;
|
|
636
640
|
const profileEmail = profileInfoSel.user_name || profileDir;
|
|
637
641
|
|
|
638
|
-
//
|
|
639
|
-
const pwdEnvPath = join(process.cwd(), ".env.local");
|
|
640
|
-
const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
|
|
641
|
-
const homeEnvPath = join(process.env.HOME!, ".env.local");
|
|
642
|
-
const saveChoice = (await ask(
|
|
643
|
-
`\n[4/4] Save RECHROME_URL to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n\n Choice [1]: `
|
|
644
|
-
)).trim();
|
|
645
|
-
const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
|
|
646
|
-
if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
|
|
647
|
-
const existing = await file(globalEnvPath).text().catch(() => "");
|
|
642
|
+
// Build RECHROME_URL and show it before asking where to save
|
|
648
643
|
const rechUrl = new URL(url);
|
|
649
644
|
if (!rechUrl.username) rechUrl.username = randomBytes(9).toString("base64url");
|
|
650
645
|
rechUrl.searchParams.set("extension_id", extId);
|
|
@@ -652,14 +647,26 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
|
|
|
652
647
|
rechUrl.searchParams.set("profile", profileEmail);
|
|
653
648
|
if (userDataDir) rechUrl.searchParams.set("user_data_dir", userDataDir);
|
|
654
649
|
const newLine = `RECHROME_URL=${rechUrl.toString()}`;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
650
|
+
console.log(`\n[4/4] Your RECHROME_URL:\n\n ${newLine}\n`);
|
|
651
|
+
|
|
652
|
+
const pwdEnvPath = join(process.cwd(), ".env.local");
|
|
653
|
+
const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
|
|
654
|
+
const homeEnvPath = join(process.env.HOME!, ".env.local");
|
|
655
|
+
const saveChoice = (await ask(
|
|
656
|
+
`Save to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n 4. Skip (already copied)\n\n Choice [1]: `
|
|
657
|
+
)).trim();
|
|
658
|
+
if (saveChoice !== "4") {
|
|
659
|
+
const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
|
|
660
|
+
if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
|
|
661
|
+
const existing = await file(globalEnvPath).text().catch(() => "");
|
|
662
|
+
const keysToRemove = ["PLAYWRIGHT_MCP_USER_DATA_DIR", "PLAYWRIGHT_MCP_EXTENSION_ID", "PLAYWRIGHT_MCP_EXTENSION_TOKEN", "PLAYWRIGHT_MCP_PROFILE_DIRECTORY"];
|
|
663
|
+
let lines = existing.trimEnd().split("\n").filter(l => !keysToRemove.some(k => l.startsWith(`${k}=`)));
|
|
664
|
+
const rechIdx = lines.findIndex(l => l.startsWith("RECHROME_URL="));
|
|
665
|
+
if (rechIdx >= 0) lines[rechIdx] = newLine;
|
|
666
|
+
else lines.push(newLine);
|
|
667
|
+
await Bun.write(globalEnvPath, lines.join("\n").trim() + "\n");
|
|
668
|
+
console.log(`\nSaved to ${globalEnvPath}`);
|
|
669
|
+
}
|
|
663
670
|
|
|
664
671
|
// Save primary to token registry
|
|
665
672
|
await saveTokenEntry(profileEmail, { extensionId: extId, token, profileDir, userDataDir: userDataDir ?? undefined });
|
package/rech.ts
CHANGED
|
@@ -535,15 +535,19 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
|
|
|
535
535
|
const url = await getOrCreateUrl();
|
|
536
536
|
const { host, port, protocol } = parseUrl(url);
|
|
537
537
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
538
|
+
const { key: serveKey } = parseUrl(url);
|
|
539
|
+
const authPing = await fetch(`${protocol}://${host}:${port}/ping`, {
|
|
540
|
+
headers: { Authorization: `Bearer ${serveKey}` },
|
|
541
|
+
signal: AbortSignal.timeout(2000),
|
|
542
|
+
}).catch(() => null);
|
|
543
|
+
if (authPing?.ok) {
|
|
544
|
+
console.log(` Already running at ${protocol}://${host}:${port} — skipping reinstall`);
|
|
545
|
+
await runOxmgr(["service", "install"]);
|
|
543
546
|
} else {
|
|
544
547
|
await daemonInstall(url);
|
|
545
548
|
console.log(` Registered daemon: ${OXMGR_PROCESS_NAME}`);
|
|
546
549
|
process.stdout.write(" Starting");
|
|
550
|
+
let ping = null;
|
|
547
551
|
for (let i = 0; i < 15; i++) {
|
|
548
552
|
await Bun.sleep(1000);
|
|
549
553
|
ping = await fetch(`${protocol}://${host}:${port}/`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
|
|
@@ -635,16 +639,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
|
|
|
635
639
|
const { extId, token } = primary;
|
|
636
640
|
const profileEmail = profileInfoSel.user_name || profileDir;
|
|
637
641
|
|
|
638
|
-
//
|
|
639
|
-
const pwdEnvPath = join(process.cwd(), ".env.local");
|
|
640
|
-
const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
|
|
641
|
-
const homeEnvPath = join(process.env.HOME!, ".env.local");
|
|
642
|
-
const saveChoice = (await ask(
|
|
643
|
-
`\n[4/4] Save RECHROME_URL to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n\n Choice [1]: `
|
|
644
|
-
)).trim();
|
|
645
|
-
const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
|
|
646
|
-
if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
|
|
647
|
-
const existing = await file(globalEnvPath).text().catch(() => "");
|
|
642
|
+
// Build RECHROME_URL and show it before asking where to save
|
|
648
643
|
const rechUrl = new URL(url);
|
|
649
644
|
if (!rechUrl.username) rechUrl.username = randomBytes(9).toString("base64url");
|
|
650
645
|
rechUrl.searchParams.set("extension_id", extId);
|
|
@@ -652,14 +647,26 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
|
|
|
652
647
|
rechUrl.searchParams.set("profile", profileEmail);
|
|
653
648
|
if (userDataDir) rechUrl.searchParams.set("user_data_dir", userDataDir);
|
|
654
649
|
const newLine = `RECHROME_URL=${rechUrl.toString()}`;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
650
|
+
console.log(`\n[4/4] Your RECHROME_URL:\n\n ${newLine}\n`);
|
|
651
|
+
|
|
652
|
+
const pwdEnvPath = join(process.cwd(), ".env.local");
|
|
653
|
+
const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
|
|
654
|
+
const homeEnvPath = join(process.env.HOME!, ".env.local");
|
|
655
|
+
const saveChoice = (await ask(
|
|
656
|
+
`Save to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n 4. Skip (already copied)\n\n Choice [1]: `
|
|
657
|
+
)).trim();
|
|
658
|
+
if (saveChoice !== "4") {
|
|
659
|
+
const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
|
|
660
|
+
if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
|
|
661
|
+
const existing = await file(globalEnvPath).text().catch(() => "");
|
|
662
|
+
const keysToRemove = ["PLAYWRIGHT_MCP_USER_DATA_DIR", "PLAYWRIGHT_MCP_EXTENSION_ID", "PLAYWRIGHT_MCP_EXTENSION_TOKEN", "PLAYWRIGHT_MCP_PROFILE_DIRECTORY"];
|
|
663
|
+
let lines = existing.trimEnd().split("\n").filter(l => !keysToRemove.some(k => l.startsWith(`${k}=`)));
|
|
664
|
+
const rechIdx = lines.findIndex(l => l.startsWith("RECHROME_URL="));
|
|
665
|
+
if (rechIdx >= 0) lines[rechIdx] = newLine;
|
|
666
|
+
else lines.push(newLine);
|
|
667
|
+
await Bun.write(globalEnvPath, lines.join("\n").trim() + "\n");
|
|
668
|
+
console.log(`\nSaved to ${globalEnvPath}`);
|
|
669
|
+
}
|
|
663
670
|
|
|
664
671
|
// Save primary to token registry
|
|
665
672
|
await saveTokenEntry(profileEmail, { extensionId: extId, token, profileDir, userDataDir: userDataDir ?? undefined });
|
package/serve.js
CHANGED
|
@@ -107,6 +107,11 @@ export async function serve() {
|
|
|
107
107
|
return new Response(f);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
if (reqUrl.pathname === "/ping") {
|
|
111
|
+
const denied = authCheck(req, key);
|
|
112
|
+
if (denied) return denied;
|
|
113
|
+
return new Response("ok");
|
|
114
|
+
}
|
|
110
115
|
if (reqUrl.pathname !== "/run") return new Response("rech server\n");
|
|
111
116
|
const denied = authCheck(req, key);
|
|
112
117
|
if (denied) return denied;
|
package/serve.ts
CHANGED
|
@@ -107,6 +107,11 @@ export async function serve() {
|
|
|
107
107
|
return new Response(f);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
if (reqUrl.pathname === "/ping") {
|
|
111
|
+
const denied = authCheck(req, key);
|
|
112
|
+
if (denied) return denied;
|
|
113
|
+
return new Response("ok");
|
|
114
|
+
}
|
|
110
115
|
if (reqUrl.pathname !== "/run") return new Response("rech server\n");
|
|
111
116
|
const denied = authCheck(req, key);
|
|
112
117
|
if (denied) return denied;
|