@devicecloud.dev/dcd 5.11.0-beta.1 → 5.11.0-beta.11

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 (59) hide show
  1. package/README.md +75 -3
  2. package/dist/commands/cloud.d.ts +1 -1
  3. package/dist/commands/cloud.js +7 -6
  4. package/dist/commands/device.d.ts +36 -0
  5. package/dist/commands/device.js +1151 -0
  6. package/dist/commands/live.d.ts +2 -0
  7. package/dist/commands/live.js +10 -1
  8. package/dist/commands/login.js +2 -17
  9. package/dist/commands/mcp.d.ts +13 -0
  10. package/dist/commands/mcp.js +180 -0
  11. package/dist/commands/upload.js +2 -8
  12. package/dist/config/flags/device.flags.d.ts +1 -1
  13. package/dist/config/flags/device.flags.js +1 -1
  14. package/dist/constants.d.ts +1 -1
  15. package/dist/gateways/device-gateway.d.ts +88 -0
  16. package/dist/gateways/device-gateway.js +140 -0
  17. package/dist/index.js +4 -0
  18. package/dist/mcp/bridge.d.ts +52 -0
  19. package/dist/mcp/bridge.js +288 -0
  20. package/dist/mcp/tools/run-cloud-test.d.ts +13 -0
  21. package/dist/mcp/tools/run-cloud-test.js +18 -8
  22. package/dist/methods.d.ts +24 -0
  23. package/dist/methods.js +147 -169
  24. package/dist/services/device-validation.service.js +1 -1
  25. package/dist/services/execution-plan.service.d.ts +27 -0
  26. package/dist/services/execution-plan.service.js +9 -1
  27. package/dist/services/metadata-extractor.service.d.ts +13 -0
  28. package/dist/services/metadata-extractor.service.js +35 -1
  29. package/dist/services/moropo.service.js +1 -1
  30. package/dist/services/results-polling.service.js +1 -1
  31. package/dist/types/domain/device-session.types.d.ts +211 -0
  32. package/dist/types/domain/device-session.types.js +5 -0
  33. package/dist/types/domain/device.types.d.ts +0 -2
  34. package/dist/types/domain/device.types.js +0 -2
  35. package/dist/types.d.ts +11 -0
  36. package/dist/utils/app-upload.d.ts +19 -0
  37. package/dist/utils/app-upload.js +63 -0
  38. package/dist/utils/auth.d.ts +0 -8
  39. package/dist/utils/auth.js +31 -27
  40. package/dist/utils/b2-retry.d.ts +49 -0
  41. package/dist/utils/b2-retry.js +77 -0
  42. package/dist/utils/browser.d.ts +16 -0
  43. package/dist/utils/browser.js +48 -0
  44. package/dist/utils/compatibility.d.ts +5 -7
  45. package/dist/utils/compatibility.js +5 -13
  46. package/dist/utils/device-artifacts.d.ts +55 -0
  47. package/dist/utils/device-artifacts.js +211 -0
  48. package/dist/utils/device-bundle.d.ts +35 -0
  49. package/dist/utils/device-bundle.js +162 -0
  50. package/dist/utils/device-matrix.js +1 -1
  51. package/dist/utils/device-output.d.ts +81 -0
  52. package/dist/utils/device-output.js +207 -0
  53. package/dist/utils/device-run.d.ts +29 -0
  54. package/dist/utils/device-run.js +113 -0
  55. package/dist/utils/mcp-install.d.ts +50 -0
  56. package/dist/utils/mcp-install.js +132 -0
  57. package/dist/utils/progress.d.ts +4 -0
  58. package/dist/utils/progress.js +45 -21
  59. package/package.json +2 -2
package/README.md CHANGED
@@ -36,9 +36,81 @@ See full documentation: [Docs](https://docs.devicecloud.dev)
36
36
 
37
37
  ## MCP server
38
38
 
39
- The same npm package ships an [MCP](https://modelcontextprotocol.io) server (`dcd-mcp` bin) so AI agents — Claude, Cursor, VS Code — can drive devicecloud.dev directly.
39
+ devicecloud.dev has an [MCP](https://modelcontextprotocol.io) server, so AI agents (Claude, Cursor, VS Code) can run cloud tests and drive cloud devices. You don't run it yourself. You add it to your MCP client's config, and the client starts it.
40
40
 
41
- Add it to your MCP client config:
41
+ There are three ways to connect:
42
+
43
+ | | Install | Tools | Use it when |
44
+ | --- | --- | --- | --- |
45
+ | **`dcd mcp`** (recommended) | the CLI | device tools + `dcd_*` cloud-test tools | you want everything, including installing a local build or running local flow files |
46
+ | **Hosted** `https://api.devicecloud.dev/mcp` | nothing | device tools | the agent only drives devices, with apps and flows that are already uploaded or at a URL |
47
+ | **`dcd-mcp`** | the CLI | `dcd_*` cloud-test tools | you only run cloud tests (the older server; `dcd mcp` covers it) |
48
+
49
+ ### `dcd mcp`
50
+
51
+ `dcd mcp` connects to the hosted server and passes its device tools through. It adds what only a local process can do: `install_app` takes `app_path` (a build on your machine, uploaded first) and `run` takes `path` (a flow file, or a directory uploaded as a bundle). It also serves the `dcd_*` tools below.
52
+
53
+ **Set it up with `dcd mcp install`.** Install the CLI (see the top of this page), sign in, then add the server to your AI tool:
54
+
55
+ ```sh-session
56
+ $ dcd login
57
+ $ dcd mcp install cursor # or claude-code, claude-desktop, vscode
58
+ ```
59
+
60
+ Leave out the client name to pick from a list. Add `--read-only` for a server that only offers tools that change nothing, or `--print` to see what would be added without changing anything. For Claude Code and VS Code it runs `claude mcp add` and `code --add-mcp`. For Claude Desktop and Cursor it adds an entry to their JSON config file and keeps everything else in it. Restart the app afterwards.
61
+
62
+ **Setting it up by hand.** Start dcd by its **full path**. Desktop apps such as Claude Desktop and Cursor are usually opened from the Dock or Start menu, so they don't see the PATH your shell sets up, and a bare `dcd` gives "command not found". The installer prints the path at the end; it's `~/.dcd/bin/dcd` by default, written out in full because config files don't expand `~`.
63
+
64
+ Claude Desktop (`claude_desktop_config.json`) and Cursor (`~/.cursor/mcp.json`):
65
+
66
+ ```jsonc
67
+ {
68
+ "mcpServers": {
69
+ "devicecloud": {
70
+ "command": "/Users/you/.dcd/bin/dcd",
71
+ "args": ["mcp"]
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ VS Code (`.vscode/mcp.json`, or the user `mcp.json`) uses `servers` and a `type`:
78
+
79
+ ```jsonc
80
+ {
81
+ "servers": {
82
+ "devicecloud": {
83
+ "type": "stdio",
84
+ "command": "/Users/you/.dcd/bin/dcd",
85
+ "args": ["mcp"]
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ Claude Code, run from a terminal, does see your PATH:
92
+
93
+ ```sh-session
94
+ $ claude mcp add --scope user devicecloud -- dcd mcp
95
+ ```
96
+
97
+ 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.
98
+
99
+ It signs in the same way as the CLI: run `dcd login` once, or set `DEVICE_CLOUD_API_KEY` in `env`. Add `--read-only` to the args (or set `DCD_MCP_READONLY=1`) to serve only the tools that change nothing. If the hosted server can't be reached, it serves the `dcd_*` tools only and says why on stderr.
100
+
101
+ **Device tools:** `list_devices`, `start_device`, `get_device_status`, `install_app`, `launch_app`, `inspect_screen`, `take_screenshot`, `run`, `get_command_status`, `get_logs`, `request_human`, `get_human_status`, `stop_device`, and `cheat_sheet` (Maestro syntax for the agent).
102
+
103
+ ### Hosted
104
+
105
+ Point an HTTP-capable client at the URL. It signs you in through the browser (OAuth), and you can disconnect it later under Settings → Connected apps.
106
+
107
+ ```sh-session
108
+ $ claude mcp add --transport http devicecloud https://api.devicecloud.dev/mcp
109
+ ```
110
+
111
+ ### `dcd-mcp`
112
+
113
+ The older server, with the `dcd_*` tools only. Add it to your MCP client config:
42
114
 
43
115
  ```jsonc
44
116
  {
@@ -56,7 +128,7 @@ Add it to your MCP client config:
56
128
 
57
129
  Auth is inherited from the CLI: set `DEVICE_CLOUD_API_KEY` as above, or run `dcd login` once and the server picks up the stored session. Point it at a non-prod environment with `DCD_API_URL`.
58
130
 
59
- **Tools**
131
+ **`dcd_*` tools** (served by both `dcd mcp` and `dcd-mcp`)
60
132
 
61
133
  | Tool | What it does |
62
134
  | --- | --- |
@@ -197,7 +197,7 @@ export declare const cloudCommand: import("citty").CommandDef<{
197
197
  };
198
198
  readonly 'android-device-matrix': {
199
199
  readonly type: "string";
200
- readonly description: "[Android only] Device-matrix cell as <device>:<apiLevel> (append :play for Google Play), e.g. pixel-7:34 or pixel-7:34:play. Repeatable — every flow runs once per cell (no cross-product). Cannot be combined with --ios-device-matrix.";
200
+ readonly description: "[Android only] Device-matrix cell as <device>:<apiLevel> (append :play for Google Play), e.g. pixel-8:34 or pixel-8:34:play. Repeatable — every flow runs once per cell (no cross-product). Cannot be combined with --ios-device-matrix.";
201
201
  };
202
202
  readonly orientation: {
203
203
  readonly type: "string";
@@ -6,7 +6,7 @@ import { flags as allFlags } from '../constants.js';
6
6
  import { ApiGateway } from '../gateways/api-gateway.js';
7
7
  import { uploadBinary, uploadFlowZip, verifyAppZip, writeJSONFile, } from '../methods.js';
8
8
  import { DeviceValidationService } from '../services/device-validation.service.js';
9
- import { plan } from '../services/execution-plan.service.js';
9
+ import { countExtendedRuntimeFlows, plan } from '../services/execution-plan.service.js';
10
10
  import { isSubmitEndpointMissing, submitWithRetry, } from '../services/flow-submit.service.js';
11
11
  import { buildTestMetadataMap, computeCommonRoot, } from '../services/flow-paths.js';
12
12
  import { MoropoService } from '../services/moropo.service.js';
@@ -242,11 +242,7 @@ export const cloudCommand = defineCommand({
242
242
  const ciContext = detectCiContext();
243
243
  let compatibilityData;
244
244
  try {
245
- compatibilityData = await fetchCompatibilityData(apiUrl, auth, {
246
- cliVersion,
247
- ciProvider: ciContext.provider,
248
- ciWrapperVersion: ciContext.wrapperVersion,
249
- });
245
+ compatibilityData = await fetchCompatibilityData(apiUrl, auth);
250
246
  if (debug) {
251
247
  out('[DEBUG] Successfully fetched compatibility data from API');
252
248
  }
@@ -523,6 +519,11 @@ export const cloudCommand = defineCommand({
523
519
  submitRows.push(colors.dim(`${flowPath.replace(process.cwd(), '.')}:`));
524
520
  submitRows.push(...ui.fields(Object.entries(overrides).map(([key, value]) => [key, colors.highlight(String(value))])));
525
521
  }
522
+ // The 2x is charged per flow, so say it before the run, not on the bill.
523
+ const extendedFlows = countExtendedRuntimeFlows(flowOverrides);
524
+ if (extendedFlows > 0) {
525
+ submitRows.push('', ui.note(`${extendedFlows} flow${extendedFlows === 1 ? '' : 's'} with extended runtime: up to 20 min each, billed at 2×`));
526
+ }
526
527
  }
527
528
  out(ui.section('Submitting new job'));
528
529
  out(ui.branch(submitRows));
@@ -0,0 +1,36 @@
1
+ import { type DeviceCatalogue, type DeviceScreenElement, type DeviceSession } from '../types/domain/device-session.types.js';
2
+ /**
3
+ * The platform a `--model` belongs to, from GET /device/models. Matches the
4
+ * model id (iphone-16) or its name (iPhone 16), ignoring case. Unknown, or on
5
+ * both platforms: a usage error that says to pass --platform.
6
+ */
7
+ export declare function platformOfModel(catalogue: DeviceCatalogue, model: string): 'android' | 'ios';
8
+ /**
9
+ * The "Next steps" `dcd device start` prints. They follow the session: a
10
+ * device that isn't ready yet can't be inspected, so that comes first, and
11
+ * a session with no app gets the install step.
12
+ */
13
+ export declare function startNextSteps(session: DeviceSession, hasApp: boolean): [string, string][];
14
+ /** One element on one line: what to target it by, then its bounds. */
15
+ export declare function formatElement(el: DeviceScreenElement): string;
16
+ /** `data:image/jpeg;base64,...` to bytes and a file extension. */
17
+ export declare function decodeDataUrl(dataUrl: string): {
18
+ bytes: Buffer;
19
+ ext: string;
20
+ };
21
+ /** `--env KEY=VALUE`, given once or several times. */
22
+ export declare function parseEnvFlags(value: unknown): Record<string, string> | undefined;
23
+ /** Every value of a repeatable flag; citty keeps only the last one. */
24
+ export declare function collectFlagValues(flag: string, rawArgs: string[]): string[];
25
+ /**
26
+ * citty drops a string flag's value when it starts with `-`, as a flow's
27
+ * first command does (`--yaml "- launchApp"`). Read it from argv instead.
28
+ */
29
+ export declare function recoverFlagValue(flag: string, parsed: string | undefined, rawArgs: string[]): string | undefined;
30
+ /**
31
+ * The lines of `next` that `prev` has not shown. Each fetch is the log's
32
+ * last N lines, so the overlap is the longest end of `prev` that `next`
33
+ * starts with. No overlap: everything in `next` is new.
34
+ */
35
+ export declare function newLogLines(prev: string[], next: string[]): string[];
36
+ export declare const deviceCommand: import("citty").CommandDef<import("citty").ArgsDef>;