@_deep4wee/agent-lens 1.1.0 → 1.2.0
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 +331 -227
- package/dist/cli.js +1068 -911
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1277 -1033
- package/dist/cli.mjs.map +1 -1
- package/dist/dsl-BIjVN1M0.d.mts +204 -0
- package/dist/dsl-BIjVN1M0.d.ts +204 -0
- package/dist/index.d.mts +131 -178
- package/dist/index.d.ts +131 -178
- package/dist/index.js +1506 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1479 -3
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/a11y-tree/index.d.mts +11 -0
- package/dist/plugins/a11y-tree/index.d.ts +11 -0
- package/dist/plugins/a11y-tree/index.js +190 -0
- package/dist/plugins/a11y-tree/index.js.map +1 -0
- package/dist/plugins/a11y-tree/index.mjs +155 -0
- package/dist/plugins/a11y-tree/index.mjs.map +1 -0
- package/dist/plugins/desktop-webview2/index.d.mts +14 -0
- package/dist/plugins/desktop-webview2/index.d.ts +14 -0
- package/dist/plugins/desktop-webview2/index.js +258 -0
- package/dist/plugins/desktop-webview2/index.js.map +1 -0
- package/dist/plugins/desktop-webview2/index.mjs +221 -0
- package/dist/plugins/desktop-webview2/index.mjs.map +1 -0
- package/dist/plugins/live-controller/index.d.mts +35 -0
- package/dist/plugins/live-controller/index.d.ts +35 -0
- package/dist/plugins/live-controller/index.js +303 -0
- package/dist/plugins/live-controller/index.js.map +1 -0
- package/dist/plugins/live-controller/index.mjs +261 -0
- package/dist/plugins/live-controller/index.mjs.map +1 -0
- package/dist/plugins/mock-ipc/index.d.mts +30 -0
- package/dist/plugins/mock-ipc/index.d.ts +30 -0
- package/dist/plugins/mock-ipc/index.js +210 -0
- package/dist/plugins/mock-ipc/index.js.map +1 -0
- package/dist/plugins/mock-ipc/index.mjs +181 -0
- package/dist/plugins/mock-ipc/index.mjs.map +1 -0
- package/dist/plugins/visual-diff/index.d.mts +30 -0
- package/dist/plugins/visual-diff/index.d.ts +30 -0
- package/dist/plugins/visual-diff/index.js +163 -0
- package/dist/plugins/visual-diff/index.js.map +1 -0
- package/dist/plugins/visual-diff/index.mjs +127 -0
- package/dist/plugins/visual-diff/index.mjs.map +1 -0
- package/docs/plugins.md +415 -0
- package/package.json +40 -2
- package/skills/agent-lens/SKILL.md +130 -43
- package/skills/agent-lens/examples/07-live-controller-interactive-loop.md +108 -0
- package/skills/agent-lens/examples/08-accessibility-semantic-inspection.md +80 -0
- package/skills/agent-lens/examples/09-visual-regression-and-pixel-diffing.md +66 -0
- package/skills/agent-lens/examples/10-authoring-custom-agent-plugins.md +85 -0
- package/skills/agent-lens/references/plugin-development.md +165 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,193 +1,146 @@
|
|
|
1
|
+
import { V as VisualScenario, A as AgentLensPlugin, C as ConsoleEntry, S as SnapshotMetadata, b as CaptureOptions, c as CaptureBurstOptions, R as ReportData, P as PluginHookContext, D as DriverLaunchResult, T as TestContext } from './dsl-BIjVN1M0.mjs';
|
|
2
|
+
export { a as MockIpcEntry, M as MockIpcResponseType, d as MockRouteEntry, e as ReportSection, f as VIEWPORT_PRESETS, g as ViewportPreset, h as definePlugin, i as defineVisualTest } from './dsl-BIjVN1M0.mjs';
|
|
1
3
|
import { Page, BrowserContext } from 'playwright';
|
|
2
4
|
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface RunOptions {
|
|
6
|
+
scenario: VisualScenario;
|
|
7
|
+
targetMode?: 'desktop' | 'preview' | string;
|
|
8
|
+
artifactsRoot?: string;
|
|
9
|
+
autoLaunchDesktop?: boolean;
|
|
10
|
+
port?: number;
|
|
11
|
+
wwwrootDir?: string;
|
|
12
|
+
executablePath?: string;
|
|
13
|
+
desktopArgs?: string[];
|
|
14
|
+
desktopEnv?: Record<string, string>;
|
|
15
|
+
cleanPaths?: string[];
|
|
16
|
+
url?: string;
|
|
17
|
+
startCommand?: string;
|
|
18
|
+
startCwd?: string;
|
|
19
|
+
cleanArtifacts?: boolean;
|
|
20
|
+
headed?: boolean;
|
|
21
|
+
detach?: boolean;
|
|
22
|
+
globalMocks?: any[];
|
|
23
|
+
plugins?: (string | AgentLensPlugin)[];
|
|
9
24
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
}
|
|
23
|
-
declare const VIEWPORT_PRESETS: {
|
|
24
|
-
/** Minimum supported window size (e.g., ) */
|
|
25
|
-
MIN_SUPPORTED: ViewportPreset;
|
|
26
|
-
/** Standard default window size (e.g., ) */
|
|
27
|
-
DEFAULT: ViewportPreset;
|
|
28
|
-
/** Wide screen for checking grids and tables */
|
|
29
|
-
WIDE: ViewportPreset;
|
|
30
|
-
/** Full HD */
|
|
31
|
-
FULL_HD: ViewportPreset;
|
|
32
|
-
};
|
|
33
|
-
interface MockRouteEntry {
|
|
34
|
-
url: string;
|
|
35
|
-
method?: string;
|
|
36
|
-
status?: number;
|
|
37
|
-
body: any;
|
|
38
|
-
delayMs?: number;
|
|
39
|
-
headers?: Record<string, string>;
|
|
25
|
+
interface RunResult {
|
|
26
|
+
scenarioId: string;
|
|
27
|
+
targetMode: 'desktop' | 'preview' | string;
|
|
28
|
+
success: boolean;
|
|
29
|
+
totalSnapshots: number;
|
|
30
|
+
consoleErrors: number;
|
|
31
|
+
consoleWarnings: number;
|
|
32
|
+
reportPath: string;
|
|
33
|
+
artifactsDir: string;
|
|
34
|
+
error?: string;
|
|
40
35
|
}
|
|
41
|
-
|
|
36
|
+
declare function runVisualScenario(options: RunOptions): Promise<RunResult>;
|
|
37
|
+
|
|
38
|
+
interface SnapCliOptions {
|
|
39
|
+
url?: string;
|
|
40
|
+
start?: string;
|
|
41
|
+
startCwd?: string;
|
|
42
42
|
selector?: string;
|
|
43
|
+
viewports?: string[];
|
|
44
|
+
waitMs?: number;
|
|
45
|
+
name?: string;
|
|
46
|
+
clean?: string[];
|
|
47
|
+
cleanArtifacts?: boolean;
|
|
48
|
+
headed?: boolean;
|
|
49
|
+
detach?: boolean;
|
|
50
|
+
outDir?: string;
|
|
51
|
+
mode?: 'desktop' | 'preview';
|
|
52
|
+
exe?: string;
|
|
53
|
+
port?: number;
|
|
54
|
+
plugins?: (string | any)[];
|
|
43
55
|
fullPage?: boolean;
|
|
44
|
-
mask?: string[];
|
|
45
56
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
width: number;
|
|
62
|
-
height: number;
|
|
63
|
-
};
|
|
64
|
-
timestamp: string;
|
|
65
|
-
isBurstFrame?: boolean;
|
|
66
|
-
burstGroup?: string;
|
|
67
|
-
frameIndex?: number;
|
|
68
|
-
selector?: string;
|
|
57
|
+
declare function runQuickSnap(options: SnapCliOptions): Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
declare class ConsoleTracker {
|
|
60
|
+
private entries;
|
|
61
|
+
private attached;
|
|
62
|
+
attach(page: Page): void;
|
|
63
|
+
getErrors(): ConsoleEntry[];
|
|
64
|
+
getWarnings(): ConsoleEntry[];
|
|
65
|
+
getAll(): ConsoleEntry[];
|
|
66
|
+
get errorCount(): number;
|
|
67
|
+
get warningCount(): number;
|
|
68
|
+
get hasErrors(): boolean;
|
|
69
|
+
clear(): void;
|
|
70
|
+
private mapConsoleType;
|
|
71
|
+
private isIgnoredWarning;
|
|
69
72
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/** Capture a single high-quality snapshot of the window or element */
|
|
79
|
-
capture: (name: string, options?: CaptureOptions) => Promise<SnapshotMetadata>;
|
|
80
|
-
/** Capture a series of frames for animations (Framer Motion, modals, lists) */
|
|
81
|
-
captureBurst: (name: string, options: CaptureBurstOptions) => Promise<SnapshotMetadata[]>;
|
|
82
|
-
/**
|
|
83
|
-
* Dynamically navigate to another page during the test.
|
|
84
|
-
* Example: await ctx.navigate('/settings');
|
|
85
|
-
*/
|
|
86
|
-
navigate: (route: string) => Promise<void>;
|
|
87
|
-
/** Change window / viewport size */
|
|
88
|
-
resize: (width: number, height: number) => Promise<void>;
|
|
89
|
-
/** Set one of the standard presets (MIN_SUPPORTED, DEFAULT, WIDE) */
|
|
90
|
-
setPreset: (preset: ViewportPreset) => Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Dynamically resize the window so it perfectly fits the specified element (or body).
|
|
93
|
-
* Useful when an agent wants to test an isolated component without background clutter.
|
|
94
|
-
*/
|
|
95
|
-
resizeToFit: (selector?: string, padding?: number) => Promise<void>;
|
|
96
|
-
/** Wait the specified amount of milliseconds */
|
|
97
|
-
wait: (ms: number) => Promise<void>;
|
|
98
|
-
/** Wait for the selector to appear in the DOM */
|
|
99
|
-
waitForSelector: (selector: string, timeoutMs?: number) => Promise<void>;
|
|
100
|
-
/** Left-click the element */
|
|
101
|
-
click: (selector: string) => Promise<void>;
|
|
102
|
-
/** Right-click the element (Context Menu) */
|
|
103
|
-
rightClick: (selector: string) => Promise<void>;
|
|
104
|
-
/** Type text into an input field */
|
|
105
|
-
type: (selector: string, text: string) => Promise<void>;
|
|
106
|
-
/** Select an option in a <select> by its value */
|
|
107
|
-
selectOption: (selector: string, value: string) => Promise<void>;
|
|
108
|
-
/** Hover the cursor to check highlights / tooltips */
|
|
109
|
-
hover: (selector: string) => Promise<void>;
|
|
110
|
-
/** Scroll the element (or window) down by the specified number of pixels */
|
|
111
|
-
scroll: (selector: string, deltaY: number) => Promise<void>;
|
|
112
|
-
/** Log a step for the agent */
|
|
113
|
-
log: (message: string) => void;
|
|
73
|
+
|
|
74
|
+
declare class CaptureEngine {
|
|
75
|
+
private outputDir;
|
|
76
|
+
private currentStepIndex;
|
|
77
|
+
private recordedSnapshots;
|
|
78
|
+
constructor(outputDir: string);
|
|
79
|
+
getSnapshots(): SnapshotMetadata[];
|
|
80
|
+
getOutputDir(): string;
|
|
114
81
|
/**
|
|
115
|
-
* Set a mock response for an IPC action.
|
|
116
|
-
* Changes the data returned by window.__mockIpc.invoke or hybrid bridges in preview mode.
|
|
117
|
-
* Ignored in desktop mode (IPC goes through real backend).
|
|
118
82
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
})
|
|
83
|
+
takeSnapshot(page: Page, name: string, viewport: {
|
|
84
|
+
width: number;
|
|
85
|
+
height: number;
|
|
86
|
+
}, options?: CaptureOptions): Promise<SnapshotMetadata>;
|
|
123
87
|
/**
|
|
124
|
-
* Mock an HTTP REST or GraphQL network request in preview mode.
|
|
125
|
-
* Intercepts fetch/axios calls matching the URL pattern and returns mock data.
|
|
126
|
-
*
|
|
127
|
-
* Example:
|
|
128
|
-
* await ctx.setMockRoute('/api/user', { id: 1, name: 'Agent' });
|
|
129
|
-
* await ctx.setMockRoute('**\/api/items*', [], { status: 200, delayMs: 50 });
|
|
130
88
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
headers?: Record<string, string>;
|
|
136
|
-
}) => Promise<void>;
|
|
137
|
-
/** Return all intercepted console.error and pageerror logs */
|
|
138
|
-
getConsoleErrors: () => ConsoleEntry[];
|
|
139
|
-
/** Return all intercepted console.warn logs */
|
|
140
|
-
getConsoleWarnings: () => ConsoleEntry[];
|
|
141
|
-
/** Returns true if there are critical errors in the console */
|
|
142
|
-
hasConsoleErrors: () => boolean;
|
|
143
|
-
/** Get the visible text of a specific element */
|
|
144
|
-
readText: (selector: string) => Promise<string | null>;
|
|
145
|
-
/** Get ALL visible text on the page (useful for quick analysis without Vision) */
|
|
146
|
-
getPageText: () => Promise<string>;
|
|
147
|
-
/** Check if the element is visible on the screen */
|
|
148
|
-
isVisible: (selector: string) => Promise<boolean>;
|
|
149
|
-
/** Count the number of elements matching the selector */
|
|
150
|
-
getElementCount: (selector: string) => Promise<number>;
|
|
89
|
+
takeBurst(page: Page, name: string, viewport: {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
}, options: CaptureBurstOptions): Promise<SnapshotMetadata[]>;
|
|
151
93
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
94
|
+
|
|
95
|
+
declare class VisualReporter {
|
|
96
|
+
static generateReport(data: ReportData): string;
|
|
97
|
+
private static getHealthStatus;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface AgentLensConfigFile {
|
|
101
|
+
mode?: 'desktop' | 'preview';
|
|
102
|
+
port?: number;
|
|
103
|
+
headed?: boolean;
|
|
104
|
+
detach?: boolean;
|
|
105
|
+
buildCommand?: string;
|
|
106
|
+
autoBuild?: boolean;
|
|
107
|
+
startCommand?: string;
|
|
108
|
+
startCwd?: string;
|
|
109
|
+
cleanArtifacts?: boolean;
|
|
110
|
+
url?: string;
|
|
111
|
+
executablePath?: string;
|
|
112
|
+
clean?: string | string[];
|
|
113
|
+
scenarios?: string;
|
|
114
|
+
wwwroot?: string;
|
|
115
|
+
outDir?: string;
|
|
116
|
+
env?: Record<string, string>;
|
|
117
|
+
plugins?: string[];
|
|
118
|
+
}
|
|
119
|
+
declare function loadConfig(cwd?: string): AgentLensConfigFile;
|
|
120
|
+
declare function detectStartCwd(providedCwd?: string): string | undefined;
|
|
121
|
+
declare function resolveWwwrootDir(customDir?: string): string;
|
|
122
|
+
|
|
123
|
+
declare class PluginManager {
|
|
124
|
+
private plugins;
|
|
125
|
+
private jiti;
|
|
126
|
+
register(plugin: AgentLensPlugin): void;
|
|
127
|
+
load(pluginSpec: string | AgentLensPlugin): Promise<void>;
|
|
128
|
+
private loadFromFile;
|
|
129
|
+
loadAll(specs: (string | AgentLensPlugin)[]): Promise<void>;
|
|
130
|
+
runSetup(hookContext: PluginHookContext): Promise<void>;
|
|
131
|
+
launchSession(options: {
|
|
132
|
+
currentViewport: {
|
|
133
|
+
width: number;
|
|
134
|
+
height: number;
|
|
135
|
+
};
|
|
136
|
+
headed?: boolean;
|
|
137
|
+
}, hookContext: PluginHookContext): Promise<DriverLaunchResult | undefined>;
|
|
138
|
+
runOnContextCreated(context: BrowserContext, hookContext: PluginHookContext): Promise<void>;
|
|
139
|
+
runOnPageCreated(page: Page, context: BrowserContext, hookContext: PluginHookContext): Promise<void>;
|
|
140
|
+
extendContext(ctx: TestContext, page: Page, hookContext: PluginHookContext): Promise<void>;
|
|
141
|
+
runOnAfterRun(reportData: ReportData, hookContext: PluginHookContext): Promise<void>;
|
|
142
|
+
runTeardown(hookContext: PluginHookContext): Promise<void>;
|
|
143
|
+
get loadedPlugins(): AgentLensPlugin[];
|
|
190
144
|
}
|
|
191
|
-
declare function defineVisualTest(scenario: VisualScenario): VisualScenario;
|
|
192
145
|
|
|
193
|
-
export { type CaptureBurstOptions,
|
|
146
|
+
export { type AgentLensConfigFile, AgentLensPlugin, CaptureBurstOptions, CaptureEngine, CaptureOptions, ConsoleEntry, ConsoleTracker, DriverLaunchResult, PluginHookContext, PluginManager, ReportData, type RunOptions, type RunResult, type SnapCliOptions, SnapshotMetadata, TestContext, VisualReporter, VisualScenario, detectStartCwd, loadConfig, resolveWwwrootDir, runQuickSnap, runVisualScenario };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,193 +1,146 @@
|
|
|
1
|
+
import { V as VisualScenario, A as AgentLensPlugin, C as ConsoleEntry, S as SnapshotMetadata, b as CaptureOptions, c as CaptureBurstOptions, R as ReportData, P as PluginHookContext, D as DriverLaunchResult, T as TestContext } from './dsl-BIjVN1M0.js';
|
|
2
|
+
export { a as MockIpcEntry, M as MockIpcResponseType, d as MockRouteEntry, e as ReportSection, f as VIEWPORT_PRESETS, g as ViewportPreset, h as definePlugin, i as defineVisualTest } from './dsl-BIjVN1M0.js';
|
|
1
3
|
import { Page, BrowserContext } from 'playwright';
|
|
2
4
|
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
interface RunOptions {
|
|
6
|
+
scenario: VisualScenario;
|
|
7
|
+
targetMode?: 'desktop' | 'preview' | string;
|
|
8
|
+
artifactsRoot?: string;
|
|
9
|
+
autoLaunchDesktop?: boolean;
|
|
10
|
+
port?: number;
|
|
11
|
+
wwwrootDir?: string;
|
|
12
|
+
executablePath?: string;
|
|
13
|
+
desktopArgs?: string[];
|
|
14
|
+
desktopEnv?: Record<string, string>;
|
|
15
|
+
cleanPaths?: string[];
|
|
16
|
+
url?: string;
|
|
17
|
+
startCommand?: string;
|
|
18
|
+
startCwd?: string;
|
|
19
|
+
cleanArtifacts?: boolean;
|
|
20
|
+
headed?: boolean;
|
|
21
|
+
detach?: boolean;
|
|
22
|
+
globalMocks?: any[];
|
|
23
|
+
plugins?: (string | AgentLensPlugin)[];
|
|
9
24
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
}
|
|
23
|
-
declare const VIEWPORT_PRESETS: {
|
|
24
|
-
/** Minimum supported window size (e.g., ) */
|
|
25
|
-
MIN_SUPPORTED: ViewportPreset;
|
|
26
|
-
/** Standard default window size (e.g., ) */
|
|
27
|
-
DEFAULT: ViewportPreset;
|
|
28
|
-
/** Wide screen for checking grids and tables */
|
|
29
|
-
WIDE: ViewportPreset;
|
|
30
|
-
/** Full HD */
|
|
31
|
-
FULL_HD: ViewportPreset;
|
|
32
|
-
};
|
|
33
|
-
interface MockRouteEntry {
|
|
34
|
-
url: string;
|
|
35
|
-
method?: string;
|
|
36
|
-
status?: number;
|
|
37
|
-
body: any;
|
|
38
|
-
delayMs?: number;
|
|
39
|
-
headers?: Record<string, string>;
|
|
25
|
+
interface RunResult {
|
|
26
|
+
scenarioId: string;
|
|
27
|
+
targetMode: 'desktop' | 'preview' | string;
|
|
28
|
+
success: boolean;
|
|
29
|
+
totalSnapshots: number;
|
|
30
|
+
consoleErrors: number;
|
|
31
|
+
consoleWarnings: number;
|
|
32
|
+
reportPath: string;
|
|
33
|
+
artifactsDir: string;
|
|
34
|
+
error?: string;
|
|
40
35
|
}
|
|
41
|
-
|
|
36
|
+
declare function runVisualScenario(options: RunOptions): Promise<RunResult>;
|
|
37
|
+
|
|
38
|
+
interface SnapCliOptions {
|
|
39
|
+
url?: string;
|
|
40
|
+
start?: string;
|
|
41
|
+
startCwd?: string;
|
|
42
42
|
selector?: string;
|
|
43
|
+
viewports?: string[];
|
|
44
|
+
waitMs?: number;
|
|
45
|
+
name?: string;
|
|
46
|
+
clean?: string[];
|
|
47
|
+
cleanArtifacts?: boolean;
|
|
48
|
+
headed?: boolean;
|
|
49
|
+
detach?: boolean;
|
|
50
|
+
outDir?: string;
|
|
51
|
+
mode?: 'desktop' | 'preview';
|
|
52
|
+
exe?: string;
|
|
53
|
+
port?: number;
|
|
54
|
+
plugins?: (string | any)[];
|
|
43
55
|
fullPage?: boolean;
|
|
44
|
-
mask?: string[];
|
|
45
56
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
width: number;
|
|
62
|
-
height: number;
|
|
63
|
-
};
|
|
64
|
-
timestamp: string;
|
|
65
|
-
isBurstFrame?: boolean;
|
|
66
|
-
burstGroup?: string;
|
|
67
|
-
frameIndex?: number;
|
|
68
|
-
selector?: string;
|
|
57
|
+
declare function runQuickSnap(options: SnapCliOptions): Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
declare class ConsoleTracker {
|
|
60
|
+
private entries;
|
|
61
|
+
private attached;
|
|
62
|
+
attach(page: Page): void;
|
|
63
|
+
getErrors(): ConsoleEntry[];
|
|
64
|
+
getWarnings(): ConsoleEntry[];
|
|
65
|
+
getAll(): ConsoleEntry[];
|
|
66
|
+
get errorCount(): number;
|
|
67
|
+
get warningCount(): number;
|
|
68
|
+
get hasErrors(): boolean;
|
|
69
|
+
clear(): void;
|
|
70
|
+
private mapConsoleType;
|
|
71
|
+
private isIgnoredWarning;
|
|
69
72
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
/** Capture a single high-quality snapshot of the window or element */
|
|
79
|
-
capture: (name: string, options?: CaptureOptions) => Promise<SnapshotMetadata>;
|
|
80
|
-
/** Capture a series of frames for animations (Framer Motion, modals, lists) */
|
|
81
|
-
captureBurst: (name: string, options: CaptureBurstOptions) => Promise<SnapshotMetadata[]>;
|
|
82
|
-
/**
|
|
83
|
-
* Dynamically navigate to another page during the test.
|
|
84
|
-
* Example: await ctx.navigate('/settings');
|
|
85
|
-
*/
|
|
86
|
-
navigate: (route: string) => Promise<void>;
|
|
87
|
-
/** Change window / viewport size */
|
|
88
|
-
resize: (width: number, height: number) => Promise<void>;
|
|
89
|
-
/** Set one of the standard presets (MIN_SUPPORTED, DEFAULT, WIDE) */
|
|
90
|
-
setPreset: (preset: ViewportPreset) => Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Dynamically resize the window so it perfectly fits the specified element (or body).
|
|
93
|
-
* Useful when an agent wants to test an isolated component without background clutter.
|
|
94
|
-
*/
|
|
95
|
-
resizeToFit: (selector?: string, padding?: number) => Promise<void>;
|
|
96
|
-
/** Wait the specified amount of milliseconds */
|
|
97
|
-
wait: (ms: number) => Promise<void>;
|
|
98
|
-
/** Wait for the selector to appear in the DOM */
|
|
99
|
-
waitForSelector: (selector: string, timeoutMs?: number) => Promise<void>;
|
|
100
|
-
/** Left-click the element */
|
|
101
|
-
click: (selector: string) => Promise<void>;
|
|
102
|
-
/** Right-click the element (Context Menu) */
|
|
103
|
-
rightClick: (selector: string) => Promise<void>;
|
|
104
|
-
/** Type text into an input field */
|
|
105
|
-
type: (selector: string, text: string) => Promise<void>;
|
|
106
|
-
/** Select an option in a <select> by its value */
|
|
107
|
-
selectOption: (selector: string, value: string) => Promise<void>;
|
|
108
|
-
/** Hover the cursor to check highlights / tooltips */
|
|
109
|
-
hover: (selector: string) => Promise<void>;
|
|
110
|
-
/** Scroll the element (or window) down by the specified number of pixels */
|
|
111
|
-
scroll: (selector: string, deltaY: number) => Promise<void>;
|
|
112
|
-
/** Log a step for the agent */
|
|
113
|
-
log: (message: string) => void;
|
|
73
|
+
|
|
74
|
+
declare class CaptureEngine {
|
|
75
|
+
private outputDir;
|
|
76
|
+
private currentStepIndex;
|
|
77
|
+
private recordedSnapshots;
|
|
78
|
+
constructor(outputDir: string);
|
|
79
|
+
getSnapshots(): SnapshotMetadata[];
|
|
80
|
+
getOutputDir(): string;
|
|
114
81
|
/**
|
|
115
|
-
* Set a mock response for an IPC action.
|
|
116
|
-
* Changes the data returned by window.__mockIpc.invoke or hybrid bridges in preview mode.
|
|
117
|
-
* Ignored in desktop mode (IPC goes through real backend).
|
|
118
82
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
})
|
|
83
|
+
takeSnapshot(page: Page, name: string, viewport: {
|
|
84
|
+
width: number;
|
|
85
|
+
height: number;
|
|
86
|
+
}, options?: CaptureOptions): Promise<SnapshotMetadata>;
|
|
123
87
|
/**
|
|
124
|
-
* Mock an HTTP REST or GraphQL network request in preview mode.
|
|
125
|
-
* Intercepts fetch/axios calls matching the URL pattern and returns mock data.
|
|
126
|
-
*
|
|
127
|
-
* Example:
|
|
128
|
-
* await ctx.setMockRoute('/api/user', { id: 1, name: 'Agent' });
|
|
129
|
-
* await ctx.setMockRoute('**\/api/items*', [], { status: 200, delayMs: 50 });
|
|
130
88
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
headers?: Record<string, string>;
|
|
136
|
-
}) => Promise<void>;
|
|
137
|
-
/** Return all intercepted console.error and pageerror logs */
|
|
138
|
-
getConsoleErrors: () => ConsoleEntry[];
|
|
139
|
-
/** Return all intercepted console.warn logs */
|
|
140
|
-
getConsoleWarnings: () => ConsoleEntry[];
|
|
141
|
-
/** Returns true if there are critical errors in the console */
|
|
142
|
-
hasConsoleErrors: () => boolean;
|
|
143
|
-
/** Get the visible text of a specific element */
|
|
144
|
-
readText: (selector: string) => Promise<string | null>;
|
|
145
|
-
/** Get ALL visible text on the page (useful for quick analysis without Vision) */
|
|
146
|
-
getPageText: () => Promise<string>;
|
|
147
|
-
/** Check if the element is visible on the screen */
|
|
148
|
-
isVisible: (selector: string) => Promise<boolean>;
|
|
149
|
-
/** Count the number of elements matching the selector */
|
|
150
|
-
getElementCount: (selector: string) => Promise<number>;
|
|
89
|
+
takeBurst(page: Page, name: string, viewport: {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
}, options: CaptureBurstOptions): Promise<SnapshotMetadata[]>;
|
|
151
93
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
94
|
+
|
|
95
|
+
declare class VisualReporter {
|
|
96
|
+
static generateReport(data: ReportData): string;
|
|
97
|
+
private static getHealthStatus;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface AgentLensConfigFile {
|
|
101
|
+
mode?: 'desktop' | 'preview';
|
|
102
|
+
port?: number;
|
|
103
|
+
headed?: boolean;
|
|
104
|
+
detach?: boolean;
|
|
105
|
+
buildCommand?: string;
|
|
106
|
+
autoBuild?: boolean;
|
|
107
|
+
startCommand?: string;
|
|
108
|
+
startCwd?: string;
|
|
109
|
+
cleanArtifacts?: boolean;
|
|
110
|
+
url?: string;
|
|
111
|
+
executablePath?: string;
|
|
112
|
+
clean?: string | string[];
|
|
113
|
+
scenarios?: string;
|
|
114
|
+
wwwroot?: string;
|
|
115
|
+
outDir?: string;
|
|
116
|
+
env?: Record<string, string>;
|
|
117
|
+
plugins?: string[];
|
|
118
|
+
}
|
|
119
|
+
declare function loadConfig(cwd?: string): AgentLensConfigFile;
|
|
120
|
+
declare function detectStartCwd(providedCwd?: string): string | undefined;
|
|
121
|
+
declare function resolveWwwrootDir(customDir?: string): string;
|
|
122
|
+
|
|
123
|
+
declare class PluginManager {
|
|
124
|
+
private plugins;
|
|
125
|
+
private jiti;
|
|
126
|
+
register(plugin: AgentLensPlugin): void;
|
|
127
|
+
load(pluginSpec: string | AgentLensPlugin): Promise<void>;
|
|
128
|
+
private loadFromFile;
|
|
129
|
+
loadAll(specs: (string | AgentLensPlugin)[]): Promise<void>;
|
|
130
|
+
runSetup(hookContext: PluginHookContext): Promise<void>;
|
|
131
|
+
launchSession(options: {
|
|
132
|
+
currentViewport: {
|
|
133
|
+
width: number;
|
|
134
|
+
height: number;
|
|
135
|
+
};
|
|
136
|
+
headed?: boolean;
|
|
137
|
+
}, hookContext: PluginHookContext): Promise<DriverLaunchResult | undefined>;
|
|
138
|
+
runOnContextCreated(context: BrowserContext, hookContext: PluginHookContext): Promise<void>;
|
|
139
|
+
runOnPageCreated(page: Page, context: BrowserContext, hookContext: PluginHookContext): Promise<void>;
|
|
140
|
+
extendContext(ctx: TestContext, page: Page, hookContext: PluginHookContext): Promise<void>;
|
|
141
|
+
runOnAfterRun(reportData: ReportData, hookContext: PluginHookContext): Promise<void>;
|
|
142
|
+
runTeardown(hookContext: PluginHookContext): Promise<void>;
|
|
143
|
+
get loadedPlugins(): AgentLensPlugin[];
|
|
190
144
|
}
|
|
191
|
-
declare function defineVisualTest(scenario: VisualScenario): VisualScenario;
|
|
192
145
|
|
|
193
|
-
export { type CaptureBurstOptions,
|
|
146
|
+
export { type AgentLensConfigFile, AgentLensPlugin, CaptureBurstOptions, CaptureEngine, CaptureOptions, ConsoleEntry, ConsoleTracker, DriverLaunchResult, PluginHookContext, PluginManager, ReportData, type RunOptions, type RunResult, type SnapCliOptions, SnapshotMetadata, TestContext, VisualReporter, VisualScenario, detectStartCwd, loadConfig, resolveWwwrootDir, runQuickSnap, runVisualScenario };
|