@jonathanleelx/meddle 0.5.0-beta.24 → 0.5.0-beta.26
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/README.md +1 -1
- package/bin/commands/route/add.js +98 -86
- package/bin/commands/route/delete.js +48 -25
- package/bin/commands/route/index.js +16 -2
- package/bin/commands/route/update.js +118 -87
- package/bin/index.js +7 -3
- package/bin/lib/output.js +4 -2
- package/bin/lib/route-write-args.js +150 -0
- package/dist/core/browser.d.ts +8 -1
- package/dist/core/browser.d.ts.map +1 -1
- package/dist/core/browser.js +239 -36
- package/dist/core/browser.js.map +1 -1
- package/dist/server/agent/tools.d.ts.map +1 -1
- package/dist/server/agent/tools.js +2 -1
- package/dist/server/agent/tools.js.map +1 -1
- package/index.js +3 -2
- package/package.json +1 -1
- package/web/dist/assets/{detail-panel-D56nCma2.js → detail-panel-CyOc7gn8.js} +1 -1
- package/web/dist/assets/{global-panel-shell-SKPshqTf.js → global-panel-shell-jXQTb9nw.js} +1 -1
- package/web/dist/assets/{health-panel-CvI-VsvG.js → health-panel-CSV7OqBv.js} +1 -1
- package/web/dist/assets/{index-Dcm171u1.js → index-CSXxaYkG.js} +2 -2
- package/web/dist/assets/{mobile-proxy-panel-cpkvsdBT.js → mobile-proxy-panel-a09S-R79.js} +1 -1
- package/web/dist/assets/{mock-config-CtZ866iI.js → mock-config-D_E5YOE_.js} +1 -1
- package/web/dist/assets/{mock-editor-panel-CweYBdeM.js → mock-editor-panel-t4TDXeaR.js} +1 -1
- package/web/dist/assets/{mocks-file-missing-note-C-QJ8Bpm.js → mocks-file-missing-note-Ddy1TdMX.js} +1 -1
- package/web/dist/assets/{monaco-editor-Cge8h-Ca.js → monaco-editor-GpPLOKA5.js} +1 -1
- package/web/dist/assets/{pane-bar-Dvi-MHuB.js → pane-bar-zJmE3xI5.js} +1 -1
- package/web/dist/assets/{pane-split-ChCHxR7K.js → pane-split-CJ1VXJDy.js} +1 -1
- package/web/dist/assets/{panel-heading-Crmy9fo0.js → panel-heading-DlFWoYAR.js} +1 -1
- package/web/dist/assets/{plugin-code-editor-VaL2lVyD.js → plugin-code-editor-CtaamKWJ.js} +1 -1
- package/web/dist/assets/{plugin-config-DSiOk77l.js → plugin-config-Dg_FCb-L.js} +2 -2
- package/web/dist/assets/{plugin-generator-iAksMY2Q.js → plugin-generator-CVREuZs7.js} +1 -1
- package/web/dist/assets/{plugin-test-dialog-Cx6ifDnm.js → plugin-test-dialog-B-iV8ocm.js} +1 -1
- package/web/dist/assets/{route-preview-T0s6si4V.js → route-preview-CLJeg_9v.js} +1 -1
- package/web/dist/assets/{rule-ai-assistant-panel-DzfobTWM.js → rule-ai-assistant-panel-BvTqm4zV.js} +1 -1
- package/web/dist/assets/{rule-config-ESpfkJg6.js → rule-config-DmNPaKxc.js} +1 -1
- package/web/dist/assets/{rule-overview-panel-BswSByar.js → rule-overview-panel-CB9b-b0t.js} +1 -1
- package/web/dist/assets/{settings-panel-Cj-1Z8Ow.js → settings-panel-DLdeJ8ox.js} +1 -1
- package/web/dist/index.html +1 -1
package/bin/index.js
CHANGED
|
@@ -59,7 +59,7 @@ if (command === 'mock' || command === 'route' || command === 'session') {
|
|
|
59
59
|
// No command or only flags - start proxy (default behavior)
|
|
60
60
|
require('../index.js')
|
|
61
61
|
} else {
|
|
62
|
-
console.
|
|
62
|
+
console.error(`Unknown command: ${command}`)
|
|
63
63
|
showHelp()
|
|
64
64
|
process.exit(1)
|
|
65
65
|
}
|
|
@@ -106,8 +106,10 @@ Route 命令:
|
|
|
106
106
|
meddle route active 查看当前激活的路由文件
|
|
107
107
|
meddle route active set <file> 设置激活的路由文件
|
|
108
108
|
meddle route create <name> 创建路由文件
|
|
109
|
-
meddle route add <file> <pattern> <target>
|
|
110
|
-
|
|
109
|
+
meddle route add <file> <pattern> <target> [--exclusions=]
|
|
110
|
+
添加路由规则;--exclusions= 清空排除项
|
|
111
|
+
meddle route update <file> <pattern> [<target>] [--exclusions=]
|
|
112
|
+
更新路由规则;--exclusions= 清空排除项
|
|
111
113
|
meddle route delete <file> <pattern> 删除路由规则
|
|
112
114
|
|
|
113
115
|
全局选项:
|
|
@@ -137,6 +139,8 @@ Route 命令:
|
|
|
137
139
|
meddle route preview "https://api.example.com/v1/users" # 预览转发目标
|
|
138
140
|
meddle route preview "https://cdn.com/assets/js/app.js" --file dev-rules --json
|
|
139
141
|
meddle route add dev-rules "api.test.com" "localhost:3000"
|
|
142
|
+
meddle route add dev-rules "api.test.com" "localhost:3000" --exclusions=
|
|
143
|
+
meddle route update dev-rules "api.test.com" --exclusions=
|
|
140
144
|
meddle route active set beta-rules
|
|
141
145
|
|
|
142
146
|
更多信息请访问: https://github.com/JonathanLee-LX/meddle
|
package/bin/lib/output.js
CHANGED
|
@@ -51,11 +51,13 @@ function success(message) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Print
|
|
54
|
+
* Print a command failure. Human-readable text goes to stderr so stdout stays
|
|
55
|
+
* empty on error. In --json mode this is a no-op; the caller prints the
|
|
56
|
+
* `{ success: false }` object on stdout.
|
|
55
57
|
*/
|
|
56
58
|
function error(message) {
|
|
57
59
|
if (jsonMode) return
|
|
58
|
-
console.
|
|
60
|
+
console.error(chalk.red(' ✗'), message)
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/**
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Argument parsing for `meddle route add|update|delete` (issue #149).
|
|
3
|
+
*
|
|
4
|
+
* `--exclusions=` clears a rule's exclusions. `--exclusions=/a,/b` replaces
|
|
5
|
+
* them. A bare `--exclusions`, an unknown flag, or an empty `!` token used to
|
|
6
|
+
* be ignored and the command still exited 0 without changing exclusions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { splitPatternArg } = require('./rule-file-edit')
|
|
10
|
+
|
|
11
|
+
class RouteArgError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message)
|
|
14
|
+
this.name = 'RouteArgError'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const CLEAR_HINT = 'To clear exclusions, pass --exclusions= (empty). To replace them, pass --exclusions=/a,/b.'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} raw value after `=`
|
|
22
|
+
* @returns {string[]}
|
|
23
|
+
*/
|
|
24
|
+
function parseExclusionList(raw) {
|
|
25
|
+
const value = String(raw).trim()
|
|
26
|
+
if (value === '') return []
|
|
27
|
+
const pieces = value.includes(',') ? value.split(',') : value.split(/\s+/)
|
|
28
|
+
const out = []
|
|
29
|
+
for (const piece of pieces) {
|
|
30
|
+
const token = piece.trim()
|
|
31
|
+
if (!token) {
|
|
32
|
+
throw new RouteArgError(`Invalid --exclusions: empty entry. ${CLEAR_HINT}`)
|
|
33
|
+
}
|
|
34
|
+
const body = token.startsWith('!') ? token.slice(1).trim() : token
|
|
35
|
+
if (!body) {
|
|
36
|
+
throw new RouteArgError(`Invalid --exclusions: "!" needs a path, for example --exclusions=/health. ${CLEAR_HINT}`)
|
|
37
|
+
}
|
|
38
|
+
out.push(body)
|
|
39
|
+
}
|
|
40
|
+
return out
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {string[]} args argv after the subcommand
|
|
45
|
+
* @param {{ allowExclusions?: boolean }} [options]
|
|
46
|
+
* @returns {{ help: boolean, json: boolean, positional: string[], exclusions: string[] | undefined }}
|
|
47
|
+
* `exclusions` is undefined when the flag was not passed. `[]` means clear.
|
|
48
|
+
*/
|
|
49
|
+
function parseRouteWriteArgs(args, { allowExclusions = true } = {}) {
|
|
50
|
+
let help = false
|
|
51
|
+
let json = false
|
|
52
|
+
/** @type {string[] | undefined} */
|
|
53
|
+
let exclusions
|
|
54
|
+
let sawExclusions = false
|
|
55
|
+
const positional = []
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
const arg = args[i]
|
|
59
|
+
if (arg === '--help' || arg === '-h') {
|
|
60
|
+
help = true
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
63
|
+
if (arg === '--json') {
|
|
64
|
+
json = true
|
|
65
|
+
continue
|
|
66
|
+
}
|
|
67
|
+
if (arg === '--exclusions' || arg.startsWith('--exclusions=')) {
|
|
68
|
+
if (!allowExclusions) {
|
|
69
|
+
throw new RouteArgError(`Unsupported option: ${arg === '--exclusions' ? '--exclusions' : '--exclusions='}. route delete does not change exclusions.`)
|
|
70
|
+
}
|
|
71
|
+
if (arg === '--exclusions') {
|
|
72
|
+
throw new RouteArgError(`Unsupported option: --exclusions. ${CLEAR_HINT}`)
|
|
73
|
+
}
|
|
74
|
+
if (sawExclusions) throw new RouteArgError('--exclusions was given more than once.')
|
|
75
|
+
sawExclusions = true
|
|
76
|
+
exclusions = parseExclusionList(arg.slice('--exclusions='.length))
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
if (arg.startsWith('-')) {
|
|
80
|
+
throw new RouteArgError(`Unsupported option: ${arg}.`)
|
|
81
|
+
}
|
|
82
|
+
positional.push(arg)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { help, json, positional, exclusions: sawExclusions ? exclusions : undefined }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Split a pattern argument the way the CLI always has (`"host !/api"`), but
|
|
90
|
+
* refuse a bare `!` — that used to be dropped and looked like a successful clear.
|
|
91
|
+
* @returns {{ patterns: string[], exclusions: string[] }}
|
|
92
|
+
*/
|
|
93
|
+
function parsePatternArg(raw) {
|
|
94
|
+
const parts = String(raw).trim().split(/\s+/).filter(Boolean)
|
|
95
|
+
for (const part of parts) {
|
|
96
|
+
if (part.startsWith('!') && part.slice(1).trim() === '') {
|
|
97
|
+
throw new RouteArgError('Invalid exclusion "!": a "!" token needs a path such as "!/api". To clear exclusions, pass --exclusions=.')
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return splitPatternArg(raw)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {string[]} patternExclusions exclusions parsed from !path tokens
|
|
105
|
+
* @param {string[] | undefined} flagExclusions undefined when --exclusions was omitted
|
|
106
|
+
* @returns {{ explicit: boolean, exclusions: string[] | undefined }}
|
|
107
|
+
*/
|
|
108
|
+
function resolveExclusions(patternExclusions, flagExclusions) {
|
|
109
|
+
if (flagExclusions !== undefined && patternExclusions.length > 0) {
|
|
110
|
+
throw new RouteArgError('Pass exclusions either as !path tokens in the pattern or with --exclusions, not both.')
|
|
111
|
+
}
|
|
112
|
+
if (flagExclusions !== undefined) return { explicit: true, exclusions: flagExclusions }
|
|
113
|
+
if (patternExclusions.length > 0) return { explicit: true, exclusions: patternExclusions }
|
|
114
|
+
return { explicit: false, exclusions: undefined }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const UPDATE_HELP = `
|
|
118
|
+
meddle route update <file> <pattern> [<target>] [--exclusions=<list>] [--json]
|
|
119
|
+
|
|
120
|
+
Update a rule. Edits only the line(s) that hold the pattern; every other line
|
|
121
|
+
stays byte-for-byte, including comments, blank lines and other rules' !path.
|
|
122
|
+
|
|
123
|
+
--exclusions= Clear this rule's exclusions (the line loses !path).
|
|
124
|
+
--exclusions=/a,/b Replace exclusions. Spaces work inside quotes
|
|
125
|
+
(--exclusions="/a /b"). A leading ! is optional.
|
|
126
|
+
"pattern !/a !/b" Replace exclusions (same as before). Omit both
|
|
127
|
+
--exclusions and !path to keep existing exclusions.
|
|
128
|
+
|
|
129
|
+
The <target> may be omitted when --exclusions is set; the current target stays.
|
|
130
|
+
A bare --exclusions, an empty "!" token, an unknown flag, or both exclusion
|
|
131
|
+
forms at once exits 1 and does not change the file.
|
|
132
|
+
|
|
133
|
+
A "#" comments out a whole line only when it is the first non-space character.
|
|
134
|
+
A "#" later on a rule line is a pattern token, not a trailing comment.
|
|
135
|
+
|
|
136
|
+
Examples:
|
|
137
|
+
meddle route update dev "api.example.com" "localhost:4000"
|
|
138
|
+
meddle route update dev "api.example.com" --exclusions=
|
|
139
|
+
meddle route update dev "api.example.com" "localhost:4000" --exclusions=/health
|
|
140
|
+
`
|
|
141
|
+
|
|
142
|
+
module.exports = {
|
|
143
|
+
CLEAR_HINT,
|
|
144
|
+
RouteArgError,
|
|
145
|
+
UPDATE_HELP,
|
|
146
|
+
parseExclusionList,
|
|
147
|
+
parsePatternArg,
|
|
148
|
+
parseRouteWriteArgs,
|
|
149
|
+
resolveExclusions,
|
|
150
|
+
}
|
package/dist/core/browser.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import * as os from 'os';
|
|
2
|
+
type Platform = ReturnType<typeof os.platform>;
|
|
3
|
+
/** Name of a browser this machine can launch (`google-chrome`, `Google Chrome`, …), or null. */
|
|
4
|
+
export declare function findInstalledBrowser(platform?: Platform): string | null;
|
|
5
|
+
/** Stop browsers opened by this process. Tests call this from afterAll. */
|
|
6
|
+
export declare function closeLaunchedBrowsers(): void;
|
|
7
|
+
export declare function openBrowserWithProxy(url: string, proxyServer: string, meddleDir: string, remoteDebuggingPort?: number): Promise<boolean>;
|
|
8
|
+
export {};
|
|
2
9
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../core/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../core/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAmBxB,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAA;AAgC9C,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,QAAwB,GAAG,MAAM,GAAG,IAAI,CAStF;AAwCD,2EAA2E;AAC3E,wBAAgB,qBAAqB,IAAI,IAAI,CAM5C;AA2GD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB9I"}
|
package/dist/core/browser.js
CHANGED
|
@@ -36,57 +36,260 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.findInstalledBrowser = findInstalledBrowser;
|
|
40
|
+
exports.closeLaunchedBrowsers = closeLaunchedBrowsers;
|
|
39
41
|
exports.openBrowserWithProxy = openBrowserWithProxy;
|
|
40
42
|
const os = __importStar(require("os"));
|
|
41
43
|
const path = __importStar(require("path"));
|
|
42
44
|
const fs = __importStar(require("fs"));
|
|
43
45
|
const child_process_1 = require("child_process");
|
|
44
46
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
// Linux `execSync('google-chrome …')` waits until Chrome exits. Chrome does not
|
|
48
|
+
// exit, so the caller — including the Vitest worker in tests/browser.spec.ts —
|
|
49
|
+
// blocks forever and the test timeout never fires (#130). Spawn instead. A
|
|
50
|
+
// process that is still alive after a short grace period is open. Exit 0 is
|
|
51
|
+
// also success: Chrome hands the URL to an existing window with the same
|
|
52
|
+
// profile and quits. A non-zero exit is a failed start. Kill anything that
|
|
53
|
+
// fails to start or that tests ask us to close.
|
|
54
|
+
const BROWSER_GRACE_MS = 500;
|
|
55
|
+
const LAUNCHER_TIMEOUT_MS = 2000;
|
|
56
|
+
const launched = [];
|
|
57
|
+
const profiles = [];
|
|
58
|
+
function browserCandidates(platform) {
|
|
59
|
+
if (platform === 'darwin')
|
|
60
|
+
return ['Google Chrome', 'Microsoft Edge', 'Chromium'];
|
|
61
|
+
if (platform === 'win32')
|
|
62
|
+
return ['chrome', 'msedge', 'chromium'];
|
|
63
|
+
return ['google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser'];
|
|
64
|
+
}
|
|
65
|
+
function commandOnPath(name) {
|
|
66
|
+
const directories = (process.env.PATH || '').split(path.delimiter).filter(Boolean);
|
|
67
|
+
const suffixes = process.platform === 'win32'
|
|
68
|
+
? (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';')
|
|
69
|
+
: [''];
|
|
70
|
+
for (const directory of directories) {
|
|
71
|
+
for (const suffix of suffixes) {
|
|
72
|
+
const candidate = path.join(directory, name + suffix);
|
|
73
|
+
try {
|
|
74
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
75
|
+
return candidate;
|
|
67
76
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return true;
|
|
77
|
+
catch {
|
|
78
|
+
// try the next directory
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function darwinAppExists(app) {
|
|
85
|
+
const roots = ['/Applications', path.join(os.homedir(), 'Applications')];
|
|
86
|
+
return roots.some((root) => fs.existsSync(path.join(root, `${app}.app`)));
|
|
87
|
+
}
|
|
88
|
+
/** Name of a browser this machine can launch (`google-chrome`, `Google Chrome`, …), or null. */
|
|
89
|
+
function findInstalledBrowser(platform = os.platform()) {
|
|
90
|
+
for (const app of browserCandidates(platform)) {
|
|
91
|
+
if (platform === 'darwin') {
|
|
92
|
+
if (darwinAppExists(app))
|
|
93
|
+
return app;
|
|
74
94
|
continue;
|
|
75
95
|
}
|
|
96
|
+
if (commandOnPath(app))
|
|
97
|
+
return app;
|
|
76
98
|
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function killPid(pid) {
|
|
77
102
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
(0, child_process_1.execSync)(`start "" "${url}"`, { stdio: 'ignore' });
|
|
82
|
-
else
|
|
83
|
-
(0, child_process_1.execSync)(`xdg-open "${url}"`, { stdio: 'ignore' });
|
|
84
|
-
console.log(chalk_1.default.yellow('未找到 Chrome/Edge,已用默认浏览器打开,请手动设置代理:', proxyServer));
|
|
85
|
-
return true;
|
|
103
|
+
// detached: true puts the child in its own process group, so this also
|
|
104
|
+
// stops Chrome helpers spawned from it.
|
|
105
|
+
process.kill(-pid, 'SIGKILL');
|
|
86
106
|
}
|
|
87
|
-
catch
|
|
88
|
-
|
|
107
|
+
catch {
|
|
108
|
+
try {
|
|
109
|
+
process.kill(pid, 'SIGKILL');
|
|
110
|
+
}
|
|
111
|
+
catch { /* already exited */ }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function forget(child) {
|
|
115
|
+
const index = launched.indexOf(child);
|
|
116
|
+
if (index >= 0)
|
|
117
|
+
launched.splice(index, 1);
|
|
118
|
+
if (child.pid)
|
|
119
|
+
killPid(child.pid);
|
|
120
|
+
}
|
|
121
|
+
function killProcessesUsingProfile(dir) {
|
|
122
|
+
if (process.platform === 'win32')
|
|
123
|
+
return;
|
|
124
|
+
let output = '';
|
|
125
|
+
try {
|
|
126
|
+
output = (0, child_process_1.execFileSync)('ps', ['-Aww', '-o', 'pid=', '-o', 'args='], {
|
|
127
|
+
encoding: 'utf8',
|
|
128
|
+
timeout: 2000,
|
|
129
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
for (const line of output.split('\n')) {
|
|
136
|
+
if (!line.includes(dir))
|
|
137
|
+
continue;
|
|
138
|
+
const match = /^\s*(\d+)\s/.exec(line);
|
|
139
|
+
if (!match)
|
|
140
|
+
continue;
|
|
141
|
+
const pid = Number(match[1]);
|
|
142
|
+
if (!pid || pid === process.pid)
|
|
143
|
+
continue;
|
|
144
|
+
try {
|
|
145
|
+
process.kill(pid, 'SIGKILL');
|
|
146
|
+
}
|
|
147
|
+
catch { /* already exited */ }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** Stop browsers opened by this process. Tests call this from afterAll. */
|
|
151
|
+
function closeLaunchedBrowsers() {
|
|
152
|
+
for (const child of launched.splice(0)) {
|
|
153
|
+
if (!child.pid || child.exitCode !== null || child.signalCode !== null)
|
|
154
|
+
continue;
|
|
155
|
+
killPid(child.pid);
|
|
156
|
+
}
|
|
157
|
+
for (const dir of profiles.splice(0))
|
|
158
|
+
killProcessesUsingProfile(dir);
|
|
159
|
+
}
|
|
160
|
+
function spawnTracked(command, args, shell = false) {
|
|
161
|
+
try {
|
|
162
|
+
const child = (0, child_process_1.spawn)(command, args, {
|
|
163
|
+
detached: true,
|
|
164
|
+
stdio: 'ignore',
|
|
165
|
+
windowsHide: true,
|
|
166
|
+
shell,
|
|
167
|
+
});
|
|
168
|
+
// 'error' is async (ENOENT). A listener is required so Node does not
|
|
169
|
+
// throw it as an unhandled error after we have already moved on.
|
|
170
|
+
child.on('error', () => { });
|
|
171
|
+
launched.push(child);
|
|
172
|
+
return child;
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Browser binaries stay in the foreground. Still running after the grace
|
|
180
|
+
* period means opened. Exit 0 also means opened: a second Chrome with the
|
|
181
|
+
* same profile hands the URL to the existing window and quits.
|
|
182
|
+
*/
|
|
183
|
+
function launchDetached(command, args) {
|
|
184
|
+
return new Promise((resolve) => {
|
|
185
|
+
const child = spawnTracked(command, args);
|
|
186
|
+
if (!child) {
|
|
187
|
+
resolve(false);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
let settled = false;
|
|
191
|
+
let timer;
|
|
192
|
+
const finish = (ok) => {
|
|
193
|
+
if (settled)
|
|
194
|
+
return;
|
|
195
|
+
settled = true;
|
|
196
|
+
if (timer)
|
|
197
|
+
clearTimeout(timer);
|
|
198
|
+
if (ok) {
|
|
199
|
+
// Already exited (handoff). Drop it so a later cleanup cannot
|
|
200
|
+
// signal a recycled pid. A process that is still running stays
|
|
201
|
+
// tracked so tests can close it.
|
|
202
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
203
|
+
const index = launched.indexOf(child);
|
|
204
|
+
if (index >= 0)
|
|
205
|
+
launched.splice(index, 1);
|
|
206
|
+
}
|
|
207
|
+
child.unref();
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
forget(child);
|
|
211
|
+
}
|
|
212
|
+
resolve(ok);
|
|
213
|
+
};
|
|
214
|
+
timer = setTimeout(() => {
|
|
215
|
+
finish(child.exitCode === null && child.signalCode === null);
|
|
216
|
+
}, BROWSER_GRACE_MS);
|
|
217
|
+
child.once('error', () => finish(false));
|
|
218
|
+
child.once('exit', (code) => finish(code === 0));
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/** `open`, `start`, and `xdg-open` are supposed to exit. Kill them if they do not. */
|
|
222
|
+
function launchExiting(command, args, shell = false) {
|
|
223
|
+
return new Promise((resolve) => {
|
|
224
|
+
const child = spawnTracked(command, args, shell);
|
|
225
|
+
if (!child) {
|
|
226
|
+
resolve(false);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
let settled = false;
|
|
230
|
+
let timer;
|
|
231
|
+
const finish = (ok) => {
|
|
232
|
+
if (settled)
|
|
233
|
+
return;
|
|
234
|
+
settled = true;
|
|
235
|
+
if (timer)
|
|
236
|
+
clearTimeout(timer);
|
|
237
|
+
if (ok) {
|
|
238
|
+
const index = launched.indexOf(child);
|
|
239
|
+
if (index >= 0)
|
|
240
|
+
launched.splice(index, 1);
|
|
241
|
+
child.unref();
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
forget(child);
|
|
245
|
+
}
|
|
246
|
+
resolve(ok);
|
|
247
|
+
};
|
|
248
|
+
timer = setTimeout(() => finish(false), LAUNCHER_TIMEOUT_MS);
|
|
249
|
+
child.once('error', () => finish(false));
|
|
250
|
+
child.once('exit', (code) => finish(code === 0));
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
async function launchCandidate(platform, app, argList, url) {
|
|
254
|
+
if (platform === 'darwin') {
|
|
255
|
+
return launchExiting('open', ['-a', app, '--args', ...argList, url]);
|
|
256
|
+
}
|
|
257
|
+
if (platform === 'win32') {
|
|
258
|
+
return launchExiting('cmd.exe', ['/c', 'start', '', app, ...argList, url]);
|
|
259
|
+
}
|
|
260
|
+
const command = commandOnPath(app);
|
|
261
|
+
if (!command)
|
|
89
262
|
return false;
|
|
263
|
+
return launchDetached(command, [...argList, url]);
|
|
264
|
+
}
|
|
265
|
+
function launchFallback(platform, url) {
|
|
266
|
+
if (platform === 'darwin')
|
|
267
|
+
return launchExiting('open', [url]);
|
|
268
|
+
if (platform === 'win32')
|
|
269
|
+
return launchExiting('cmd.exe', ['/c', 'start', '', url]);
|
|
270
|
+
return launchExiting('xdg-open', [url]);
|
|
271
|
+
}
|
|
272
|
+
async function openBrowserWithProxy(url, proxyServer, meddleDir, remoteDebuggingPort) {
|
|
273
|
+
const platform = os.platform();
|
|
274
|
+
const userDataDir = path.join(meddleDir, 'chrome-proxy');
|
|
275
|
+
fs.mkdirSync(userDataDir, { recursive: true });
|
|
276
|
+
profiles.push(userDataDir);
|
|
277
|
+
const argList = [
|
|
278
|
+
`--user-data-dir=${userDataDir}`,
|
|
279
|
+
`--proxy-server=${proxyServer}`,
|
|
280
|
+
'--window-size=1920,1080',
|
|
281
|
+
];
|
|
282
|
+
if (remoteDebuggingPort)
|
|
283
|
+
argList.push(`--remote-debugging-port=${remoteDebuggingPort}`);
|
|
284
|
+
for (const app of browserCandidates(platform)) {
|
|
285
|
+
if (await launchCandidate(platform, app, argList, url))
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
if (await launchFallback(platform, url)) {
|
|
289
|
+
console.log(chalk_1.default.yellow('未找到 Chrome/Edge,已用默认浏览器打开,请手动设置代理:', proxyServer));
|
|
290
|
+
return true;
|
|
90
291
|
}
|
|
292
|
+
console.error(chalk_1.default.red('浏览器并未启动:'), 'no supported browser found');
|
|
293
|
+
return false;
|
|
91
294
|
}
|
|
92
295
|
//# sourceMappingURL=browser.js.map
|
package/dist/core/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../core/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../core/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,oDASC;AAyCD,sDAMC;AA2GD,oDAuBC;AA9OD,uCAAwB;AACxB,2CAA4B;AAC5B,uCAAwB;AACxB,iDAAsE;AACtE,kDAAyB;AAEzB,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,gDAAgD;AAChD,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAC5B,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC,MAAM,QAAQ,GAAmB,EAAE,CAAA;AACnC,MAAM,QAAQ,GAAa,EAAE,CAAA;AAI7B,SAAS,iBAAiB,CAAC,QAAkB;IACzC,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,eAAe,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAA;IACjF,IAAI,QAAQ,KAAK,OAAO;QAAE,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,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,oCAAoC,EAAE,WAAW,CAAC,CAAC,CAAA;QAC5E,OAAO,IAAI,CAAA;IACf,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,4BAA4B,CAAC,CAAA;IAClE,OAAO,KAAK,CAAA;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../server/agent/tools.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAoB,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE/E,KAAK,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../server/agent/tools.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAoB,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAE/E,KAAK,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AA+qC1C,wBAAgB,gBAAgB,IAAI,YAAY,CA2B/C;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,mBAAmB,EAAE,CAS5E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY;;;;;;IAQrD"}
|
|
@@ -526,12 +526,13 @@ function createRouteRuleUpdateTool() {
|
|
|
526
526
|
const normalized = normalizeRouteRuleUpdateInput(input);
|
|
527
527
|
const next = buildRouteRuleUpdateContent(normalized, ctx);
|
|
528
528
|
return {
|
|
529
|
-
summary: `更新路由规则:${normalized.pattern}`,
|
|
529
|
+
summary: `更新路由规则:${normalized.pattern} -> ${next.newTarget}`,
|
|
530
530
|
diff: buildRouteRuleUpdateDiff(normalized, next),
|
|
531
531
|
preview: {
|
|
532
532
|
ruleFile: normalized.ruleFile,
|
|
533
533
|
pattern: normalized.pattern,
|
|
534
534
|
target: next.newTarget,
|
|
535
|
+
newTarget: next.newTarget,
|
|
535
536
|
exclusions: next.exclusions,
|
|
536
537
|
},
|
|
537
538
|
input: normalized,
|