@fliwright/cli 0.0.0-stage → 0.1.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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -2
  3. package/dist/ArtifactReferences.d.ts +7 -0
  4. package/dist/ArtifactReferences.js +82 -0
  5. package/dist/CommandRegistry.d.ts +40 -0
  6. package/dist/CommandRegistry.js +177 -0
  7. package/dist/InspectionOutput.d.ts +5 -0
  8. package/dist/InspectionOutput.js +11 -0
  9. package/dist/RecordingReplay.d.ts +24 -0
  10. package/dist/RecordingReplay.js +79 -0
  11. package/dist/WorkflowContext.d.ts +20 -0
  12. package/dist/WorkflowContext.js +1 -0
  13. package/dist/capabilities/form.d.ts +13 -0
  14. package/dist/capabilities/form.js +9 -0
  15. package/dist/capabilities/interaction.d.ts +226 -0
  16. package/dist/capabilities/interaction.js +447 -0
  17. package/dist/capabilities/session.d.ts +18 -0
  18. package/dist/capabilities/session.js +55 -0
  19. package/dist/catalog.d.ts +36 -0
  20. package/dist/catalog.js +69 -0
  21. package/dist/commands/app-inspect.d.ts +96 -0
  22. package/dist/commands/app-inspect.js +70 -0
  23. package/dist/commands/app.d.ts +53 -0
  24. package/dist/commands/app.js +104 -0
  25. package/dist/commands/artifact-query.d.ts +138 -0
  26. package/dist/commands/artifact-query.js +81 -0
  27. package/dist/commands/artifacts.d.ts +40 -0
  28. package/dist/commands/artifacts.js +311 -0
  29. package/dist/commands/doctor.d.ts +11 -0
  30. package/dist/commands/doctor.js +285 -0
  31. package/dist/commands/flow-runtime.d.ts +40 -0
  32. package/dist/commands/flow-runtime.js +37 -0
  33. package/dist/commands/flow.d.ts +122 -0
  34. package/dist/commands/flow.js +236 -0
  35. package/dist/commands/generate-test.d.ts +46 -0
  36. package/dist/commands/generate-test.js +233 -0
  37. package/dist/commands/init.d.ts +22 -0
  38. package/dist/commands/init.js +262 -0
  39. package/dist/commands/mock-management.d.ts +53 -0
  40. package/dist/commands/mock-management.js +65 -0
  41. package/dist/commands/mock.d.ts +8 -0
  42. package/dist/commands/mock.js +27 -0
  43. package/dist/commands/record.d.ts +55 -0
  44. package/dist/commands/record.js +216 -0
  45. package/dist/commands/run.d.ts +93 -0
  46. package/dist/commands/run.js +707 -0
  47. package/dist/commands/scenario.d.ts +26 -0
  48. package/dist/commands/scenario.js +39 -0
  49. package/dist/commands/tdd.d.ts +72 -0
  50. package/dist/commands/tdd.js +218 -0
  51. package/dist/config.d.ts +20 -0
  52. package/dist/config.js +40 -0
  53. package/dist/index.d.ts +10 -0
  54. package/dist/index.js +139 -0
  55. package/dist/registry/devices.d.ts +2 -0
  56. package/dist/registry/devices.js +12 -0
  57. package/dist/registry/finite.d.ts +38 -0
  58. package/dist/registry/finite.js +121 -0
  59. package/dist/registry/flow-schemas.d.ts +405 -0
  60. package/dist/registry/flow-schemas.js +98 -0
  61. package/dist/registry/flow.d.ts +3 -0
  62. package/dist/registry/flow.js +56 -0
  63. package/dist/registry/generation-schema.d.ts +112 -0
  64. package/dist/registry/generation-schema.js +36 -0
  65. package/dist/registry/session.d.ts +2 -0
  66. package/dist/registry/session.js +24 -0
  67. package/dist/registry/tdd.d.ts +3 -0
  68. package/dist/registry/tdd.js +118 -0
  69. package/dist/reporter.d.ts +95 -0
  70. package/dist/reporter.js +61 -0
  71. package/dist/run.d.ts +6 -0
  72. package/dist/run.js +5 -0
  73. package/dist/session/ConnectionHost.d.ts +43 -0
  74. package/dist/session/ConnectionHost.js +129 -0
  75. package/dist/session/client.d.ts +38 -0
  76. package/dist/session/client.js +120 -0
  77. package/dist/session/worker.d.ts +1 -0
  78. package/dist/session/worker.js +161 -0
  79. package/dist/vm-discovery.d.ts +14 -0
  80. package/dist/vm-discovery.js +85 -0
  81. package/package.json +78 -3
@@ -0,0 +1,55 @@
1
+ import { EndpointLeaseManager, FliwrightDriver } from '@fliwright/core';
2
+ import { resolveProjectConfig } from '../config.js';
3
+ import { resolveVmUrl } from '../vm-discovery.js';
4
+ export async function connectAppSession(options = {}, deps = {}) {
5
+ options.signal?.throwIfAborted();
6
+ const cwd = options.cwd ?? process.cwd();
7
+ const config = await resolveProjectConfig(cwd);
8
+ const vmServiceUrl = await (deps.resolveVmUrl ?? resolveVmUrl)({
9
+ cliFlag: options.vmUrl,
10
+ configUrl: config.vmServiceUrl,
11
+ cwd,
12
+ verify: false,
13
+ });
14
+ if (!vmServiceUrl) {
15
+ throw new Error('Could not find a running Flutter VM Service. Pass --vm-url or start the app with the Fliwright bridge enabled.');
16
+ }
17
+ const driver = deps.driverFactory ? await deps.driverFactory() : new FliwrightDriver({ cacheRoot: config.cacheRoot });
18
+ const abort = () => { void driver.dispose({ signal: AbortSignal.abort(options.signal?.reason) }).catch(() => { }); };
19
+ options.signal?.addEventListener('abort', abort, { once: true });
20
+ try {
21
+ await driver.connect(vmServiceUrl);
22
+ options.signal?.throwIfAborted();
23
+ }
24
+ catch (error) {
25
+ await driver.dispose().catch(() => { });
26
+ throw error;
27
+ }
28
+ finally {
29
+ options.signal?.removeEventListener('abort', abort);
30
+ }
31
+ return { driver, vmServiceUrl };
32
+ }
33
+ export async function withAppSession(options, operation, deps = {}) {
34
+ const session = deps.sessionProvider ? await deps.sessionProvider() : await connectAppSession(options, deps);
35
+ try {
36
+ const lease = await endpointLeases.acquire(session.vmServiceUrl, { signal: options.signal });
37
+ const abort = () => { void session.driver.dispose({ signal: AbortSignal.abort(options.signal?.reason) }).catch(() => { }); };
38
+ options.signal?.addEventListener('abort', abort, { once: true });
39
+ try {
40
+ options.signal?.throwIfAborted();
41
+ const result = await lease.run(() => operation(session));
42
+ options.signal?.throwIfAborted();
43
+ return result;
44
+ }
45
+ finally {
46
+ options.signal?.removeEventListener('abort', abort);
47
+ await lease.release();
48
+ }
49
+ }
50
+ finally {
51
+ if (!deps.sessionProvider)
52
+ await session.driver.dispose();
53
+ }
54
+ }
55
+ const endpointLeases = new EndpointLeaseManager();
@@ -0,0 +1,36 @@
1
+ export interface CatalogCase {
2
+ caseId: string;
3
+ file: string;
4
+ titlePath: string[];
5
+ duplicateIndex: number;
6
+ }
7
+ export interface CatalogSelection extends CatalogCase {
8
+ }
9
+ export declare function catalogCaseId(file: string, titlePath: string[], duplicateIndex: number): string;
10
+ /** Translate the actual collected task tree, preserving duplicate title ordinals. */
11
+ export declare function collectedCases(modules: Iterable<any>, root: string): Array<CatalogCase & {
12
+ test: any;
13
+ }>;
14
+ /** Collection only: imports trusted project modules but never starts an app or runs hooks/tests. */
15
+ export declare function collectCatalog(options: {
16
+ cwd: string;
17
+ suites: Record<string, string>;
18
+ }): Promise<{
19
+ suites: {
20
+ id: string;
21
+ pattern: string;
22
+ files: string[];
23
+ cases: {
24
+ caseId: string;
25
+ file: string;
26
+ titlePath: string[];
27
+ duplicateIndex: number;
28
+ }[];
29
+ }[];
30
+ scenarios: {
31
+ name: string;
32
+ fingerprint: string;
33
+ }[];
34
+ scannerVersion: string;
35
+ fliwrightVersion: string;
36
+ }>;
@@ -0,0 +1,69 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { realpath } from 'node:fs/promises';
3
+ import { isAbsolute, relative, resolve } from 'node:path';
4
+ import { createJiti } from 'jiti';
5
+ import { loadConfig } from './config.js';
6
+ export function catalogCaseId(file, titlePath, duplicateIndex) {
7
+ return createHash('sha256').update(JSON.stringify([file, titlePath, duplicateIndex])).digest('hex');
8
+ }
9
+ /** Translate the actual collected task tree, preserving duplicate title ordinals. */
10
+ export function collectedCases(modules, root) {
11
+ const cases = [];
12
+ const counts = new Map();
13
+ for (const module of modules) {
14
+ if (module.errors().length)
15
+ throw new Error('Test module collection failed', { cause: module.errors()[0] });
16
+ const file = relative(root, module.moduleId).split('\\').join('/');
17
+ if (isAbsolute(file) || file.startsWith('../'))
18
+ throw new Error('Test file escapes project');
19
+ for (const test of module.children.allTests()) {
20
+ const titlePath = [test.name];
21
+ let parent = test.parent;
22
+ while (parent && parent.type !== 'module') {
23
+ titlePath.unshift(parent.name);
24
+ parent = parent.parent;
25
+ }
26
+ const key = JSON.stringify([file, titlePath]);
27
+ const duplicateIndex = counts.get(key) ?? 0;
28
+ counts.set(key, duplicateIndex + 1);
29
+ cases.push({ caseId: catalogCaseId(file, titlePath, duplicateIndex), file, titlePath, duplicateIndex, test });
30
+ }
31
+ }
32
+ return cases;
33
+ }
34
+ /** Collection only: imports trusted project modules but never starts an app or runs hooks/tests. */
35
+ export async function collectCatalog(options) {
36
+ const root = await realpath(options.cwd);
37
+ const resolver = createJiti(resolve(root, 'package.json'));
38
+ const url = resolver.esmResolve('vitest/node', { try: true }) ?? import.meta.resolve('vitest/node');
39
+ const { createVitest } = await import(url);
40
+ const config = await loadConfig(root);
41
+ const scenarios = Object.entries(config.scenarios ?? {}).map(([name, scenario]) => {
42
+ return { name, fingerprint: createHash('sha256').update(JSON.stringify(scenario)).digest('hex') };
43
+ });
44
+ const suites = [];
45
+ for (const [id, pattern] of Object.entries(options.suites)) {
46
+ if (isAbsolute(pattern) || pattern.split(/[\\/]/).includes('..'))
47
+ throw new Error('Suite path escapes project');
48
+ const context = await createVitest({ root, watch: false, include: [pattern], reporters: [], maxWorkers: 1,
49
+ configLoader: 'runner', cache: false, fsModuleCache: false });
50
+ try {
51
+ const result = await context.collect([], { staticParse: false });
52
+ if (result.unhandledErrors.length)
53
+ throw new Error('Unhandled collection error');
54
+ const cases = collectedCases(result.testModules, root).map(({ test: _test, ...item }) => item);
55
+ for (const item of cases) {
56
+ const path = relative(root, await realpath(resolve(root, item.file)));
57
+ if (path.startsWith('../') || isAbsolute(path))
58
+ throw new Error('Test symlink escapes project');
59
+ }
60
+ if (cases.length > 10000)
61
+ throw new Error('Catalog case limit exceeded');
62
+ suites.push({ id, pattern, files: [...new Set(cases.map(item => item.file))], cases });
63
+ }
64
+ finally {
65
+ await context.close();
66
+ }
67
+ }
68
+ return { suites, scenarios, scannerVersion: 'vitest-collection-v1', fliwrightVersion: '0.1.0' };
69
+ }
@@ -0,0 +1,96 @@
1
+ import { diagnosticsInteraction, findInteraction } from '../capabilities/interaction.js';
2
+ import { type AppSessionOptions, type AppSessionDeps } from '../capabilities/session.js';
3
+ export declare function appSnapshotCommand(options: AppSessionOptions & {
4
+ depth?: number;
5
+ includeRects?: boolean;
6
+ includeProperties?: boolean;
7
+ }, deps?: AppSessionDeps): Promise<import("../capabilities/interaction.js").SnapshotResult>;
8
+ export declare function appFindCommand(options: AppSessionOptions & Parameters<typeof findInteraction>[1], deps?: AppSessionDeps): Promise<{
9
+ matches: import("../capabilities/interaction.js").SnapshotRef[];
10
+ count: number;
11
+ }>;
12
+ export declare function appSourceMapCommand(options: AppSessionOptions & {
13
+ includeFramework?: boolean;
14
+ includeRects?: boolean;
15
+ includeProperties?: boolean;
16
+ limit?: number;
17
+ }, deps?: AppSessionDeps): Promise<import("@fliwright/core").SourceMapResult>;
18
+ export declare function appDiagnosticsCommand(options: AppSessionOptions & Parameters<typeof diagnosticsInteraction>[1], deps?: AppSessionDeps): Promise<import("../capabilities/interaction.js").DiagnosticsResult>;
19
+ export declare function appReloadCommand(options: AppSessionOptions & {
20
+ depth?: number;
21
+ includeRects?: boolean;
22
+ includeProperties?: boolean;
23
+ includeScreenshot?: boolean;
24
+ screenshotPixelRatio?: number;
25
+ output?: string;
26
+ }, deps?: AppSessionDeps): Promise<{
27
+ screenshot: {
28
+ path: string;
29
+ } | undefined;
30
+ reloaded: boolean;
31
+ durationMs: number;
32
+ reloadResult?: unknown;
33
+ snapshot?: import("../capabilities/interaction.js").SnapshotResult;
34
+ exceptions: Array<{
35
+ kind: "reload" | "snapshot" | "screenshot";
36
+ message: string;
37
+ }>;
38
+ }>;
39
+ export declare function appDebugSnapshotCommand(options: AppSessionOptions & {
40
+ depth?: number;
41
+ includeRects?: boolean;
42
+ includeProperties?: boolean;
43
+ includeScreenshot?: boolean;
44
+ pixelRatio?: number;
45
+ includeDiagnostics?: boolean;
46
+ diagnosticLimit?: number;
47
+ includeMockStatus?: boolean;
48
+ mockRecentCallsLimit?: number;
49
+ includeSourceMap?: boolean;
50
+ sourceMapLimit?: number;
51
+ output?: string;
52
+ }, deps?: AppSessionDeps): Promise<{
53
+ snapshot: import("@fliwright/core").AgentSnapshotResult;
54
+ diagnostics: import("../capabilities/interaction.js").DiagnosticsResult | undefined;
55
+ mock: {
56
+ rules: {
57
+ endpoint: string;
58
+ method: string;
59
+ rules: string[];
60
+ activeRule: string;
61
+ }[];
62
+ routes: {
63
+ id: string;
64
+ method?: string;
65
+ path: string;
66
+ }[];
67
+ calls: import("@fliwright/core").MockCall[];
68
+ } | undefined;
69
+ sourceMap: import("@fliwright/core").SourceMapResult | undefined;
70
+ screenshot: {
71
+ path: string;
72
+ mimeType: string;
73
+ } | undefined;
74
+ partial: boolean;
75
+ errors: {
76
+ section: string;
77
+ message: string;
78
+ }[];
79
+ route?: {
80
+ location?: string;
81
+ name?: string;
82
+ };
83
+ focused?: {
84
+ ref?: string;
85
+ role?: string;
86
+ label?: string;
87
+ type?: string;
88
+ key?: string;
89
+ };
90
+ keyboard?: import("@fliwright/core").SoftKeyboardState;
91
+ capabilities?: Record<string, boolean>;
92
+ lastFailures: import("../reporter.js").CliFailureEntry[] | undefined;
93
+ tdd: import("@fliwright/tdd").RuntimeSnapshot | null;
94
+ connected: boolean;
95
+ capturedAt: string;
96
+ }>;
@@ -0,0 +1,70 @@
1
+ import { inspectionOutput } from '../InspectionOutput.js';
2
+ import { artifactsFailuresCommand } from './artifact-query.js';
3
+ import { tddStatusCommand } from './tdd.js';
4
+ import { mockListCommand } from './mock-management.js';
5
+ import { CliError } from '../CommandRegistry.js';
6
+ import { mkdir, writeFile } from 'node:fs/promises';
7
+ import { dirname } from 'node:path';
8
+ import { diagnosticsInteraction, findInteraction, hotReloadAndSnapInteraction, snapInteraction } from '../capabilities/interaction.js';
9
+ import { withAppSession } from '../capabilities/session.js';
10
+ export async function appSnapshotCommand(options, deps = {}) {
11
+ return withAppSession(options, ({ driver }) => snapInteraction(driver, options), deps);
12
+ }
13
+ export async function appFindCommand(options, deps = {}) {
14
+ return withAppSession(options, ({ driver }) => findInteraction(driver, options), deps);
15
+ }
16
+ export async function appSourceMapCommand(options, deps = {}) {
17
+ return withAppSession(options, ({ driver }) => driver.page.sourceMap(options), deps);
18
+ }
19
+ export async function appDiagnosticsCommand(options, deps = {}) {
20
+ return withAppSession(options, ({ driver }) => diagnosticsInteraction(driver, options), deps);
21
+ }
22
+ export async function appReloadCommand(options, deps = {}) {
23
+ return withAppSession(options, async ({ driver }) => {
24
+ const result = await hotReloadAndSnapInteraction(driver, { ...options, pixelRatio: options.screenshotPixelRatio, includeScreenshot: options.includeScreenshot ?? false });
25
+ const { screenshot: base64, ...data } = result;
26
+ let screenshot;
27
+ if (base64) {
28
+ const path = await inspectionOutput(options, 'reload');
29
+ await mkdir(dirname(path), { recursive: true });
30
+ await writeFile(path, Buffer.from(base64, 'base64'));
31
+ screenshot = { path };
32
+ }
33
+ if (!result.reloaded || result.exceptions.length)
34
+ throw new CliError('RELOAD_FAILED', 'Hot reload or capture failed.', 3, { ...data, screenshot });
35
+ return { ...data, screenshot };
36
+ }, deps);
37
+ }
38
+ export async function appDebugSnapshotCommand(options, deps = {}) {
39
+ return withAppSession(options, async ({ driver }) => {
40
+ const errors = [];
41
+ async function section(name, execute) {
42
+ try {
43
+ return await execute();
44
+ }
45
+ catch (error) {
46
+ errors.push({ section: name, message: error instanceof Error ? error.message : String(error) });
47
+ return undefined;
48
+ }
49
+ }
50
+ // A structural snapshot is required; optional channels can fail independently.
51
+ const snapshot = await driver.page.snapshot(options);
52
+ if (snapshot.error)
53
+ throw new Error(snapshot.error);
54
+ const context = await section('context', () => driver.page.context());
55
+ const diagnostics = options.includeDiagnostics !== false ? await section('diagnostics', () => diagnosticsInteraction(driver, { limit: options.diagnosticLimit ?? 20 })) : undefined;
56
+ const mock = options.includeMockStatus !== false ? await section('mock', async () => ({
57
+ rules: (await mockListCommand(options)).rules, routes: await driver.mock.listFlutterRoutes(), calls: (await driver.mock.getFlutterCalls()).slice(-(options.mockRecentCallsLimit ?? 20)),
58
+ })) : undefined;
59
+ const sourceMap = options.includeSourceMap ? await section('sourceMap', () => driver.page.sourceMap({ ...options, limit: options.sourceMapLimit })) : undefined;
60
+ const screenshot = options.includeScreenshot ? await section('screenshot', async () => {
61
+ const path = await inspectionOutput(options, 'debug');
62
+ await mkdir(dirname(path), { recursive: true });
63
+ await writeFile(path, await driver.page.screenshot({ pixelRatio: options.pixelRatio }));
64
+ return { path, mimeType: 'image/png' };
65
+ }) : undefined;
66
+ const lastFailures = await section('failures', async () => (await artifactsFailuresCommand({ cwd: options.cwd })).failures);
67
+ const tdd = await tddStatusCommand({ configRoot: options.cwd ?? process.cwd(), print: false });
68
+ return { lastFailures, tdd, connected: true, capturedAt: new Date().toISOString(), ...context, snapshot, diagnostics, mock, sourceMap, screenshot, partial: errors.length > 0, errors };
69
+ }, deps);
70
+ }
@@ -0,0 +1,53 @@
1
+ import { type ActionName, type NavigationAction, type NavigationOptions } from '../capabilities/interaction.js';
2
+ import { type AppSessionDeps, type AppSessionOptions } from '../capabilities/session.js';
3
+ export interface AppObserveOptions extends AppSessionOptions {
4
+ intent?: string;
5
+ roles?: string;
6
+ limit?: number;
7
+ includeDiagnostics?: boolean;
8
+ }
9
+ export interface AppInteractOptions extends AppSessionOptions, NavigationOptions {
10
+ operation: 'tap' | 'type' | 'navigate' | 'wait' | 'drag' | 'action';
11
+ ref?: string;
12
+ key?: string;
13
+ text?: string;
14
+ type?: string;
15
+ value?: string | number;
16
+ replace?: boolean;
17
+ path?: string;
18
+ homeRoute?: string;
19
+ navigationAction?: NavigationAction;
20
+ timeout?: number;
21
+ deltaX?: number;
22
+ deltaY?: number;
23
+ steps?: number;
24
+ x?: number;
25
+ y?: number;
26
+ action?: ActionName;
27
+ keyboardKey?: string;
28
+ checked?: boolean;
29
+ quietMs?: number;
30
+ includeSnapshot?: boolean;
31
+ }
32
+ export declare function appStatusCommand(options: AppSessionOptions, deps?: AppSessionDeps): Promise<{
33
+ connected: boolean;
34
+ vmServiceUrl: string;
35
+ dartSdkVersion: string | null;
36
+ }>;
37
+ export declare function appObserveCommand(options: AppObserveOptions, deps?: AppSessionDeps): Promise<{
38
+ candidates: Array<import("../capabilities/interaction.js").SnapshotRef & {
39
+ diagnostics?: Record<string, unknown>;
40
+ }>;
41
+ count: number;
42
+ }>;
43
+ export declare function appInteractCommand(options: AppInteractOptions, deps?: AppSessionDeps): Promise<unknown>;
44
+ export declare function appScreenshotCommand(options: AppSessionOptions & {
45
+ output?: string;
46
+ pixelRatio?: number;
47
+ fullPage?: boolean;
48
+ scrollable?: string;
49
+ maxHeight?: number;
50
+ }, deps?: AppSessionDeps): Promise<{
51
+ path: string;
52
+ bytes: number;
53
+ }>;
@@ -0,0 +1,104 @@
1
+ import { inspectionOutput } from '../InspectionOutput.js';
2
+ import { CliError } from '../CommandRegistry.js';
3
+ import { mkdir, writeFile } from 'node:fs/promises';
4
+ import { dirname } from 'node:path';
5
+ import { actionInteraction, dragInteraction, navigateInteraction, observeInteraction, tapInteraction, typeInteraction, waitInteraction, } from '../capabilities/interaction.js';
6
+ import { withAppSession } from '../capabilities/session.js';
7
+ export async function appStatusCommand(options, deps = {}) {
8
+ return withAppSession(options, async ({ driver, vmServiceUrl }) => ({
9
+ connected: true,
10
+ vmServiceUrl,
11
+ dartSdkVersion: driver.sdkVersion,
12
+ }), deps);
13
+ }
14
+ export async function appObserveCommand(options, deps = {}) {
15
+ return withAppSession(options, ({ driver }) => observeInteraction(driver, options), deps);
16
+ }
17
+ export async function appInteractCommand(options, deps = {}) {
18
+ if (!['tap', 'type', 'navigate', 'wait', 'drag', 'action'].includes(options.operation)) {
19
+ throw new CliError('INVALID_INPUT', `Unknown interaction operation: ${options.operation}`, 2);
20
+ }
21
+ if (options.operation === 'type' && typeof options.value !== 'string')
22
+ throw new CliError('INVALID_INPUT', 'app interact type requires --value', 2);
23
+ if (options.operation === 'drag' && (options.deltaX === undefined || options.deltaY === undefined)) {
24
+ throw new CliError('INVALID_INPUT', 'app interact drag requires --delta-x and --delta-y', 2);
25
+ }
26
+ if (options.operation === 'action' && !options.action)
27
+ throw new CliError('INVALID_INPUT', 'app interact action requires --action', 2);
28
+ const targetCount = [options.ref, options.key, options.text, options.type].filter((value) => value !== undefined).length;
29
+ const globalAction = options.operation === 'action' && ['dismissModal', 'dismissKeyboard', 'waitForNetworkIdle'].includes(options.action ?? '');
30
+ const coordinates = (options.operation === 'drag' || options.action === 'drag') && options.x !== undefined && options.y !== undefined;
31
+ if (options.operation !== 'navigate' && !globalAction && !coordinates && targetCount !== 1)
32
+ throw new CliError('INVALID_INPUT', 'Choose exactly one target: ref, key, text, or type.', 2);
33
+ if (options.operation === 'navigate' && (options.navigationAction ?? 'goto') !== 'resetToHome' && !options.path)
34
+ throw new CliError('INVALID_INPUT', 'Navigation requires path.', 2);
35
+ if (options.action === 'pressKey' && !options.keyboardKey)
36
+ throw new CliError('INVALID_INPUT', 'pressKey requires keyboardKey.', 2);
37
+ if (options.action === 'setCheckbox' && options.checked === undefined)
38
+ throw new CliError('INVALID_INPUT', 'setCheckbox requires checked.', 2);
39
+ if (options.action === 'selectOption' && options.value === undefined)
40
+ throw new CliError('INVALID_INPUT', 'selectOption requires value.', 2);
41
+ return withAppSession(options, async ({ driver }) => {
42
+ const target = {
43
+ ref: options.ref,
44
+ key: options.key,
45
+ text: options.text,
46
+ type: options.type,
47
+ includeSnapshot: options.includeSnapshot,
48
+ };
49
+ switch (options.operation) {
50
+ case 'tap': return tapInteraction(driver, target);
51
+ case 'type':
52
+ if (typeof options.value !== 'string')
53
+ throw new CliError('INVALID_INPUT', 'app interact type requires --value', 2);
54
+ return typeInteraction(driver, { ...target, value: options.value, replace: options.replace });
55
+ case 'navigate':
56
+ return navigateInteraction(driver, {
57
+ ...options,
58
+ action: options.navigationAction,
59
+ path: options.path,
60
+ homeRoute: options.homeRoute,
61
+ includeSnapshot: options.includeSnapshot,
62
+ });
63
+ case 'wait': return waitInteraction(driver, { ...target, timeout: options.timeout });
64
+ case 'drag':
65
+ if (options.deltaX === undefined || options.deltaY === undefined) {
66
+ throw new CliError('INVALID_INPUT', 'app interact drag requires --delta-x and --delta-y', 2);
67
+ }
68
+ return dragInteraction(driver, {
69
+ ...target,
70
+ deltaX: options.deltaX,
71
+ deltaY: options.deltaY,
72
+ steps: options.steps,
73
+ x: options.x,
74
+ y: options.y,
75
+ });
76
+ case 'action':
77
+ if (!options.action)
78
+ throw new CliError('INVALID_INPUT', 'app interact action requires --action', 2);
79
+ return actionInteraction(driver, {
80
+ ...target,
81
+ action: options.action,
82
+ quietMs: options.quietMs,
83
+ keyboardKey: options.keyboardKey,
84
+ checked: options.checked,
85
+ value: options.value,
86
+ deltaX: options.deltaX,
87
+ deltaY: options.deltaY,
88
+ steps: options.steps,
89
+ x: options.x,
90
+ y: options.y,
91
+ timeout: options.timeout,
92
+ });
93
+ }
94
+ }, deps);
95
+ }
96
+ export async function appScreenshotCommand(options, deps = {}) {
97
+ return withAppSession(options, async ({ driver }) => {
98
+ const output = await inspectionOutput(options, 'screenshot');
99
+ const screenshot = await driver.page.screenshot({ pixelRatio: options.pixelRatio, fullPage: options.fullPage, scrollable: options.scrollable, maxHeight: options.maxHeight });
100
+ await mkdir(dirname(output), { recursive: true });
101
+ await writeFile(output, screenshot);
102
+ return { path: output, bytes: screenshot.byteLength };
103
+ }, deps);
104
+ }
@@ -0,0 +1,138 @@
1
+ import { type AgentVisibleFailure } from '@fliwright/core';
2
+ import { type ArtifactOptions } from './artifacts.js';
3
+ export declare function artifactsFailuresCommand(options: ArtifactOptions & {
4
+ testName?: string;
5
+ }): Promise<{
6
+ runId: string | undefined;
7
+ failures: import("../reporter.js").CliFailureEntry[];
8
+ runnerErrors: {
9
+ phase: string;
10
+ message: string;
11
+ stack?: string;
12
+ file?: string;
13
+ }[];
14
+ evidenceStatus: string | undefined;
15
+ }>;
16
+ export declare function artifactsTimelineCommand(options: ArtifactOptions & {
17
+ path?: string;
18
+ testId?: string;
19
+ attemptId?: string;
20
+ nodeId?: string;
21
+ includeArtifacts?: boolean;
22
+ includeFlow?: boolean;
23
+ }): Promise<{
24
+ path: string;
25
+ timeline: {
26
+ nodes: {
27
+ id: string;
28
+ parentId?: string;
29
+ kind: import("@fliwright/core").TimelineNodeKind;
30
+ title: string;
31
+ status: import("@fliwright/core").TimelineNodeStatus;
32
+ startedAt: string;
33
+ endedAt?: string;
34
+ route?: string;
35
+ codeRef?: import("@fliwright/core").CodeRef;
36
+ metadata?: Record<string, unknown>;
37
+ error?: AgentVisibleFailure;
38
+ }[];
39
+ version: 2;
40
+ runId: string;
41
+ testName: string;
42
+ mode: import("@fliwright/core").TimelineRunMode;
43
+ status: import("@fliwright/core").TimelineRunStatus;
44
+ startedAt: string;
45
+ endedAt?: string;
46
+ agentVisibleFailures?: AgentVisibleFailure[];
47
+ };
48
+ flow: import("@fliwright/core").FliwrightFlowDocument | undefined;
49
+ node?: undefined;
50
+ parent?: undefined;
51
+ children?: undefined;
52
+ previous?: undefined;
53
+ next?: undefined;
54
+ } | {
55
+ path: string;
56
+ node: {
57
+ id: string;
58
+ parentId?: string;
59
+ kind: import("@fliwright/core").TimelineNodeKind;
60
+ title: string;
61
+ status: import("@fliwright/core").TimelineNodeStatus;
62
+ startedAt: string;
63
+ endedAt?: string;
64
+ route?: string;
65
+ codeRef?: import("@fliwright/core").CodeRef;
66
+ metadata?: Record<string, unknown>;
67
+ error?: AgentVisibleFailure;
68
+ };
69
+ parent: {
70
+ id: string;
71
+ parentId?: string;
72
+ kind: import("@fliwright/core").TimelineNodeKind;
73
+ title: string;
74
+ status: import("@fliwright/core").TimelineNodeStatus;
75
+ startedAt: string;
76
+ endedAt?: string;
77
+ route?: string;
78
+ codeRef?: import("@fliwright/core").CodeRef;
79
+ metadata?: Record<string, unknown>;
80
+ error?: AgentVisibleFailure;
81
+ } | undefined;
82
+ children: {
83
+ id: string;
84
+ parentId?: string;
85
+ kind: import("@fliwright/core").TimelineNodeKind;
86
+ title: string;
87
+ status: import("@fliwright/core").TimelineNodeStatus;
88
+ startedAt: string;
89
+ endedAt?: string;
90
+ route?: string;
91
+ codeRef?: import("@fliwright/core").CodeRef;
92
+ metadata?: Record<string, unknown>;
93
+ error?: AgentVisibleFailure;
94
+ }[];
95
+ previous: {
96
+ id: string;
97
+ parentId?: string;
98
+ kind: import("@fliwright/core").TimelineNodeKind;
99
+ title: string;
100
+ status: import("@fliwright/core").TimelineNodeStatus;
101
+ startedAt: string;
102
+ endedAt?: string;
103
+ route?: string;
104
+ codeRef?: import("@fliwright/core").CodeRef;
105
+ metadata?: Record<string, unknown>;
106
+ error?: AgentVisibleFailure;
107
+ };
108
+ next: {
109
+ id: string;
110
+ parentId?: string;
111
+ kind: import("@fliwright/core").TimelineNodeKind;
112
+ title: string;
113
+ status: import("@fliwright/core").TimelineNodeStatus;
114
+ startedAt: string;
115
+ endedAt?: string;
116
+ route?: string;
117
+ codeRef?: import("@fliwright/core").CodeRef;
118
+ metadata?: Record<string, unknown>;
119
+ error?: AgentVisibleFailure;
120
+ };
121
+ flow: import("@fliwright/core").FliwrightFlowDocument | undefined;
122
+ timeline?: undefined;
123
+ }>;
124
+ export declare function artifactsDiagnoseCommand(options: ArtifactOptions & {
125
+ path?: string;
126
+ testId?: string;
127
+ attemptId?: string;
128
+ failureIndex?: number;
129
+ failure?: {
130
+ code: string;
131
+ title: string;
132
+ message: string;
133
+ timelineNodeId?: string;
134
+ };
135
+ }): Promise<{
136
+ diagnosis: import("@fliwright/core").AgentDiagnosis | null;
137
+ skipped: boolean;
138
+ }>;