@xcanwin/manyoyo 5.11.8 → 5.11.10

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.
@@ -437,6 +437,58 @@ class PlaywrightPlugin {
437
437
  this.writeStdout('}');
438
438
  }
439
439
 
440
+ remoteDebuggingPageUrl() {
441
+ return 'chrome://inspect/#remote-debugging';
442
+ }
443
+
444
+ openChromeRemoteDebuggingPage() {
445
+ const url = this.remoteDebuggingPageUrl();
446
+ const platform = process.platform;
447
+ let commands = [];
448
+
449
+ if (platform === 'darwin') {
450
+ commands = [
451
+ ['open', '-a', 'Google Chrome', url],
452
+ ['open', url]
453
+ ];
454
+ } else if (platform === 'win32') {
455
+ commands = [
456
+ ['cmd', '/c', 'start', '', 'chrome', url]
457
+ ];
458
+ } else {
459
+ commands = [
460
+ ['google-chrome', url],
461
+ ['google-chrome-stable', url],
462
+ ['chromium', url],
463
+ ['chromium-browser', url]
464
+ ];
465
+ }
466
+
467
+ for (const args of commands) {
468
+ const result = this.runCmd(args, { check: false, captureOutput: true });
469
+ if (result.returncode === 0) {
470
+ return true;
471
+ }
472
+ }
473
+ return false;
474
+ }
475
+
476
+ remindDevHostCliSessionScene() {
477
+ this.writeStdout(`[tip] 已尝试用 Chrome 打开 ${this.remoteDebuggingPageUrl()},请在页面中确认 remote debugging 相关勾选项已启用。`);
478
+ this.writeStdout('[tip] 如果希望容器内 manyoyo run 自动附着到宿主机正在运行的 Chrome,请在 ~/.manyoyo/manyoyo.json 中设置:');
479
+ this.writeStdout('{');
480
+ this.writeStdout(' "volumes": [');
481
+ this.writeStdout(' "~/.manyoyo/.cache/ms-playwright:/root/.cache/ms-playwright",');
482
+ this.writeStdout(' "~/Library/Application Support/Google/Chrome/DevToolsActivePort:/root/Library/Application Support/Google/Chrome/DevToolsActivePort"');
483
+ this.writeStdout(' ],');
484
+ this.writeStdout(' "plugins": {');
485
+ this.writeStdout(' "playwright": {');
486
+ this.writeStdout(' "cliSessionScene": "dev-host-headed"');
487
+ this.writeStdout(' }');
488
+ this.writeStdout(' }');
489
+ this.writeStdout('}');
490
+ }
491
+
440
492
  randomAlnum(length = 16) {
441
493
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
442
494
  let out = '';
@@ -1092,6 +1144,7 @@ class PlaywrightPlugin {
1092
1144
  const hostConfigPath = this.sceneCliAttachConfigPath(sceneName);
1093
1145
  const containerConfigPath = `/tmp/manyoyo-playwright/${sceneName}.cli-attach.json`;
1094
1146
  this.writeSceneCliAttachConfig(sceneName, {
1147
+ outputDir: '/tmp/.playwright-cli',
1095
1148
  browser: {
1096
1149
  // launch-server(非 shared)不预创建 context;remoteEndpoint 存在时
1097
1150
  // playwright-cli 默认 isolated=false 会走 contexts()[0] 并报
@@ -1120,6 +1173,7 @@ class PlaywrightPlugin {
1120
1173
  const containerConfigPath = `/tmp/manyoyo-playwright/${sceneName}.cli-attach.json`;
1121
1174
 
1122
1175
  this.writeSceneCliAttachConfig(sceneName, {
1176
+ outputDir: '/tmp/.playwright-cli',
1123
1177
  browser: {
1124
1178
  cdpEndpoint,
1125
1179
  cdpHeaders: {
@@ -1445,13 +1499,19 @@ class PlaywrightPlugin {
1445
1499
  return 1;
1446
1500
  }
1447
1501
 
1448
- startDevHost(sceneName) {
1502
+ async startDevHost(sceneName) {
1503
+ this.openChromeRemoteDebuggingPage();
1449
1504
  try {
1450
1505
  const endpoint = this.readDevToolsActivePort();
1506
+ if (!(await this.portReady(endpoint.port))) {
1507
+ throw new Error(`DevToolsActivePort 指向 127.0.0.1:${endpoint.port},但该端口不可连接;请确认 Chrome remote debugging 已启用,或重新打开 Chrome 后再试。`);
1508
+ }
1451
1509
  this.writeStdout(`[up] ${sceneName} ready via DevToolsActivePort (${endpoint.filePath}, 127.0.0.1:${endpoint.port})`);
1510
+ this.remindDevHostCliSessionScene();
1452
1511
  return 0;
1453
1512
  } catch (error) {
1454
1513
  this.writeStderr(`[up] ${sceneName} failed: ${error.message || String(error)}`);
1514
+ this.remindDevHostCliSessionScene();
1455
1515
  return 1;
1456
1516
  }
1457
1517
  }
@@ -1734,6 +1794,7 @@ class PlaywrightPlugin {
1734
1794
  }
1735
1795
 
1736
1796
  const scenes = this.resolveTargets('all').filter(sceneName => isMcpScene(sceneName));
1797
+ this.writeStdout('# 在容器中执行');
1737
1798
  for (const sceneName of scenes) {
1738
1799
  const url = `http://${host}:${this.scenePort(sceneName)}/mcp`;
1739
1800
  this.writeStdout(`claude mcp add -t http -s user playwright-${sceneName} ${url}`);
@@ -1754,6 +1815,7 @@ class PlaywrightPlugin {
1754
1815
 
1755
1816
  printCliAdd() {
1756
1817
  const lines = [
1818
+ '# 在宿主机中执行',
1757
1819
  'PLAYWRIGHT_CLI_INSTALL_DIR="${TMPDIR:-/tmp}/manyoyo-playwright-cli-install-$$"',
1758
1820
  'mkdir -p "$PLAYWRIGHT_CLI_INSTALL_DIR/.playwright"',
1759
1821
  'cd "$PLAYWRIGHT_CLI_INSTALL_DIR"',
@@ -1781,7 +1843,7 @@ class PlaywrightPlugin {
1781
1843
  const def = SCENE_DEFS[sceneName];
1782
1844
  if (isDevScene(sceneName)) {
1783
1845
  if (action === 'up') {
1784
- return this.startDevHost(sceneName);
1846
+ return await this.startDevHost(sceneName);
1785
1847
  }
1786
1848
  if (action === 'down') {
1787
1849
  return this.stopDevHost(sceneName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcanwin/manyoyo",
3
- "version": "5.11.8",
3
+ "version": "5.11.10",
4
4
  "imageVersion": "1.9.1-common",
5
5
  "playwrightCliVersion": "0.1.14",
6
6
  "description": "AI Agent CLI Security Sandbox for Docker and Podman",