@jackwener/opencli 0.7.6 → 0.7.8
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/.agents/skills/cross-project-adapter-migration/SKILL.md +249 -0
- package/.agents/workflows/cross-project-adapter-migration.md +54 -0
- package/dist/browser/discover.d.ts +8 -0
- package/dist/browser/discover.js +83 -0
- package/dist/browser/errors.d.ts +21 -0
- package/dist/browser/errors.js +54 -0
- package/dist/browser/index.d.ts +22 -0
- package/dist/browser/index.js +22 -0
- package/dist/browser/mcp.d.ts +33 -0
- package/dist/browser/mcp.js +304 -0
- package/dist/browser/page.d.ts +41 -0
- package/dist/browser/page.js +142 -0
- package/dist/browser/tabs.d.ts +13 -0
- package/dist/browser/tabs.js +70 -0
- package/dist/browser.test.js +1 -1
- package/dist/completion.js +2 -2
- package/dist/doctor.js +7 -7
- package/dist/engine.js +6 -4
- package/dist/errors.d.ts +25 -0
- package/dist/errors.js +42 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.js +47 -0
- package/dist/main.js +8 -2
- package/dist/pipeline/executor.js +8 -8
- package/dist/pipeline/steps/browser.d.ts +7 -7
- package/dist/pipeline/steps/intercept.d.ts +1 -1
- package/dist/pipeline/steps/tap.d.ts +1 -1
- package/dist/setup.js +1 -1
- package/package.json +3 -3
- package/scripts/clean-yaml.cjs +19 -0
- package/scripts/copy-yaml.cjs +21 -0
- package/scripts/postinstall.js +30 -9
- package/src/bilibili.ts +1 -1
- package/src/browser/discover.ts +90 -0
- package/src/browser/errors.ts +89 -0
- package/src/browser/index.ts +26 -0
- package/src/browser/mcp.ts +305 -0
- package/src/browser/page.ts +152 -0
- package/src/browser/tabs.ts +76 -0
- package/src/browser.test.ts +1 -1
- package/src/completion.ts +2 -2
- package/src/doctor.ts +13 -1
- package/src/engine.ts +9 -4
- package/src/errors.ts +48 -0
- package/src/logger.ts +57 -0
- package/src/main.ts +10 -3
- package/src/pipeline/executor.ts +8 -7
- package/src/pipeline/steps/browser.ts +18 -18
- package/src/pipeline/steps/intercept.ts +8 -8
- package/src/pipeline/steps/tap.ts +2 -2
- package/src/setup.ts +1 -1
- package/tsconfig.json +1 -2
- package/dist/browser.d.ts +0 -105
- package/dist/browser.js +0 -644
- package/src/browser.ts +0 -698
package/src/errors.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified error types for opencli.
|
|
3
|
+
*
|
|
4
|
+
* All errors thrown by the framework should extend CliError so that
|
|
5
|
+
* the top-level handler in main.ts can render consistent, helpful output.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export class CliError extends Error {
|
|
9
|
+
/** Machine-readable error code (e.g. 'BROWSER_CONNECT', 'ADAPTER_LOAD') */
|
|
10
|
+
readonly code: string;
|
|
11
|
+
/** Human-readable hint on how to fix the problem */
|
|
12
|
+
readonly hint?: string;
|
|
13
|
+
|
|
14
|
+
constructor(code: string, message: string, hint?: string) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'CliError';
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.hint = hint;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class BrowserConnectError extends CliError {
|
|
23
|
+
constructor(message: string, hint?: string) {
|
|
24
|
+
super('BROWSER_CONNECT', message, hint);
|
|
25
|
+
this.name = 'BrowserConnectError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class AdapterLoadError extends CliError {
|
|
30
|
+
constructor(message: string, hint?: string) {
|
|
31
|
+
super('ADAPTER_LOAD', message, hint);
|
|
32
|
+
this.name = 'AdapterLoadError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class CommandExecutionError extends CliError {
|
|
37
|
+
constructor(message: string, hint?: string) {
|
|
38
|
+
super('COMMAND_EXEC', message, hint);
|
|
39
|
+
this.name = 'CommandExecutionError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class ConfigError extends CliError {
|
|
44
|
+
constructor(message: string, hint?: string) {
|
|
45
|
+
super('CONFIG', message, hint);
|
|
46
|
+
this.name = 'ConfigError';
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified logging for opencli.
|
|
3
|
+
*
|
|
4
|
+
* All framework output (warnings, debug info, errors) should go through
|
|
5
|
+
* this module so that verbosity levels are respected consistently.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
|
|
10
|
+
function isVerbose(): boolean {
|
|
11
|
+
return !!process.env.OPENCLI_VERBOSE;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isDebug(): boolean {
|
|
15
|
+
return !!process.env.DEBUG?.includes('opencli');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const log = {
|
|
19
|
+
/** Informational message (always shown) */
|
|
20
|
+
info(msg: string): void {
|
|
21
|
+
process.stderr.write(`${chalk.blue('ℹ')} ${msg}\n`);
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** Warning (always shown) */
|
|
25
|
+
warn(msg: string): void {
|
|
26
|
+
process.stderr.write(`${chalk.yellow('⚠')} ${msg}\n`);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/** Error (always shown) */
|
|
30
|
+
error(msg: string): void {
|
|
31
|
+
process.stderr.write(`${chalk.red('✖')} ${msg}\n`);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/** Verbose output (only when OPENCLI_VERBOSE is set or -v flag) */
|
|
35
|
+
verbose(msg: string): void {
|
|
36
|
+
if (isVerbose()) {
|
|
37
|
+
process.stderr.write(`${chalk.dim('[verbose]')} ${msg}\n`);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/** Debug output (only when DEBUG includes 'opencli') */
|
|
42
|
+
debug(msg: string): void {
|
|
43
|
+
if (isDebug()) {
|
|
44
|
+
process.stderr.write(`${chalk.dim('[debug]')} ${msg}\n`);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/** Step-style debug (for pipeline steps, etc.) */
|
|
49
|
+
step(stepNum: number, total: number, op: string, preview: string = ''): void {
|
|
50
|
+
process.stderr.write(` ${chalk.dim(`[${stepNum}/${total}]`)} ${chalk.bold.cyan(op)}${preview}\n`);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/** Step result summary */
|
|
54
|
+
stepResult(summary: string): void {
|
|
55
|
+
process.stderr.write(` ${chalk.dim(`→ ${summary}`)}\n`);
|
|
56
|
+
},
|
|
57
|
+
};
|
package/src/main.ts
CHANGED
|
@@ -11,10 +11,11 @@ import chalk from 'chalk';
|
|
|
11
11
|
import { discoverClis, executeCommand } from './engine.js';
|
|
12
12
|
import { type CliCommand, fullName, getRegistry, strategyLabel } from './registry.js';
|
|
13
13
|
import { render as renderOutput } from './output.js';
|
|
14
|
-
import { PlaywrightMCP } from './browser.js';
|
|
14
|
+
import { PlaywrightMCP } from './browser/index.js';
|
|
15
15
|
import { browserSession, DEFAULT_BROWSER_COMMAND_TIMEOUT, runWithTimeout } from './runtime.js';
|
|
16
16
|
import { PKG_VERSION } from './version.js';
|
|
17
17
|
import { getCompletions, printCompletionScript } from './completion.js';
|
|
18
|
+
import { CliError } from './errors.js';
|
|
18
19
|
|
|
19
20
|
const __filename = fileURLToPath(import.meta.url);
|
|
20
21
|
const __dirname = path.dirname(__filename);
|
|
@@ -212,8 +213,14 @@ for (const [, cmd] of registry) {
|
|
|
212
213
|
}
|
|
213
214
|
renderOutput(result, { fmt: actionOpts.format, columns: cmd.columns, title: `${cmd.site}/${cmd.name}`, elapsed: (Date.now() - startTime) / 1000, source: fullName(cmd) });
|
|
214
215
|
} catch (err: any) {
|
|
215
|
-
if (
|
|
216
|
-
|
|
216
|
+
if (err instanceof CliError) {
|
|
217
|
+
console.error(chalk.red(`Error [${err.code}]: ${err.message}`));
|
|
218
|
+
if (err.hint) console.error(chalk.yellow(`Hint: ${err.hint}`));
|
|
219
|
+
} else if (actionOpts.verbose && err.stack) {
|
|
220
|
+
console.error(chalk.red(err.stack));
|
|
221
|
+
} else {
|
|
222
|
+
console.error(chalk.red(`Error: ${err.message ?? err}`));
|
|
223
|
+
}
|
|
217
224
|
process.exitCode = 1;
|
|
218
225
|
}
|
|
219
226
|
});
|
package/src/pipeline/executor.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { stepFetch } from './steps/fetch.js';
|
|
|
9
9
|
import { stepSelect, stepMap, stepFilter, stepSort, stepLimit } from './steps/transform.js';
|
|
10
10
|
import { stepIntercept } from './steps/intercept.js';
|
|
11
11
|
import { stepTap } from './steps/tap.js';
|
|
12
|
+
import { log } from '../logger.js';
|
|
12
13
|
|
|
13
14
|
export interface PipelineContext {
|
|
14
15
|
args?: Record<string, any>;
|
|
@@ -57,7 +58,7 @@ export async function executePipeline(
|
|
|
57
58
|
if (handler) {
|
|
58
59
|
data = await handler(page, params, data, args);
|
|
59
60
|
} else {
|
|
60
|
-
if (debug)
|
|
61
|
+
if (debug) log.warn(`Unknown step: ${op}`);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
if (debug) debugStepResult(op, data);
|
|
@@ -73,21 +74,21 @@ function debugStepStart(stepNum: number, total: number, op: string, params: any)
|
|
|
73
74
|
} else if (params && typeof params === 'object' && !Array.isArray(params)) {
|
|
74
75
|
preview = ` (${Object.keys(params).join(', ')})`;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
log.step(stepNum, total, op, preview);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
function debugStepResult(op: string, data: any): void {
|
|
80
81
|
if (data === null || data === undefined) {
|
|
81
|
-
|
|
82
|
+
log.stepResult('(no data)');
|
|
82
83
|
} else if (Array.isArray(data)) {
|
|
83
|
-
|
|
84
|
+
log.stepResult(`${data.length} items`);
|
|
84
85
|
} else if (typeof data === 'object') {
|
|
85
86
|
const keys = Object.keys(data).slice(0, 5);
|
|
86
|
-
|
|
87
|
+
log.stepResult(`dict (${keys.join(', ')}${Object.keys(data).length > 5 ? '...' : ''})`);
|
|
87
88
|
} else if (typeof data === 'string') {
|
|
88
89
|
const p = data.slice(0, 60).replace(/\n/g, '\\n');
|
|
89
|
-
|
|
90
|
+
log.stepResult(`"${p}${data.length > 60 ? '...' : ''}"`);
|
|
90
91
|
} else {
|
|
91
|
-
|
|
92
|
+
log.stepResult(`${typeof data}`);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -6,53 +6,53 @@
|
|
|
6
6
|
import type { IPage } from '../../types.js';
|
|
7
7
|
import { render, normalizeEvaluateSource } from '../template.js';
|
|
8
8
|
|
|
9
|
-
export async function stepNavigate(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
9
|
+
export async function stepNavigate(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
10
10
|
const url = render(params, { args, data });
|
|
11
|
-
await page
|
|
11
|
+
await page!.goto(String(url));
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export async function stepClick(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
16
|
-
await page
|
|
15
|
+
export async function stepClick(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
16
|
+
await page!.click(String(render(params, { args, data })).replace(/^@/, ''));
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export async function stepType(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
20
|
+
export async function stepType(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
21
21
|
if (typeof params === 'object' && params) {
|
|
22
22
|
const ref = String(render(params.ref ?? '', { args, data })).replace(/^@/, '');
|
|
23
23
|
const text = String(render(params.text ?? '', { args, data }));
|
|
24
|
-
await page
|
|
25
|
-
if (params.submit) await page
|
|
24
|
+
await page!.typeText(ref, text);
|
|
25
|
+
if (params.submit) await page!.pressKey('Enter');
|
|
26
26
|
}
|
|
27
27
|
return data;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export async function stepWait(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
31
|
-
if (typeof params === 'number') await page
|
|
30
|
+
export async function stepWait(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
31
|
+
if (typeof params === 'number') await page!.wait(params);
|
|
32
32
|
else if (typeof params === 'object' && params) {
|
|
33
33
|
if ('text' in params) {
|
|
34
|
-
await page
|
|
34
|
+
await page!.wait({
|
|
35
35
|
text: String(render(params.text, { args, data })),
|
|
36
36
|
timeout: params.timeout
|
|
37
37
|
});
|
|
38
|
-
} else if ('time' in params) await page
|
|
39
|
-
} else if (typeof params === 'string') await page
|
|
38
|
+
} else if ('time' in params) await page!.wait(Number(params.time));
|
|
39
|
+
} else if (typeof params === 'string') await page!.wait(Number(render(params, { args, data })));
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export async function stepPress(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
44
|
-
await page
|
|
43
|
+
export async function stepPress(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
44
|
+
await page!.pressKey(String(render(params, { args, data })));
|
|
45
45
|
return data;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export async function stepSnapshot(page: IPage, params: any, _data: any, _args: Record<string, any>): Promise<any> {
|
|
48
|
+
export async function stepSnapshot(page: IPage | null, params: any, _data: any, _args: Record<string, any>): Promise<any> {
|
|
49
49
|
const opts = (typeof params === 'object' && params) ? params : {};
|
|
50
|
-
return page
|
|
50
|
+
return page!.snapshot({ interactive: opts.interactive ?? false, compact: opts.compact ?? false, maxDepth: opts.max_depth, raw: opts.raw ?? false });
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export async function stepEvaluate(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
53
|
+
export async function stepEvaluate(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
54
54
|
const js = String(render(params, { args, data }));
|
|
55
|
-
let result = await page
|
|
55
|
+
let result = await page!.evaluate(normalizeEvaluateSource(js));
|
|
56
56
|
// MCP may return JSON as a string — auto-parse it
|
|
57
57
|
if (typeof result === 'string') {
|
|
58
58
|
const trimmed = result.trim();
|
|
@@ -6,7 +6,7 @@ import type { IPage } from '../../types.js';
|
|
|
6
6
|
import { render } from '../template.js';
|
|
7
7
|
import { generateInterceptorJs, generateReadInterceptedJs } from '../../interceptor.js';
|
|
8
8
|
|
|
9
|
-
export async function stepIntercept(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
9
|
+
export async function stepIntercept(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
10
10
|
const cfg = typeof params === 'object' ? params : {};
|
|
11
11
|
const trigger = cfg.trigger ?? '';
|
|
12
12
|
const capturePattern = cfg.capture ?? '';
|
|
@@ -16,28 +16,28 @@ export async function stepIntercept(page: IPage, params: any, data: any, args: R
|
|
|
16
16
|
if (!capturePattern) return data;
|
|
17
17
|
|
|
18
18
|
// Step 1: Inject fetch/XHR interceptor BEFORE trigger
|
|
19
|
-
await page
|
|
19
|
+
await page!.evaluate(generateInterceptorJs(JSON.stringify(capturePattern)));
|
|
20
20
|
|
|
21
21
|
// Step 2: Execute the trigger action
|
|
22
22
|
if (trigger.startsWith('navigate:')) {
|
|
23
23
|
const url = render(trigger.slice('navigate:'.length), { args, data });
|
|
24
|
-
await page
|
|
24
|
+
await page!.goto(String(url));
|
|
25
25
|
} else if (trigger.startsWith('evaluate:')) {
|
|
26
26
|
const js = trigger.slice('evaluate:'.length);
|
|
27
27
|
const { normalizeEvaluateSource } = await import('../template.js');
|
|
28
|
-
await page
|
|
28
|
+
await page!.evaluate(normalizeEvaluateSource(render(js, { args, data }) as string));
|
|
29
29
|
} else if (trigger.startsWith('click:')) {
|
|
30
30
|
const ref = render(trigger.slice('click:'.length), { args, data });
|
|
31
|
-
await page
|
|
31
|
+
await page!.click(String(ref).replace(/^@/, ''));
|
|
32
32
|
} else if (trigger === 'scroll') {
|
|
33
|
-
await page
|
|
33
|
+
await page!.scroll('down');
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// Step 3: Wait a bit for network requests to fire
|
|
37
|
-
await page
|
|
37
|
+
await page!.wait(Math.min(timeout, 3));
|
|
38
38
|
|
|
39
39
|
// Step 4: Retrieve captured data
|
|
40
|
-
const matchingResponses = await page
|
|
40
|
+
const matchingResponses = await page!.evaluate(generateReadInterceptedJs());
|
|
41
41
|
|
|
42
42
|
// Step 5: Select from response if specified
|
|
43
43
|
let result = matchingResponses.length === 1 ? matchingResponses[0] :
|
|
@@ -13,7 +13,7 @@ import type { IPage } from '../../types.js';
|
|
|
13
13
|
import { render } from '../template.js';
|
|
14
14
|
import { generateTapInterceptorJs } from '../../interceptor.js';
|
|
15
15
|
|
|
16
|
-
export async function stepTap(page: IPage, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
16
|
+
export async function stepTap(page: IPage | null, params: any, data: any, args: Record<string, any>): Promise<any> {
|
|
17
17
|
const cfg = typeof params === 'object' ? params : {};
|
|
18
18
|
const storeName = String(render(cfg.store ?? '', { args, data }));
|
|
19
19
|
const actionName = String(render(cfg.action ?? '', { args, data }));
|
|
@@ -96,5 +96,5 @@ export async function stepTap(page: IPage, params: any, data: any, args: Record<
|
|
|
96
96
|
}
|
|
97
97
|
`;
|
|
98
98
|
|
|
99
|
-
return page
|
|
99
|
+
return page!.evaluate(js);
|
|
100
100
|
}
|
package/src/setup.ts
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
upsertTomlConfigToken,
|
|
25
25
|
writeFileWithMkdir,
|
|
26
26
|
} from './doctor.js';
|
|
27
|
-
import { getTokenFingerprint } from './browser.js';
|
|
27
|
+
import { getTokenFingerprint } from './browser/index.js';
|
|
28
28
|
import { type CheckboxItem, checkboxPrompt } from './tui.js';
|
|
29
29
|
|
|
30
30
|
export async function runSetup(opts: { cliVersion?: string; token?: string } = {}) {
|
package/tsconfig.json
CHANGED
package/dist/browser.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser interaction via Playwright MCP Bridge extension.
|
|
3
|
-
* Connects to an existing Chrome browser through the extension.
|
|
4
|
-
*/
|
|
5
|
-
import { withTimeoutMs } from './runtime.js';
|
|
6
|
-
type ConnectFailureKind = 'missing-token' | 'extension-timeout' | 'extension-not-installed' | 'mcp-init' | 'process-exit' | 'unknown';
|
|
7
|
-
type PlaywrightMCPState = 'idle' | 'connecting' | 'connected' | 'closing' | 'closed';
|
|
8
|
-
type ConnectFailureInput = {
|
|
9
|
-
kind: ConnectFailureKind;
|
|
10
|
-
timeout: number;
|
|
11
|
-
hasExtensionToken: boolean;
|
|
12
|
-
tokenFingerprint?: string | null;
|
|
13
|
-
stderr?: string;
|
|
14
|
-
exitCode?: number | null;
|
|
15
|
-
rawMessage?: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function getTokenFingerprint(token: string | undefined): string | null;
|
|
18
|
-
export declare function formatBrowserConnectError(input: ConnectFailureInput): Error;
|
|
19
|
-
declare function createJsonRpcRequest(method: string, params?: Record<string, any>): {
|
|
20
|
-
id: number;
|
|
21
|
-
message: string;
|
|
22
|
-
};
|
|
23
|
-
import type { IPage } from './types.js';
|
|
24
|
-
/**
|
|
25
|
-
* Page abstraction wrapping JSON-RPC calls to Playwright MCP.
|
|
26
|
-
*/
|
|
27
|
-
export declare class Page implements IPage {
|
|
28
|
-
private _request;
|
|
29
|
-
constructor(_request: (method: string, params?: Record<string, any>) => Promise<any>);
|
|
30
|
-
call(method: string, params?: Record<string, any>): Promise<any>;
|
|
31
|
-
goto(url: string): Promise<void>;
|
|
32
|
-
evaluate(js: string): Promise<any>;
|
|
33
|
-
snapshot(opts?: {
|
|
34
|
-
interactive?: boolean;
|
|
35
|
-
compact?: boolean;
|
|
36
|
-
maxDepth?: number;
|
|
37
|
-
raw?: boolean;
|
|
38
|
-
}): Promise<any>;
|
|
39
|
-
click(ref: string): Promise<void>;
|
|
40
|
-
typeText(ref: string, text: string): Promise<void>;
|
|
41
|
-
pressKey(key: string): Promise<void>;
|
|
42
|
-
wait(options: number | {
|
|
43
|
-
text?: string;
|
|
44
|
-
time?: number;
|
|
45
|
-
timeout?: number;
|
|
46
|
-
}): Promise<void>;
|
|
47
|
-
tabs(): Promise<any>;
|
|
48
|
-
closeTab(index?: number): Promise<void>;
|
|
49
|
-
newTab(): Promise<void>;
|
|
50
|
-
selectTab(index: number): Promise<void>;
|
|
51
|
-
networkRequests(includeStatic?: boolean): Promise<any>;
|
|
52
|
-
consoleMessages(level?: string): Promise<any>;
|
|
53
|
-
scroll(direction?: string, _amount?: number): Promise<void>;
|
|
54
|
-
autoScroll(options?: {
|
|
55
|
-
times?: number;
|
|
56
|
-
delayMs?: number;
|
|
57
|
-
}): Promise<void>;
|
|
58
|
-
installInterceptor(pattern: string): Promise<void>;
|
|
59
|
-
getInterceptedRequests(): Promise<any[]>;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Playwright MCP process manager.
|
|
63
|
-
*/
|
|
64
|
-
export declare class PlaywrightMCP {
|
|
65
|
-
private static _activeInsts;
|
|
66
|
-
private static _cleanupRegistered;
|
|
67
|
-
private static _registerGlobalCleanup;
|
|
68
|
-
private _proc;
|
|
69
|
-
private _buffer;
|
|
70
|
-
private _pending;
|
|
71
|
-
private _initialTabIdentities;
|
|
72
|
-
private _closingPromise;
|
|
73
|
-
private _state;
|
|
74
|
-
private _page;
|
|
75
|
-
get state(): PlaywrightMCPState;
|
|
76
|
-
private _sendRequest;
|
|
77
|
-
private _rejectPendingRequests;
|
|
78
|
-
private _resetAfterFailedConnect;
|
|
79
|
-
connect(opts?: {
|
|
80
|
-
timeout?: number;
|
|
81
|
-
}): Promise<Page>;
|
|
82
|
-
close(): Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
declare function extractTabEntries(raw: any): Array<{
|
|
85
|
-
index: number;
|
|
86
|
-
identity: string;
|
|
87
|
-
}>;
|
|
88
|
-
declare function diffTabIndexes(initialIdentities: string[], currentTabs: Array<{
|
|
89
|
-
index: number;
|
|
90
|
-
identity: string;
|
|
91
|
-
}>): number[];
|
|
92
|
-
declare function appendLimited(current: string, chunk: string, limit: number): string;
|
|
93
|
-
declare function buildMcpArgs(input: {
|
|
94
|
-
mcpPath: string;
|
|
95
|
-
executablePath?: string | null;
|
|
96
|
-
}): string[];
|
|
97
|
-
export declare const __test__: {
|
|
98
|
-
createJsonRpcRequest: typeof createJsonRpcRequest;
|
|
99
|
-
extractTabEntries: typeof extractTabEntries;
|
|
100
|
-
diffTabIndexes: typeof diffTabIndexes;
|
|
101
|
-
appendLimited: typeof appendLimited;
|
|
102
|
-
buildMcpArgs: typeof buildMcpArgs;
|
|
103
|
-
withTimeoutMs: typeof withTimeoutMs;
|
|
104
|
-
};
|
|
105
|
-
export {};
|