gm-plugkit 2.0.1719 → 2.0.1720

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1719",
3
+ "version": "2.0.1720",
4
4
  "description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1203,7 +1203,7 @@ function chromeLogHasSandboxDenied(chromeLogPath) {
1203
1203
  }
1204
1204
  }
1205
1205
 
1206
- function spawnChromiumOnce(browserBin, profileDir, port, headless, noSandbox) {
1206
+ function spawnChromiumOnce(browserBin, profileDir, port, headless, noSandbox, cwd) {
1207
1207
  const args = [
1208
1208
  '--user-data-dir=' + profileDir,
1209
1209
  '--remote-debugging-port=' + port,
@@ -1219,7 +1219,7 @@ function spawnChromiumOnce(browserBin, profileDir, port, headless, noSandbox) {
1219
1219
  if (headless) {
1220
1220
  args.push('--headless=new');
1221
1221
  } else {
1222
- args.push('about:blank');
1222
+ args.push(resolveBrowserStartUrl(cwd));
1223
1223
  }
1224
1224
  const chromeLogPath = path.join(profileDir, '.chrome-launch.log');
1225
1225
  let logFd;
@@ -1235,6 +1235,17 @@ function spawnChromiumOnce(browserBin, profileDir, port, headless, noSandbox) {
1235
1235
  return { pid: child.pid, chromeLogPath };
1236
1236
  }
1237
1237
 
1238
+ function resolveBrowserStartUrl(cwd) {
1239
+ if (process.env.GM_BROWSER_START_URL) return process.env.GM_BROWSER_START_URL;
1240
+ try {
1241
+ const root = cwd || process.env.CLAUDE_PROJECT_DIR || process.cwd();
1242
+ const cfgPath = path.join(root, '.gm', 'browser-target-url');
1243
+ const url = fs.readFileSync(cfgPath, 'utf-8').trim();
1244
+ if (url) return url;
1245
+ } catch (_) {}
1246
+ return 'about:blank';
1247
+ }
1248
+
1238
1249
  function waitForCdpReady(port, deadlineMs) {
1239
1250
  const start = Date.now();
1240
1251
  const deadline = start + deadlineMs;
@@ -1246,7 +1257,7 @@ function waitForCdpReady(port, deadlineMs) {
1246
1257
  return null;
1247
1258
  }
1248
1259
 
1249
- function startManagedBrowser(pw, profileDir) {
1260
+ function startManagedBrowser(pw, profileDir, cwd) {
1250
1261
  const rawHeadlessEnv = process.env.GM_BROWSER_HEADLESS;
1251
1262
  const headless = rawHeadlessEnv === '1';
1252
1263
  const unexpectedHeadlessEnv = rawHeadlessEnv !== undefined && rawHeadlessEnv !== '1';
@@ -1278,7 +1289,7 @@ function startManagedBrowser(pw, profileDir) {
1278
1289
  }
1279
1290
  const port = findFreePortSync();
1280
1291
  let noSandbox = process.env.GM_BROWSER_NO_SANDBOX === '1';
1281
- let { pid, chromeLogPath } = spawnChromiumOnce(browserBin, profileDir, port, headless, noSandbox);
1292
+ let { pid, chromeLogPath } = spawnChromiumOnce(browserBin, profileDir, port, headless, noSandbox, cwd);
1282
1293
  logEvent('plugkit', 'browser.chromium-launched', { pid, port, profileDir, headless, noSandbox, binary: browserBin, chromeLogPath });
1283
1294
  let ready = waitForCdpReady(port, 30000);
1284
1295
  if (!ready) {
@@ -1293,7 +1304,7 @@ function startManagedBrowser(pw, profileDir) {
1293
1304
  purgeProfileLockFiles(profileDir);
1294
1305
  noSandbox = true;
1295
1306
  const port2 = findFreePortSync();
1296
- ({ pid, chromeLogPath } = spawnChromiumOnce(browserBin, profileDir, port2, headless, noSandbox));
1307
+ ({ pid, chromeLogPath } = spawnChromiumOnce(browserBin, profileDir, port2, headless, noSandbox, cwd));
1297
1308
  logEvent('plugkit', 'browser.chromium-launched', { pid, port: port2, profileDir, headless, noSandbox, binary: browserBin, chromeLogPath, retry: true });
1298
1309
  ready = waitForCdpReady(port2, 30000);
1299
1310
  if (!ready) {
@@ -1490,7 +1501,7 @@ function getOrCreateBrowserSession(cwd, claudeSessionId, pw) {
1490
1501
  logEvent('plugkit', 'browser.reused-existing-chromium', { pid: browserPid, port, profileDir });
1491
1502
  } else {
1492
1503
  logEvent('plugkit', 'browser.start', { profileDir });
1493
- ({ pid: browserPid, port, wsEndpoint } = startManagedBrowser(pw, profileDir));
1504
+ ({ pid: browserPid, port, wsEndpoint } = startManagedBrowser(pw, profileDir, cwd));
1494
1505
  freshLaunch = true;
1495
1506
  }
1496
1507
  markLaunching(browserPid);