@taole/dd-playwright 0.1.3 → 0.1.5
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/bin/cli.mjs +1 -0
- package/bin/mcp-server.mjs +2 -1
- package/package.json +1 -1
- package/src/auth/diandian-auth.mjs +2 -1
- package/src/server/web-server.mjs +3 -0
- package/src/windows-hide-patch.mjs +28 -0
package/bin/cli.mjs
CHANGED
package/bin/mcp-server.mjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* stdio MCP: 独立 Playwright 浏览器自动化服务。
|
|
4
4
|
* 自动注入 SQLite 中激活的点点测试账号 storageState,托管隔离 whistle 代理。
|
|
5
5
|
*/
|
|
6
|
+
import "../src/windows-hide-patch.mjs";
|
|
6
7
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
8
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
9
|
import * as z from "zod/v4";
|
|
@@ -10,7 +11,7 @@ import { resolveConfig } from "../src/config.mjs";
|
|
|
10
11
|
import { PlaywrightBrowserManager } from "../src/browser-manager.mjs";
|
|
11
12
|
import { pathToFileURL } from "node:url";
|
|
12
13
|
|
|
13
|
-
export const MCP_VERSION = "0.1.
|
|
14
|
+
export const MCP_VERSION = "0.1.5";
|
|
14
15
|
|
|
15
16
|
function textResult(payload) {
|
|
16
17
|
return {
|
package/package.json
CHANGED
|
@@ -45,7 +45,8 @@ export class DiandianAuthManager {
|
|
|
45
45
|
this.startupPromise = (async () => {
|
|
46
46
|
await this.close();
|
|
47
47
|
await ensureChromiumInstalled();
|
|
48
|
-
|
|
48
|
+
// 后台扫码会话无论用户全局配置如何,始终以 headless: true 运行,避免弹窗
|
|
49
|
+
const instance = await this.chromium.launch({ headless: true });
|
|
49
50
|
const ctx = await instance.newContext({
|
|
50
51
|
userAgent:
|
|
51
52
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { AccountStore } from "../account-store.mjs";
|
|
4
5
|
import { DiandianAuthManager } from "../auth/diandian-auth.mjs";
|
|
5
6
|
import { getChromiumMetadata } from "../browser-check.mjs";
|
|
6
7
|
|
|
@@ -389,7 +390,9 @@ const DASHBOARD_HTML = `<!DOCTYPE html>
|
|
|
389
390
|
• 表单填写使用 <code>browser_fill_text</code>,按键使用 <code>browser_press_key</code>。
|
|
390
391
|
</div>
|
|
391
392
|
</div>
|
|
393
|
+
</div>
|
|
392
394
|
</div>
|
|
395
|
+
|
|
393
396
|
<!-- TAB 4: 全局配置 -->
|
|
394
397
|
<div id="pane-settings" class="tab-pane">
|
|
395
398
|
<div class="card">
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import cp from "node:child_process";
|
|
2
|
+
|
|
3
|
+
let patched = false;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 在 Windows 环境下给 child_process.spawn 增加 windowsHide: true 补丁。
|
|
7
|
+
* 防止 Playwright 在启动 chromium / chrome-headless-shell 时闪现 Windows 控制台黑框。
|
|
8
|
+
*/
|
|
9
|
+
export function patchWindowsHide() {
|
|
10
|
+
if (patched || process.platform !== "win32") return;
|
|
11
|
+
patched = true;
|
|
12
|
+
|
|
13
|
+
const originalSpawn = cp.spawn;
|
|
14
|
+
cp.spawn = function (command, args, options) {
|
|
15
|
+
if (options && typeof options === "object") {
|
|
16
|
+
if (options.windowsHide === undefined) {
|
|
17
|
+
options.windowsHide = true;
|
|
18
|
+
}
|
|
19
|
+
} else if (Array.isArray(args) && !options) {
|
|
20
|
+
// spawn(command, args)
|
|
21
|
+
return originalSpawn.call(this, command, args, { windowsHide: true });
|
|
22
|
+
}
|
|
23
|
+
return originalSpawn.apply(this, arguments);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 自动在加载时执行补丁
|
|
28
|
+
patchWindowsHide();
|