@_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.
Files changed (51) hide show
  1. package/README.md +331 -227
  2. package/dist/cli.js +1068 -911
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +1277 -1033
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/dsl-BIjVN1M0.d.mts +204 -0
  7. package/dist/dsl-BIjVN1M0.d.ts +204 -0
  8. package/dist/index.d.mts +131 -178
  9. package/dist/index.d.ts +131 -178
  10. package/dist/index.js +1506 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +1479 -3
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/plugins/a11y-tree/index.d.mts +11 -0
  15. package/dist/plugins/a11y-tree/index.d.ts +11 -0
  16. package/dist/plugins/a11y-tree/index.js +190 -0
  17. package/dist/plugins/a11y-tree/index.js.map +1 -0
  18. package/dist/plugins/a11y-tree/index.mjs +155 -0
  19. package/dist/plugins/a11y-tree/index.mjs.map +1 -0
  20. package/dist/plugins/desktop-webview2/index.d.mts +14 -0
  21. package/dist/plugins/desktop-webview2/index.d.ts +14 -0
  22. package/dist/plugins/desktop-webview2/index.js +258 -0
  23. package/dist/plugins/desktop-webview2/index.js.map +1 -0
  24. package/dist/plugins/desktop-webview2/index.mjs +221 -0
  25. package/dist/plugins/desktop-webview2/index.mjs.map +1 -0
  26. package/dist/plugins/live-controller/index.d.mts +35 -0
  27. package/dist/plugins/live-controller/index.d.ts +35 -0
  28. package/dist/plugins/live-controller/index.js +303 -0
  29. package/dist/plugins/live-controller/index.js.map +1 -0
  30. package/dist/plugins/live-controller/index.mjs +261 -0
  31. package/dist/plugins/live-controller/index.mjs.map +1 -0
  32. package/dist/plugins/mock-ipc/index.d.mts +30 -0
  33. package/dist/plugins/mock-ipc/index.d.ts +30 -0
  34. package/dist/plugins/mock-ipc/index.js +210 -0
  35. package/dist/plugins/mock-ipc/index.js.map +1 -0
  36. package/dist/plugins/mock-ipc/index.mjs +181 -0
  37. package/dist/plugins/mock-ipc/index.mjs.map +1 -0
  38. package/dist/plugins/visual-diff/index.d.mts +30 -0
  39. package/dist/plugins/visual-diff/index.d.ts +30 -0
  40. package/dist/plugins/visual-diff/index.js +163 -0
  41. package/dist/plugins/visual-diff/index.js.map +1 -0
  42. package/dist/plugins/visual-diff/index.mjs +127 -0
  43. package/dist/plugins/visual-diff/index.mjs.map +1 -0
  44. package/docs/plugins.md +415 -0
  45. package/package.json +40 -2
  46. package/skills/agent-lens/SKILL.md +130 -43
  47. package/skills/agent-lens/examples/07-live-controller-interactive-loop.md +108 -0
  48. package/skills/agent-lens/examples/08-accessibility-semantic-inspection.md +80 -0
  49. package/skills/agent-lens/examples/09-visual-regression-and-pixel-diffing.md +66 -0
  50. package/skills/agent-lens/examples/10-authoring-custom-agent-plugins.md +85 -0
  51. 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 ConsoleEntry {
4
- level: 'error' | 'warning' | 'info' | 'log' | 'debug';
5
- text: string;
6
- url: string;
7
- timestamp: string;
8
- stack?: string;
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
- * Generic Mock IPC Registry for Preview Mode
13
- *
14
- * Injects a global `window.__mockIpc` that web apps or mocked electron/tauri APIs can call.
15
- */
16
- type MockIpcResponseType = 'SUCCESS' | 'ERROR';
17
-
18
- interface ViewportPreset {
19
- name: string;
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
- interface CaptureOptions {
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
- interface CaptureBurstOptions {
47
- /** Total duration of burst animation capture in milliseconds */
48
- durationMs: number;
49
- /** Interval between frames in milliseconds (default: 80ms) */
50
- intervalMs?: number;
51
- /** Restrict capture to a specific element */
52
- selector?: string;
53
- }
54
- interface SnapshotMetadata {
55
- index: number;
56
- name: string;
57
- fileName: string;
58
- filePath: string;
59
- relativeUri: string;
60
- viewport: {
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
- interface TestContext {
71
- page: Page;
72
- context: BrowserContext;
73
- targetMode: 'desktop' | 'preview';
74
- currentViewport: {
75
- width: number;
76
- height: number;
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
- setMockIpc: (action: string, data: any, options?: {
120
- type?: MockIpcResponseType;
121
- delayMs?: number;
122
- }) => Promise<void>;
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
- setMockRoute: (url: string, body: any, options?: {
132
- method?: string;
133
- status?: number;
134
- delayMs?: number;
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
- interface VisualScenario {
153
- /** Unique scenario identifier (kebab-case) */
154
- id: string;
155
- /** Human-readable title for the report */
156
- title: string;
157
- /** Description of what is being tested */
158
- description?: string;
159
- /** Initial route to navigate to (e.g., '/instances', '/settings') */
160
- route?: string;
161
- /** List of viewport sizes to test */
162
- viewports?: ViewportPreset[];
163
- /**
164
- * Initial IPC mock data for preview mode.
165
- * Applied BEFORE navigation to the route.
166
- */
167
- mockIpc?: Array<{
168
- action: string;
169
- data: any;
170
- type?: MockIpcResponseType;
171
- delayMs?: number;
172
- }>;
173
- /**
174
- * Initial HTTP REST/GraphQL route mocks for preview mode.
175
- * Applied BEFORE navigation to the route.
176
- */
177
- mockRoutes?: MockRouteEntry[];
178
- /**
179
- * Optional setup hook: executed before the browser navigates and scenario runs.
180
- * Ideal for preparing mock files, test directories, or initial state.
181
- */
182
- setup?: () => Promise<void> | void;
183
- /** The main body of the scenario */
184
- run: (ctx: TestContext) => Promise<void>;
185
- /**
186
- * Optional teardown hook: guaranteed to execute in finally, even if run() fails.
187
- * Ideal for cleaning up test artifacts, cache directories, or temporary state.
188
- */
189
- teardown?: () => Promise<void> | void;
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, type CaptureOptions, type MockRouteEntry, type SnapshotMetadata, type TestContext, VIEWPORT_PRESETS, type ViewportPreset, type VisualScenario, defineVisualTest };
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 ConsoleEntry {
4
- level: 'error' | 'warning' | 'info' | 'log' | 'debug';
5
- text: string;
6
- url: string;
7
- timestamp: string;
8
- stack?: string;
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
- * Generic Mock IPC Registry for Preview Mode
13
- *
14
- * Injects a global `window.__mockIpc` that web apps or mocked electron/tauri APIs can call.
15
- */
16
- type MockIpcResponseType = 'SUCCESS' | 'ERROR';
17
-
18
- interface ViewportPreset {
19
- name: string;
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
- interface CaptureOptions {
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
- interface CaptureBurstOptions {
47
- /** Total duration of burst animation capture in milliseconds */
48
- durationMs: number;
49
- /** Interval between frames in milliseconds (default: 80ms) */
50
- intervalMs?: number;
51
- /** Restrict capture to a specific element */
52
- selector?: string;
53
- }
54
- interface SnapshotMetadata {
55
- index: number;
56
- name: string;
57
- fileName: string;
58
- filePath: string;
59
- relativeUri: string;
60
- viewport: {
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
- interface TestContext {
71
- page: Page;
72
- context: BrowserContext;
73
- targetMode: 'desktop' | 'preview';
74
- currentViewport: {
75
- width: number;
76
- height: number;
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
- setMockIpc: (action: string, data: any, options?: {
120
- type?: MockIpcResponseType;
121
- delayMs?: number;
122
- }) => Promise<void>;
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
- setMockRoute: (url: string, body: any, options?: {
132
- method?: string;
133
- status?: number;
134
- delayMs?: number;
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
- interface VisualScenario {
153
- /** Unique scenario identifier (kebab-case) */
154
- id: string;
155
- /** Human-readable title for the report */
156
- title: string;
157
- /** Description of what is being tested */
158
- description?: string;
159
- /** Initial route to navigate to (e.g., '/instances', '/settings') */
160
- route?: string;
161
- /** List of viewport sizes to test */
162
- viewports?: ViewportPreset[];
163
- /**
164
- * Initial IPC mock data for preview mode.
165
- * Applied BEFORE navigation to the route.
166
- */
167
- mockIpc?: Array<{
168
- action: string;
169
- data: any;
170
- type?: MockIpcResponseType;
171
- delayMs?: number;
172
- }>;
173
- /**
174
- * Initial HTTP REST/GraphQL route mocks for preview mode.
175
- * Applied BEFORE navigation to the route.
176
- */
177
- mockRoutes?: MockRouteEntry[];
178
- /**
179
- * Optional setup hook: executed before the browser navigates and scenario runs.
180
- * Ideal for preparing mock files, test directories, or initial state.
181
- */
182
- setup?: () => Promise<void> | void;
183
- /** The main body of the scenario */
184
- run: (ctx: TestContext) => Promise<void>;
185
- /**
186
- * Optional teardown hook: guaranteed to execute in finally, even if run() fails.
187
- * Ideal for cleaning up test artifacts, cache directories, or temporary state.
188
- */
189
- teardown?: () => Promise<void> | void;
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, type CaptureOptions, type MockRouteEntry, type SnapshotMetadata, type TestContext, VIEWPORT_PRESETS, type ViewportPreset, type VisualScenario, defineVisualTest };
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 };