@devicecloud.dev/dcd 5.14.1 → 5.16.0-beta.1
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 +25 -2
- package/dist/commands/artifacts.d.ts +13 -0
- package/dist/commands/artifacts.js +43 -5
- package/dist/commands/device.d.ts +39 -0
- package/dist/commands/device.js +479 -101
- package/dist/e2e/index.d.ts +4 -0
- package/dist/e2e/index.js +41 -0
- package/dist/e2e/provider.d.ts +80 -0
- package/dist/e2e/provider.js +233 -0
- package/dist/gateways/api-gateway.d.ts +25 -3
- package/dist/gateways/api-gateway.js +68 -6
- package/dist/gateways/device-gateway.d.ts +34 -10
- package/dist/gateways/device-gateway.js +72 -17
- package/dist/mcp/bridge.d.ts +30 -16
- package/dist/mcp/bridge.js +201 -64
- package/dist/mcp/local-files.d.ts +14 -0
- package/dist/mcp/local-files.js +75 -0
- package/dist/mcp/tools/download-artifacts.d.ts +4 -1
- package/dist/mcp/tools/download-artifacts.js +44 -17
- package/dist/services/report-download.service.d.ts +32 -0
- package/dist/services/report-download.service.js +51 -2
- package/dist/services/telemetry.service.d.ts +20 -1
- package/dist/services/telemetry.service.js +27 -6
- package/dist/types/domain/device-session.types.d.ts +73 -3
- package/dist/types/domain/device-session.types.js +2 -0
- package/dist/utils/api-url.d.ts +20 -0
- package/dist/utils/api-url.js +49 -0
- package/dist/utils/app-upload.d.ts +6 -0
- package/dist/utils/app-upload.js +19 -0
- package/dist/utils/config-store.d.ts +5 -1
- package/dist/utils/config-store.js +18 -2
- package/dist/utils/device-artifacts.d.ts +5 -0
- package/dist/utils/device-artifacts.js +22 -0
- package/dist/utils/device-bundle.d.ts +39 -9
- package/dist/utils/device-bundle.js +153 -51
- package/dist/utils/device-flags.d.ts +17 -0
- package/dist/utils/device-flags.js +145 -0
- package/dist/utils/device-output.d.ts +53 -7
- package/dist/utils/device-output.js +148 -21
- package/dist/utils/device-run.d.ts +8 -3
- package/dist/utils/device-run.js +85 -8
- package/dist/utils/zip-integrity.d.ts +21 -0
- package/dist/utils/zip-integrity.js +45 -0
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -107,7 +107,9 @@ $ codex mcp add devicecloud -- dcd mcp
|
|
|
107
107
|
|
|
108
108
|
If you use the npm package instead of the standalone binary, the command is `npx` with `"args": ["-y", "@devicecloud.dev/dcd", "mcp"]`. That needs Node 22 or newer on the app's PATH, and it checks npm each time it starts.
|
|
109
109
|
|
|
110
|
-
It signs in the same way as the CLI: with your `dcd login` session, which it renews as it runs, or with `DEVICE_CLOUD_API_KEY`. Point it at a non-prod environment with `DCD_API_URL
|
|
110
|
+
It signs in the same way as the CLI: with your `dcd login` session, which it renews as it runs, or with `DEVICE_CLOUD_API_KEY`. Point it at a non-prod environment with `DCD_API_URL` (https, or plain http to `localhost` only).
|
|
111
|
+
|
|
112
|
+
The tools that take a local path read and write only inside the folder the server was started in, so start it from your project: a flow given to `run` (with the files it uses), and the files `dcd_download_artifacts` writes, which never replace a file the server did not write.
|
|
111
113
|
|
|
112
114
|
### Tools
|
|
113
115
|
|
|
@@ -116,7 +118,7 @@ It signs in the same way as the CLI: with your `dcd login` session, which it ren
|
|
|
116
118
|
| `dcd_list_devices` | Discover available devices, OS versions, and Maestro versions |
|
|
117
119
|
| `dcd_list_runs` | List recent test runs (filter by name/date, paginated) |
|
|
118
120
|
| `dcd_get_status` | Get the status + per-test results of a run |
|
|
119
|
-
| `dcd_download_artifacts` | Download a run's artifacts/report to disk |
|
|
121
|
+
| `dcd_download_artifacts` | Download a run's artifacts/report to disk, inside the working directory |
|
|
120
122
|
| `dcd_get_team_settings` | Read your team's settings: concurrency, test runtime, integrations and more |
|
|
121
123
|
| `dcd_run_cloud_test` | Submit a flow to run on the cloud (**billable**) |
|
|
122
124
|
|
|
@@ -142,6 +144,27 @@ The npm package also ships `dcd-mcp`, an older server with the same `dcd_*` tool
|
|
|
142
144
|
|
|
143
145
|
`--package` matters: the package's default bin is `dcd`, so `npx @devicecloud.dev/dcd dcd-mcp` would run `dcd dcd-mcp` (an unknown command) instead of the server. It signs in like `dcd mcp`, and takes `--read-only` and `DCD_MCP_READONLY=1` the same way.
|
|
144
146
|
|
|
147
|
+
## e2e tests on DeviceCloud devices (early access)
|
|
148
|
+
|
|
149
|
+
`@devicecloud.dev/dcd/e2e` is a device provider for [e2e](https://github.com/e2e-inc/e2e). Each e2e worker gets its own DeviceCloud device session, and e2e drives the device directly. The session shows in the console, is recorded, and is billed like any other. Your organization needs this turned on by DeviceCloud first.
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
// e2e.config.ts
|
|
153
|
+
import type { E2EConfig } from 'e2e';
|
|
154
|
+
import { mobile } from '@e2e-dev/mobile';
|
|
155
|
+
import { deviceCloud } from '@devicecloud.dev/dcd/e2e';
|
|
156
|
+
|
|
157
|
+
const engine = mobile({ platform: 'android', device: deviceCloud() });
|
|
158
|
+
|
|
159
|
+
export default {
|
|
160
|
+
targets: [{ name: 'android', engine, app: { bundleId: 'com.example.app', appPath: './build/app.apk' } }],
|
|
161
|
+
// The first screen read after a launch can take a few seconds.
|
|
162
|
+
assertionTimeout: 20_000,
|
|
163
|
+
} satisfies E2EConfig;
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Run `npx e2e run` with `DEVICE_CLOUD_API_KEY` set. The provider uploads `appPath` once per run and each session installs it, so e2e installs nothing itself. To use a build you already uploaded, pass `deviceCloud({ appBinaryId })`. It also takes `model`, `os` and `maxDurationMin`. Each session's console link is printed as the run starts, and the session is stopped when e2e is done with it.
|
|
167
|
+
|
|
145
168
|
|
|
146
169
|
## Development
|
|
147
170
|
|
|
@@ -17,6 +17,14 @@ export declare const artifactsCommand: import("citty").CommandDef<{
|
|
|
17
17
|
readonly type: "string";
|
|
18
18
|
readonly description: "Custom file path for downloaded artifacts (default: ./artifacts.zip). Requires --download-artifacts.";
|
|
19
19
|
};
|
|
20
|
+
readonly 'result-id': {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "Download only this result's artifacts: its flow's attempts on that one device. Requires --download-artifacts.";
|
|
23
|
+
};
|
|
24
|
+
readonly flow: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly description: "Download only the artifacts of the flow with this file path or name (e.g. flows/login.yaml or login). Fails, listing the result ids, when it matches more than one result, e.g. one per device. Requires --download-artifacts.";
|
|
27
|
+
};
|
|
20
28
|
readonly report: {
|
|
21
29
|
readonly type: "string";
|
|
22
30
|
readonly description: "Download a test report in the specified format (options: junit, html, html-detailed, allure). allure and html-detailed are deprecated and will be removed on 7 December 2026.";
|
|
@@ -48,4 +56,9 @@ export declare const artifactsCommand: import("citty").CommandDef<{
|
|
|
48
56
|
readonly description: "API base URL (defaults to the URL stored by `dcd login`, else prod)";
|
|
49
57
|
};
|
|
50
58
|
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Check --result-id and --flow: at most one, only with --download-artifacts,
|
|
61
|
+
* and a result id that is a positive whole number. Returns the parsed id.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseResultFilter(resultIdArg: string | undefined, flow: string | undefined, downloadingArtifacts: boolean): number | undefined;
|
|
51
64
|
export default artifactsCommand;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import { apiFlags } from '../config/flags/api.flags.js';
|
|
3
3
|
import { jsonFlag } from '../config/flags/output.flags.js';
|
|
4
|
-
import { ReportDownloadService, reportFormatDeprecation, } from '../services/report-download.service.js';
|
|
4
|
+
import { downloadsSucceeded, ReportDownloadService, reportFormatDeprecation, } from '../services/report-download.service.js';
|
|
5
5
|
import { resolveAuth } from '../utils/auth.js';
|
|
6
6
|
import { CliError, logger, validateEnum } from '../utils/cli.js';
|
|
7
7
|
import { resolveApiUrl } from '../utils/config-store.js';
|
|
@@ -33,6 +33,14 @@ export const artifactsCommand = defineCommand({
|
|
|
33
33
|
type: 'string',
|
|
34
34
|
description: 'Custom file path for downloaded artifacts (default: ./artifacts.zip). Requires --download-artifacts.',
|
|
35
35
|
},
|
|
36
|
+
'result-id': {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: "Download only this result's artifacts: its flow's attempts on that one device. Requires --download-artifacts.",
|
|
39
|
+
},
|
|
40
|
+
flow: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Download only the artifacts of the flow with this file path or name (e.g. flows/login.yaml or login). Fails, listing the result ids, when it matches more than one result, e.g. one per device. Requires --download-artifacts.',
|
|
43
|
+
},
|
|
36
44
|
report: {
|
|
37
45
|
type: 'string',
|
|
38
46
|
description: 'Download a test report in the specified format (options: junit, html, html-detailed, allure). allure and html-detailed are deprecated and will be removed on 7 December 2026.',
|
|
@@ -58,6 +66,8 @@ export const artifactsCommand = defineCommand({
|
|
|
58
66
|
const uploadId = args['upload-id'];
|
|
59
67
|
const downloadArtifacts = validateEnum(args['download-artifacts'], DOWNLOAD_OPTIONS, 'download-artifacts');
|
|
60
68
|
const artifactsPath = args['artifacts-path'];
|
|
69
|
+
const resultIdArg = args['result-id'];
|
|
70
|
+
const flow = args.flow;
|
|
61
71
|
const report = validateEnum(args.report, REPORT_OPTIONS, 'report');
|
|
62
72
|
const allurePath = args['allure-path'];
|
|
63
73
|
const htmlPath = args['html-path'];
|
|
@@ -78,6 +88,7 @@ export const artifactsCommand = defineCommand({
|
|
|
78
88
|
if (!downloadArtifacts && !report) {
|
|
79
89
|
throw new CliError('Either --download-artifacts or --report must be specified.');
|
|
80
90
|
}
|
|
91
|
+
const resultId = parseResultFilter(resultIdArg, flow, Boolean(downloadArtifacts));
|
|
81
92
|
const service = new ReportDownloadService();
|
|
82
93
|
const downloads = [];
|
|
83
94
|
if (downloadArtifacts) {
|
|
@@ -87,7 +98,9 @@ export const artifactsCommand = defineCommand({
|
|
|
87
98
|
artifactsPath: artifactsPath ?? './artifacts.zip',
|
|
88
99
|
debug,
|
|
89
100
|
downloadType: downloadArtifacts,
|
|
101
|
+
flow,
|
|
90
102
|
logger: log,
|
|
103
|
+
resultId,
|
|
91
104
|
uploadId,
|
|
92
105
|
warnLogger: (m) => logger.warn(m),
|
|
93
106
|
}));
|
|
@@ -108,13 +121,38 @@ export const artifactsCommand = defineCommand({
|
|
|
108
121
|
if (result)
|
|
109
122
|
downloads.push(result);
|
|
110
123
|
}
|
|
124
|
+
// Downloading is this command's only job, so a failed or incomplete
|
|
125
|
+
// download exits 1, with or without --json. Its warning is already
|
|
126
|
+
// printed, and fail() prints nothing more (no second JSON object).
|
|
127
|
+
const ok = downloadsSucceeded(downloads);
|
|
111
128
|
if (json) {
|
|
112
|
-
const ok = downloads.some((d) => d.ok);
|
|
113
129
|
logger.json({ status: ok ? 'SUCCESS' : 'FAILED', uploadId, downloads });
|
|
114
|
-
// Same exit code a thrown error would give, without a second JSON object.
|
|
115
|
-
if (!ok)
|
|
116
|
-
logger.fail('Every download failed', 1);
|
|
117
130
|
}
|
|
131
|
+
if (!ok)
|
|
132
|
+
logger.fail('Download failed', 1);
|
|
118
133
|
},
|
|
119
134
|
});
|
|
135
|
+
/**
|
|
136
|
+
* Check --result-id and --flow: at most one, only with --download-artifacts,
|
|
137
|
+
* and a result id that is a positive whole number. Returns the parsed id.
|
|
138
|
+
*/
|
|
139
|
+
export function parseResultFilter(resultIdArg, flow, downloadingArtifacts) {
|
|
140
|
+
if (resultIdArg !== undefined && flow !== undefined) {
|
|
141
|
+
throw new CliError('--result-id cannot also be provided when using --flow (flags are mutually exclusive).');
|
|
142
|
+
}
|
|
143
|
+
const flag = resultIdArg === undefined ? (flow === undefined ? undefined : '--flow') : '--result-id';
|
|
144
|
+
if (flag && !downloadingArtifacts) {
|
|
145
|
+
throw new CliError(`${flag} requires --download-artifacts.`);
|
|
146
|
+
}
|
|
147
|
+
if (flow !== undefined && flow.trim() === '') {
|
|
148
|
+
throw new CliError('--flow needs a flow file path or name.');
|
|
149
|
+
}
|
|
150
|
+
if (resultIdArg === undefined)
|
|
151
|
+
return undefined;
|
|
152
|
+
const resultId = Number(resultIdArg);
|
|
153
|
+
if (!/^\d+$/.test(resultIdArg.trim()) || !Number.isSafeInteger(resultId) || resultId <= 0) {
|
|
154
|
+
throw new CliError(`--result-id must be a positive whole number, got '${resultIdArg}'.`);
|
|
155
|
+
}
|
|
156
|
+
return resultId;
|
|
157
|
+
}
|
|
120
158
|
export default artifactsCommand;
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { type DeviceCatalogue, type DeviceScreenElement, type DeviceSession } from '../types/domain/device-session.types.js';
|
|
2
|
+
import { CliError } from '../utils/cli.js';
|
|
3
|
+
/**
|
|
4
|
+
* How the waits poll. `retryMs` is how long a wait keeps asking through
|
|
5
|
+
* failed requests before it gives up, and `retryBaseMs` the first pause
|
|
6
|
+
* between tries (doubled each time, up to 15s). `runGraceMs` is how long a
|
|
7
|
+
* wait for a flow goes on past its session's maximum duration, for the API
|
|
8
|
+
* to end the session. Changed by tests only.
|
|
9
|
+
*/
|
|
10
|
+
export declare const deviceTiming: {
|
|
11
|
+
pollMs: number;
|
|
12
|
+
retryBaseMs: number;
|
|
13
|
+
retryMs: number;
|
|
14
|
+
runGraceMs: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A failure worth asking again: no answer came (a dropped connection, an
|
|
18
|
+
* unreadable reply), or the API or a proxy in front of it was busy or briefly
|
|
19
|
+
* down. A refusal (a 4xx other than 408 and 429) is final.
|
|
20
|
+
*/
|
|
21
|
+
export declare function transientFailure(error: unknown): boolean;
|
|
2
22
|
/**
|
|
3
23
|
* The platform a `--model` belongs to, from GET /device/models. Matches the
|
|
4
24
|
* model id (iphone-16) or its name (iPhone 16), ignoring case. Unknown, or on
|
|
@@ -11,6 +31,13 @@ export declare function platformOfModel(catalogue: DeviceCatalogue, model: strin
|
|
|
11
31
|
* a session with no app gets the install step.
|
|
12
32
|
*/
|
|
13
33
|
export declare function startNextSteps(session: DeviceSession, hasApp: boolean): [string, string][];
|
|
34
|
+
/**
|
|
35
|
+
* The text piped to this command, without the one line break a shell's
|
|
36
|
+
* `echo` adds. Refused at a terminal, where it would wait for typing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readStdinText(stdin?: NodeJS.ReadableStream & {
|
|
39
|
+
isTTY?: boolean;
|
|
40
|
+
}): Promise<string>;
|
|
14
41
|
/** One element on one line: what to target it by, then its bounds. */
|
|
15
42
|
export declare function formatElement(el: DeviceScreenElement): string;
|
|
16
43
|
/** `data:image/jpeg;base64,...` to bytes and a file extension. */
|
|
@@ -18,6 +45,13 @@ export declare function decodeDataUrl(dataUrl: string): {
|
|
|
18
45
|
bytes: Buffer;
|
|
19
46
|
ext: string;
|
|
20
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* `--env-file`: KEY=VALUE lines, as a .env file has them. Blank lines and
|
|
50
|
+
* `#` comments are skipped, `export ` is allowed, and one pair of quotes
|
|
51
|
+
* around a value is removed. A bad line is named by its number only: the
|
|
52
|
+
* line may hold a secret.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseEnvFile(file: string): Record<string, string>;
|
|
21
55
|
/** `--env KEY=VALUE`, given once or several times. */
|
|
22
56
|
export declare function parseEnvFlags(value: unknown): Record<string, string> | undefined;
|
|
23
57
|
/** Every value of a repeatable flag; citty keeps only the last one. */
|
|
@@ -33,4 +67,9 @@ export declare function recoverFlagValue(flag: string, parsed: string | undefine
|
|
|
33
67
|
* starts with. No overlap: everything in `next` is new.
|
|
34
68
|
*/
|
|
35
69
|
export declare function newLogLines(prev: string[], next: string[]): string[];
|
|
70
|
+
/**
|
|
71
|
+
* The usage error for `dcd device <name>` when there is no such subcommand,
|
|
72
|
+
* with the one meant: `press_key` is `press-key` here.
|
|
73
|
+
*/
|
|
74
|
+
export declare function unknownSubcommandError(name: string | undefined): CliError;
|
|
36
75
|
export declare const deviceCommand: import("citty").CommandDef<import("citty").ArgsDef>;
|