@devicecloud.dev/dcd 5.12.1 → 5.13.0-beta.2
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 +39 -40
- package/dist/commands/cloud.d.ts +1 -1
- package/dist/commands/cloud.js +8 -5
- package/dist/commands/device.js +189 -2
- package/dist/commands/login.js +4 -28
- package/dist/commands/logout.js +3 -4
- package/dist/commands/mcp.js +26 -5
- package/dist/config/flags/execution.flags.d.ts +9 -1
- package/dist/config/flags/execution.flags.js +9 -1
- package/dist/constants.d.ts +1 -1
- package/dist/gateways/cli-auth-gateway.d.ts +5 -2
- package/dist/gateways/cli-auth-gateway.js +32 -26
- package/dist/gateways/device-gateway.d.ts +6 -1
- package/dist/gateways/device-gateway.js +4 -0
- package/dist/mcp/bridge.js +21 -6
- package/dist/mcp/tools/run-cloud-test.js +7 -2
- package/dist/services/results-polling.service.d.ts +8 -11
- package/dist/services/results-polling.service.js +32 -113
- package/dist/types/domain/auth.types.d.ts +2 -2
- package/dist/types/domain/device-session.types.d.ts +37 -0
- package/dist/types/domain/device-session.types.js +13 -0
- package/dist/types/domain/device.types.d.ts +0 -1
- package/dist/types/domain/device.types.js +0 -1
- package/dist/utils/cli.d.ts +4 -1
- package/dist/utils/cli.js +5 -2
- package/dist/utils/mcp-install.d.ts +9 -2
- package/dist/utils/mcp-install.js +12 -2
- package/dist/utils/tool-spawn.d.ts +21 -0
- package/dist/utils/tool-spawn.js +65 -0
- package/package.json +1 -1
- package/dist/gateways/realtime-gateway.d.ts +0 -39
- package/dist/gateways/realtime-gateway.js +0 -128
package/README.md
CHANGED
|
@@ -36,30 +36,32 @@ See full documentation: [Docs](https://docs.devicecloud.dev)
|
|
|
36
36
|
|
|
37
37
|
## MCP server
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
`dcd mcp` is an [MCP](https://modelcontextprotocol.io) server, so AI agents (Claude, Codex, Cursor, VS Code) can run cloud tests and read their results. You don't run it yourself. You add it to your MCP client's config, and the client starts it. It works the same on your machine and headless, such as in CI.
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
### Set it up with `dcd mcp install`
|
|
42
42
|
|
|
43
|
-
|
|
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) |
|
|
43
|
+
Install the CLI (see the top of this page), sign in, then add the server to your AI tool:
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
```sh-session
|
|
46
|
+
$ dcd login
|
|
47
|
+
$ dcd mcp install cursor # or claude-code, claude-desktop, codex, vscode
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
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, Codex and VS Code it runs `claude mcp add`, `codex 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.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
### Headless, with an API key
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
For an agent that runs without you, such as in CI or a script, sign in with an API key instead of `dcd login`. Create one in the console under Settings → API Keys, and give it to the server as `DEVICE_CLOUD_API_KEY` in its environment. For example, for Claude Code in CI:
|
|
54
55
|
|
|
55
56
|
```sh-session
|
|
56
|
-
$ dcd
|
|
57
|
-
$ dcd mcp install cursor # or claude-code, claude-desktop, vscode
|
|
57
|
+
$ claude mcp add --scope user devicecloud -e DEVICE_CLOUD_API_KEY="$DEVICE_CLOUD_API_KEY" -- dcd mcp
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
In a JSON config, put it in the server's `env`: `"env": { "DEVICE_CLOUD_API_KEY": "<your-api-key>" }`. Store the key as a secret in your CI provider, never in the repository.
|
|
61
|
+
|
|
62
|
+
### Setting it up by hand
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
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
65
|
|
|
64
66
|
Claude Desktop (`claude_desktop_config.json`) and Cursor (`~/.cursor/mcp.json`):
|
|
65
67
|
|
|
@@ -88,29 +90,42 @@ VS Code (`.vscode/mcp.json`, or the user `mcp.json`) uses `servers` and a `type`
|
|
|
88
90
|
}
|
|
89
91
|
```
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
Codex (`~/.codex/config.toml`, shared by the Codex CLI, IDE extension and desktop app):
|
|
94
|
+
|
|
95
|
+
```toml
|
|
96
|
+
[mcp_servers.devicecloud]
|
|
97
|
+
command = "/Users/you/.dcd/bin/dcd"
|
|
98
|
+
args = ["mcp"]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Claude Code and the Codex CLI, run from a terminal, do see your PATH:
|
|
92
102
|
|
|
93
103
|
```sh-session
|
|
94
104
|
$ claude mcp add --scope user devicecloud -- dcd mcp
|
|
105
|
+
$ codex mcp add devicecloud -- dcd mcp
|
|
95
106
|
```
|
|
96
107
|
|
|
97
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.
|
|
98
109
|
|
|
99
|
-
It signs in the same way as the CLI:
|
|
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`.
|
|
100
111
|
|
|
101
|
-
|
|
112
|
+
### Tools
|
|
102
113
|
|
|
103
|
-
|
|
114
|
+
| Tool | What it does |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `dcd_list_devices` | Discover available devices, OS versions, and Maestro versions |
|
|
117
|
+
| `dcd_list_runs` | List recent test runs (filter by name/date, paginated) |
|
|
118
|
+
| `dcd_get_status` | Get the status + per-test results of a run |
|
|
119
|
+
| `dcd_download_artifacts` | Download a run's artifacts/report to disk |
|
|
120
|
+
| `dcd_run_cloud_test` | Submit a flow to run on the cloud (**billable**) |
|
|
104
121
|
|
|
105
|
-
|
|
122
|
+
By default `dcd_run_cloud_test` is async: it returns an `uploadId` immediately, which you poll with `dcd_get_status`. Pass `wait: true` (bounded by `waitTimeoutSeconds`) to block until completion, or `dryRun: true` to preview the flows without submitting.
|
|
106
123
|
|
|
107
|
-
|
|
108
|
-
$ claude mcp add --transport http devicecloud https://api.devicecloud.dev/mcp
|
|
109
|
-
```
|
|
124
|
+
**Read-only mode.** `dcd_run_cloud_test` consumes test minutes, so it is annotated as non-read-only/destructive (clients can prompt before calling it). To hide it entirely, which is recommended for autonomous or untrusted agents, add `--read-only` after `mcp` in the args (or pass it to `dcd mcp install`), or set `DCD_MCP_READONLY=1` in `env`.
|
|
110
125
|
|
|
111
126
|
### `dcd-mcp`
|
|
112
127
|
|
|
113
|
-
The older server
|
|
128
|
+
The npm package also ships `dcd-mcp`, an older server with the same `dcd_*` tools. `dcd mcp` covers it, so you only need it for a setup that already uses it:
|
|
114
129
|
|
|
115
130
|
```jsonc
|
|
116
131
|
{
|
|
@@ -124,23 +139,7 @@ The older server, with the `dcd_*` tools only. Add it to your MCP client config:
|
|
|
124
139
|
}
|
|
125
140
|
```
|
|
126
141
|
|
|
127
|
-
`--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.
|
|
128
|
-
|
|
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`.
|
|
130
|
-
|
|
131
|
-
**`dcd_*` tools** (served by both `dcd mcp` and `dcd-mcp`)
|
|
132
|
-
|
|
133
|
-
| Tool | What it does |
|
|
134
|
-
| --- | --- |
|
|
135
|
-
| `dcd_list_devices` | Discover available devices, OS versions, and Maestro versions |
|
|
136
|
-
| `dcd_list_runs` | List recent test runs (filter by name/date, paginated) |
|
|
137
|
-
| `dcd_get_status` | Get the status + per-test results of a run |
|
|
138
|
-
| `dcd_download_artifacts` | Download a run's artifacts/report to disk |
|
|
139
|
-
| `dcd_run_cloud_test` | Submit a flow to run on the cloud (**billable**) |
|
|
140
|
-
|
|
141
|
-
**Read-only mode.** `dcd_run_cloud_test` consumes test minutes, so it is annotated as non-read-only/destructive (clients can prompt before calling it). To hide it entirely — recommended for autonomous or untrusted agents — pass `--read-only` at the end of `args` (`["-y", "--package=@devicecloud.dev/dcd", "dcd-mcp", "--read-only"]`), or set `DCD_MCP_READONLY=1` in `env`.
|
|
142
|
-
|
|
143
|
-
By default `dcd_run_cloud_test` is async: it returns an `uploadId` immediately, which you poll with `dcd_get_status`. Pass `wait: true` (bounded by `waitTimeoutSeconds`) to block until completion, or `dryRun: true` to preview the flows without submitting.
|
|
142
|
+
`--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
143
|
|
|
145
144
|
|
|
146
145
|
## Development
|
package/dist/commands/cloud.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export declare const cloudCommand: import("citty").CommandDef<{
|
|
|
141
141
|
readonly 'runner-type': {
|
|
142
142
|
readonly type: "string";
|
|
143
143
|
readonly default: "default";
|
|
144
|
-
readonly description: "[experimental] The type of runner to use (options: default, m4, m1,
|
|
144
|
+
readonly description: "[experimental] The type of runner to use (options: default, m4, m1, cpu1) - note: anything other than default or cpu1 will incur premium pricing tiers. See https://docs.devicecloud.dev/configuration/runner-type for more information.";
|
|
145
145
|
};
|
|
146
146
|
readonly env: {
|
|
147
147
|
readonly type: "string";
|
package/dist/commands/cloud.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { defineCommand } from 'citty';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
|
+
import { RETIRED_RUNNER_TYPES, RUNNER_TYPE_OPTIONS, } from '../config/flags/execution.flags.js';
|
|
5
6
|
import { flags as allFlags } from '../constants.js';
|
|
6
7
|
import { ApiGateway } from '../gateways/api-gateway.js';
|
|
7
8
|
import { uploadBinary, uploadFlowZip, verifyAppZip, writeJSONFile, } from '../methods.js';
|
|
@@ -42,7 +43,6 @@ process.on('warning', (warning) => {
|
|
|
42
43
|
const DOWNLOAD_OPTIONS = ['ALL', 'FAILED'];
|
|
43
44
|
const REPORT_OPTIONS = ['allure', 'html', 'html-detailed', 'junit'];
|
|
44
45
|
const ORIENTATION_OPTIONS = ['0', '90'];
|
|
45
|
-
const RUNNER_TYPE_OPTIONS = ['default', 'm4', 'm1', 'gpu1', 'cpu1'];
|
|
46
46
|
const PRIORITY_OPTIONS = ['low', 'normal', 'high'];
|
|
47
47
|
const RENDER_ENGINE_OPTIONS = ['lavapipe', 'swiftshader'];
|
|
48
48
|
/**
|
|
@@ -168,7 +168,10 @@ export const cloudCommand = defineCommand({
|
|
|
168
168
|
let quiet = Boolean(args.quiet);
|
|
169
169
|
const report = validateEnum(args.report, REPORT_OPTIONS, 'report');
|
|
170
170
|
let retry = parseIntFlag(args.retry, 'retry');
|
|
171
|
-
const runnerType = validateEnum(args['runner-type'], RUNNER_TYPE_OPTIONS, 'runner-type'
|
|
171
|
+
const runnerType = validateEnum(args['runner-type'], RUNNER_TYPE_OPTIONS, 'runner-type',
|
|
172
|
+
// gpu1 still validates so old scripts keep working; the API runs it
|
|
173
|
+
// on cpu1.
|
|
174
|
+
RETIRED_RUNNER_TYPES) ?? 'default';
|
|
172
175
|
const renderEngine = validateEnum(args['render-engine'], RENDER_ENGINE_OPTIONS, 'render-engine');
|
|
173
176
|
const showCrosshairs = Boolean(args['show-crosshairs']);
|
|
174
177
|
const maestroChromeOnboarding = Boolean(args['maestro-chrome-onboarding']);
|
|
@@ -234,10 +237,10 @@ export const cloudCommand = defineCommand({
|
|
|
234
237
|
tempFiles.push(flows);
|
|
235
238
|
}
|
|
236
239
|
const auth = await resolveAuth({ apiKeyFlag });
|
|
237
|
-
// Nudge interactive api-key users toward `dcd login
|
|
238
|
-
//
|
|
240
|
+
// Nudge interactive api-key users toward `dcd login`. Suppressed in CI and
|
|
241
|
+
// non-interactive output.
|
|
239
242
|
if (auth.mode === 'apiKey' && !json && !quiet && !isCI()) {
|
|
240
|
-
out(colors.dim('Tip: run `dcd login` for
|
|
243
|
+
out(colors.dim('Tip: run `dcd login` for a smoother experience than passing --api-key.'));
|
|
241
244
|
}
|
|
242
245
|
const ciContext = detectCiContext();
|
|
243
246
|
let compatibilityData;
|
package/dist/commands/device.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolve as resolvePath } from 'node:path';
|
|
|
5
5
|
import { apiFlags } from '../config/flags/api.flags.js';
|
|
6
6
|
import { jsonFlag } from '../config/flags/output.flags.js';
|
|
7
7
|
import { DeviceApiError, DeviceGateway, START_RECOVERY_WINDOW_MS, startOutcomeUnknown, } from '../gateways/device-gateway.js';
|
|
8
|
-
import { ENDED_STATES, } from '../types/domain/device-session.types.js';
|
|
8
|
+
import { DEVICE_KEYS, ENDED_STATES, SWIPE_DIRECTIONS, } from '../types/domain/device-session.types.js';
|
|
9
9
|
import { platformOfAppFile, uploadLocalApp } from '../utils/app-upload.js';
|
|
10
10
|
import { refreshAuth, resolveAuth } from '../utils/auth.js';
|
|
11
11
|
import { openBrowser } from '../utils/browser.js';
|
|
@@ -580,6 +580,185 @@ const launchSub = defineCommand({
|
|
|
580
580
|
});
|
|
581
581
|
},
|
|
582
582
|
});
|
|
583
|
+
/**
|
|
584
|
+
* Shared by the typed-action subcommands. It chose Maestro over the device's
|
|
585
|
+
* direct path when a device session had two engines. It has one now, so the
|
|
586
|
+
* flag is still taken, for scripts that pass it, and does nothing.
|
|
587
|
+
*/
|
|
588
|
+
const maestroArg = {
|
|
589
|
+
type: 'boolean',
|
|
590
|
+
default: false,
|
|
591
|
+
description: 'Deprecated: has no effect. Device sessions have a single engine',
|
|
592
|
+
};
|
|
593
|
+
/** A percentage of the screen from a flag value, or a usage error. */
|
|
594
|
+
function percentArg(value, flag) {
|
|
595
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
596
|
+
if (typeof value === 'boolean' || value === '' || !Number.isFinite(n) || n < 0 || n > 100) {
|
|
597
|
+
throw new CliError(`--${flag} must be a number from 0 to 100 (a percentage of the screen).`, 1);
|
|
598
|
+
}
|
|
599
|
+
return n;
|
|
600
|
+
}
|
|
601
|
+
/** "x,y" (percentages) from a flag value, or a usage error. */
|
|
602
|
+
function pointArg(value, flag) {
|
|
603
|
+
const parts = typeof value === 'string' ? value.split(',') : [];
|
|
604
|
+
if (parts.length !== 2) {
|
|
605
|
+
throw new CliError(`--${flag} must be "x,y", percentages of the screen, e.g. --${flag} 50,80.`, 1);
|
|
606
|
+
}
|
|
607
|
+
return { x: percentArg(parts[0].trim(), flag), y: percentArg(parts[1].trim(), flag) };
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Send one typed action and print its outcome, the way `launch` does: exit 2
|
|
611
|
+
* with the result when the device could not do it.
|
|
612
|
+
*/
|
|
613
|
+
async function performAction(args, id, body, labels) {
|
|
614
|
+
const ctx = await context(args);
|
|
615
|
+
const sessionId = await resolveSessionId(ctx.apiUrl, ctx.auth, id);
|
|
616
|
+
const { result, session } = await DeviceGateway.action(ctx.apiUrl, ctx.auth, sessionId, body);
|
|
617
|
+
return {
|
|
618
|
+
session,
|
|
619
|
+
data: { result },
|
|
620
|
+
...(!result.success && {
|
|
621
|
+
failure: { code: null, message: result.error || labels.failed },
|
|
622
|
+
}),
|
|
623
|
+
print() {
|
|
624
|
+
logger.log(result.success ? ui.success(labels.done) : `${ui.statusSymbol('FAILED')} ${labels.failed}`);
|
|
625
|
+
if (result.error)
|
|
626
|
+
logger.log(colors.error(result.error));
|
|
627
|
+
},
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
const tapSub = defineCommand({
|
|
631
|
+
meta: { name: 'tap', description: 'Tap an element by text or id, or a point on the screen' },
|
|
632
|
+
args: {
|
|
633
|
+
...commonArgs,
|
|
634
|
+
id: idArg,
|
|
635
|
+
text: { type: 'string', description: 'The element\'s text, label or hint, matched whole, ignoring case' },
|
|
636
|
+
rid: { type: 'string', description: 'The element\'s resource id (rid in `dcd device inspect`)' },
|
|
637
|
+
x: { type: 'string', description: 'With --y: a point, as percentages of the screen (0-100)' },
|
|
638
|
+
y: { type: 'string', description: 'See --x' },
|
|
639
|
+
maestro: maestroArg,
|
|
640
|
+
},
|
|
641
|
+
async run({ args }) {
|
|
642
|
+
const json = Boolean(args.json);
|
|
643
|
+
await runDeviceCommand(json, async () => {
|
|
644
|
+
const targets = [
|
|
645
|
+
args.text !== undefined,
|
|
646
|
+
args.rid !== undefined,
|
|
647
|
+
args.x !== undefined || args.y !== undefined,
|
|
648
|
+
].filter(Boolean).length;
|
|
649
|
+
if (targets !== 1) {
|
|
650
|
+
throw new CliError('tap takes exactly one target: --text, --rid, or --x and --y.', 1);
|
|
651
|
+
}
|
|
652
|
+
const body = args.text !== undefined
|
|
653
|
+
? { type: 'tap', text: String(args.text) }
|
|
654
|
+
: args.rid !== undefined
|
|
655
|
+
? { type: 'tap', id: String(args.rid) }
|
|
656
|
+
: { type: 'tap', x: percentArg(args.x, 'x'), y: percentArg(args.y, 'y') };
|
|
657
|
+
const what = args.text !== undefined
|
|
658
|
+
? `"${String(args.text)}"`
|
|
659
|
+
: args.rid !== undefined
|
|
660
|
+
? `id ${String(args.rid)}`
|
|
661
|
+
: `${String(args.x)}%,${String(args.y)}%`;
|
|
662
|
+
return performAction(args, args.id, body, {
|
|
663
|
+
done: `Tapped ${what}`,
|
|
664
|
+
failed: `Tap ${what} failed`,
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
},
|
|
668
|
+
});
|
|
669
|
+
const typeSub = defineCommand({
|
|
670
|
+
meta: { name: 'type', description: 'Type text into the focused field' },
|
|
671
|
+
args: {
|
|
672
|
+
...commonArgs,
|
|
673
|
+
id: idArg,
|
|
674
|
+
// Not `required`: citty would reject a missing value before runDeviceCommand,
|
|
675
|
+
// and --json would then print the top-level error instead of the envelope.
|
|
676
|
+
text: { type: 'string', description: 'What to type' },
|
|
677
|
+
sensitive: {
|
|
678
|
+
type: 'boolean',
|
|
679
|
+
default: false,
|
|
680
|
+
description: 'The text is a secret: stored encrypted, never shown, masked in the output',
|
|
681
|
+
},
|
|
682
|
+
maestro: maestroArg,
|
|
683
|
+
},
|
|
684
|
+
async run({ args }) {
|
|
685
|
+
const json = Boolean(args.json);
|
|
686
|
+
await runDeviceCommand(json, async () => {
|
|
687
|
+
const text = String(args.text ?? '');
|
|
688
|
+
if (!text)
|
|
689
|
+
throw new CliError('--text must not be empty.', 1);
|
|
690
|
+
const shown = args.sensitive ? `${text.length} character(s)` : `"${text}"`;
|
|
691
|
+
return performAction(args, args.id, { type: 'type', text, ...(args.sensitive ? { sensitive: true } : {}) }, { done: `Typed ${shown}`, failed: `Typing ${shown} failed` });
|
|
692
|
+
});
|
|
693
|
+
},
|
|
694
|
+
});
|
|
695
|
+
const isDirection = (value) => typeof value === 'string' && SWIPE_DIRECTIONS.includes(value);
|
|
696
|
+
const swipeSub = defineCommand({
|
|
697
|
+
meta: { name: 'swipe', description: 'Swipe up, down, left or right, or from one point to another' },
|
|
698
|
+
args: {
|
|
699
|
+
...commonArgs,
|
|
700
|
+
id: idArg,
|
|
701
|
+
direction: {
|
|
702
|
+
type: 'positional',
|
|
703
|
+
required: false,
|
|
704
|
+
description: 'up, down, left or right (a swipe across most of the screen)',
|
|
705
|
+
},
|
|
706
|
+
from: { type: 'string', description: 'With --to: where the swipe starts, as "x,y" percentages' },
|
|
707
|
+
to: { type: 'string', description: 'Where it ends, as "x,y" percentages' },
|
|
708
|
+
maestro: maestroArg,
|
|
709
|
+
},
|
|
710
|
+
async run({ args }) {
|
|
711
|
+
const json = Boolean(args.json);
|
|
712
|
+
await runDeviceCommand(json, async () => {
|
|
713
|
+
let id = args.id;
|
|
714
|
+
let direction = args.direction;
|
|
715
|
+
// `dcd device swipe up`: the one positional is the direction, not a session.
|
|
716
|
+
if (id && !direction && isDirection(id))
|
|
717
|
+
[id, direction] = [undefined, id];
|
|
718
|
+
const byPoints = args.from !== undefined || args.to !== undefined;
|
|
719
|
+
if ((direction === undefined) === !byPoints) {
|
|
720
|
+
throw new CliError('swipe takes a direction (up, down, left, right), or --from and --to.', 1);
|
|
721
|
+
}
|
|
722
|
+
let body;
|
|
723
|
+
let what;
|
|
724
|
+
if (direction !== undefined) {
|
|
725
|
+
if (!isDirection(direction)) {
|
|
726
|
+
throw new CliError(`direction must be one of ${SWIPE_DIRECTIONS.join(', ')}.`, 1);
|
|
727
|
+
}
|
|
728
|
+
body = { type: 'swipe', direction };
|
|
729
|
+
what = direction;
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
body = { type: 'swipe', from: pointArg(args.from, 'from'), to: pointArg(args.to, 'to') };
|
|
733
|
+
what = `${String(args.from)} to ${String(args.to)}`;
|
|
734
|
+
}
|
|
735
|
+
return performAction(args, id, body, { done: `Swiped ${what}`, failed: `Swipe ${what} failed` });
|
|
736
|
+
});
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
const pressKeySub = defineCommand({
|
|
740
|
+
meta: { name: 'press-key', description: `Press a key: ${DEVICE_KEYS.join(', ')}` },
|
|
741
|
+
args: {
|
|
742
|
+
...commonArgs,
|
|
743
|
+
id: idArg,
|
|
744
|
+
key: { type: 'positional', required: false, description: `One of ${DEVICE_KEYS.join(', ')}` },
|
|
745
|
+
maestro: maestroArg,
|
|
746
|
+
},
|
|
747
|
+
async run({ args }) {
|
|
748
|
+
const json = Boolean(args.json);
|
|
749
|
+
await runDeviceCommand(json, async () => {
|
|
750
|
+
let id = args.id;
|
|
751
|
+
let key = args.key;
|
|
752
|
+
// `dcd device press-key back`: the one positional is the key, not a session.
|
|
753
|
+
if (id && !key && DEVICE_KEYS.includes(id))
|
|
754
|
+
[id, key] = [undefined, id];
|
|
755
|
+
if (!key || !DEVICE_KEYS.includes(key)) {
|
|
756
|
+
throw new CliError(`key must be one of ${DEVICE_KEYS.join(', ')}.`, 1);
|
|
757
|
+
}
|
|
758
|
+
return performAction(args, id, { type: 'press_key', key }, { done: `Pressed ${key}`, failed: `Press ${key} failed` });
|
|
759
|
+
});
|
|
760
|
+
},
|
|
761
|
+
});
|
|
583
762
|
const modelsSub = defineCommand({
|
|
584
763
|
meta: { name: 'models', description: 'The devices a session can ask for' },
|
|
585
764
|
args: {
|
|
@@ -744,7 +923,11 @@ async function waitForCommand(ctx, id, commandId) {
|
|
|
744
923
|
}
|
|
745
924
|
}
|
|
746
925
|
const runSub = defineCommand({
|
|
747
|
-
meta: {
|
|
926
|
+
meta: {
|
|
927
|
+
name: 'run',
|
|
928
|
+
description: 'Run a Maestro flow (or a directory of flows) on the device, and wait for the result. ' +
|
|
929
|
+
'A device session runs the common Maestro commands and no flow scripts (runScript, evalScript)',
|
|
930
|
+
},
|
|
748
931
|
args: {
|
|
749
932
|
...commonArgs,
|
|
750
933
|
id: idArg,
|
|
@@ -1171,6 +1354,10 @@ export const deviceCommand = defineCommand({
|
|
|
1171
1354
|
stop: stopSub,
|
|
1172
1355
|
install: installSub,
|
|
1173
1356
|
launch: launchSub,
|
|
1357
|
+
tap: tapSub,
|
|
1358
|
+
type: typeSub,
|
|
1359
|
+
swipe: swipeSub,
|
|
1360
|
+
'press-key': pressKeySub,
|
|
1174
1361
|
models: modelsSub,
|
|
1175
1362
|
inspect: inspectSub,
|
|
1176
1363
|
screenshot: screenshotSub,
|
package/dist/commands/login.js
CHANGED
|
@@ -35,7 +35,6 @@ import * as p from '@clack/prompts';
|
|
|
35
35
|
import { defineCommand } from 'citty';
|
|
36
36
|
import { createHash, randomBytes } from 'node:crypto';
|
|
37
37
|
import { ENVIRONMENTS, inferEnvFromApiUrl, resolveFrontendUrl, } from '../config/environments.js';
|
|
38
|
-
import { getSupabaseKey } from '../config/supabase-key.js';
|
|
39
38
|
import { jsonFlag } from '../config/flags/output.flags.js';
|
|
40
39
|
import { openBrowser } from '../utils/browser.js';
|
|
41
40
|
import { canPrompt } from '../utils/ci.js';
|
|
@@ -175,17 +174,11 @@ export const loginCommand = defineCommand({
|
|
|
175
174
|
orgs = await fetchOrgs(apiUrl, bearerHeaders);
|
|
176
175
|
}
|
|
177
176
|
catch (err) {
|
|
178
|
-
// The api rejected the JWT
|
|
179
|
-
//
|
|
180
|
-
// rejects it, the token itself is bad; if Supabase accepts, the
|
|
181
|
-
// api's JwtService is misconfigured.
|
|
177
|
+
// The api rejected the JWT it just minted. Name the token's issuer, so
|
|
178
|
+
// a token from the wrong environment is plain from the error.
|
|
182
179
|
const iss = decodeJwtIssuer(payload.access_token);
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
iss ? `token iss: ${iss}` : null,
|
|
186
|
-
`supabase /auth/v1/user: ${supabaseUser}`,
|
|
187
|
-
].filter(Boolean);
|
|
188
|
-
throw new CliError(`${err.message} [${parts.join(' | ')}]`);
|
|
180
|
+
const message = err.message;
|
|
181
|
+
throw new CliError(iss ? `${message} [token iss: ${iss}]` : message);
|
|
189
182
|
}
|
|
190
183
|
const { org: chosen, fromLastLogin } = await selectOrg(orgs, {
|
|
191
184
|
requested: requestedOrg,
|
|
@@ -273,23 +266,6 @@ async function pollForClaim(apiUrl, state, codeVerifier) {
|
|
|
273
266
|
function base64url(buf) {
|
|
274
267
|
return buf.toString('base64').replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
|
|
275
268
|
}
|
|
276
|
-
async function probeSupabaseUser(iss, env, token) {
|
|
277
|
-
if (!iss)
|
|
278
|
-
return 'skipped (no iss)';
|
|
279
|
-
try {
|
|
280
|
-
const res = await fetch(`${iss}/user`, {
|
|
281
|
-
headers: {
|
|
282
|
-
authorization: `Bearer ${token}`,
|
|
283
|
-
apikey: await getSupabaseKey(env),
|
|
284
|
-
},
|
|
285
|
-
});
|
|
286
|
-
const bodyText = await res.text().catch(() => '');
|
|
287
|
-
return `HTTP ${res.status}${bodyText ? ` — ${bodyText.slice(0, 200)}` : ''}`;
|
|
288
|
-
}
|
|
289
|
-
catch (err) {
|
|
290
|
-
return `network error: ${err.message}`;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
269
|
function decodeJwtIssuer(token) {
|
|
294
270
|
try {
|
|
295
271
|
const [, payloadB64] = token.split('.');
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `dcd logout` —
|
|
3
|
-
*
|
|
2
|
+
* `dcd logout` — deletes the stored session. Local only: nothing is revoked
|
|
3
|
+
* server-side, so the user stays signed in to the web app and any other CLI.
|
|
4
|
+
* Leaves DEVICE_CLOUD_API_KEY (env/flag) untouched.
|
|
4
5
|
*/
|
|
5
6
|
import { defineCommand } from 'citty';
|
|
6
7
|
import { jsonFlag } from '../config/flags/output.flags.js';
|
|
7
|
-
import { CliAuthGateway } from '../gateways/cli-auth-gateway.js';
|
|
8
8
|
import { logger } from '../utils/cli.js';
|
|
9
9
|
import { clearConfig, getConfigPath, readConfig } from '../utils/config-store.js';
|
|
10
10
|
import { colors } from '../utils/styling.js';
|
|
@@ -30,7 +30,6 @@ export const logoutCommand = defineCommand({
|
|
|
30
30
|
}
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
await CliAuthGateway.signOut(config.supabase_url, config.env, config.session);
|
|
34
33
|
clearConfig();
|
|
35
34
|
if (json) {
|
|
36
35
|
logger.json({ status: 'SUCCESS', loggedOut: true, user: config.session.user_email });
|
package/dist/commands/mcp.js
CHANGED
|
@@ -11,18 +11,26 @@ import { apiKeyOverride } from '../utils/auth.js';
|
|
|
11
11
|
import { canPrompt } from '../utils/ci.js';
|
|
12
12
|
import { CliError, getInstallMethod, logger } from '../utils/cli.js';
|
|
13
13
|
import { readConfig } from '../utils/config-store.js';
|
|
14
|
-
import { CLIENT_LABELS, claudeCodeAddArgs, clientConfigPath, MCP_CLIENTS, mcpServersSnippet, SERVER_NAME, serverLaunch, shellLine, stableNodePath, vscodeAddArgs, writeClientConfig, } from '../utils/mcp-install.js';
|
|
14
|
+
import { CLIENT_LABELS, claudeCodeAddArgs, clientConfigPath, codexAddArgs, MCP_CLIENTS, mcpServersSnippet, SERVER_NAME, serverLaunch, shellLine, stableNodePath, vscodeAddArgs, writeClientConfig, } from '../utils/mcp-install.js';
|
|
15
15
|
import { colors } from '../utils/styling.js';
|
|
16
|
+
import { toolSpawn } from '../utils/tool-spawn.js';
|
|
16
17
|
import { ui } from '../utils/ui.js';
|
|
17
18
|
const RELOAD_HINT = {
|
|
18
19
|
'claude-code': 'Start a new Claude Code session to load it.',
|
|
19
20
|
'claude-desktop': 'Restart Claude Desktop to load it.',
|
|
21
|
+
codex: 'Start a new Codex session to load it.',
|
|
20
22
|
cursor: 'Restart Cursor, or reload its MCP servers, to load it.',
|
|
21
23
|
vscode: 'VS Code asks you to trust the server the first time it starts.',
|
|
22
24
|
};
|
|
23
25
|
/** Run another tool's CLI without a shell. Undefined when it isn't installed. */
|
|
24
26
|
function runTool(command, args) {
|
|
25
|
-
const
|
|
27
|
+
const spawn = toolSpawn(command, args);
|
|
28
|
+
if (!spawn)
|
|
29
|
+
return undefined;
|
|
30
|
+
const result = spawnSync(spawn.command, spawn.args, {
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
windowsVerbatimArguments: spawn.windowsVerbatimArguments,
|
|
33
|
+
});
|
|
26
34
|
if (result.error?.code === 'ENOENT')
|
|
27
35
|
return undefined;
|
|
28
36
|
return { ok: result.status === 0, output: `${result.stdout ?? ''}${result.stderr ?? ''}`.trim() };
|
|
@@ -57,6 +65,17 @@ function install(client, launch) {
|
|
|
57
65
|
throw new CliError(`claude mcp add failed: ${added.output}`);
|
|
58
66
|
return { target: shellLine('claude', add), replaced: removed.ok };
|
|
59
67
|
}
|
|
68
|
+
if (client === 'codex') {
|
|
69
|
+
const add = codexAddArgs(launch);
|
|
70
|
+
const removed = runTool('codex', ['mcp', 'remove', SERVER_NAME]);
|
|
71
|
+
if (!removed) {
|
|
72
|
+
throw new CliError(`The codex command isn't on PATH. Run this where it is:\n ${shellLine('codex', add)}`);
|
|
73
|
+
}
|
|
74
|
+
const added = runTool('codex', add);
|
|
75
|
+
if (!added.ok)
|
|
76
|
+
throw new CliError(`codex mcp add failed: ${added.output}`);
|
|
77
|
+
return { target: shellLine('codex', add), replaced: removed.ok };
|
|
78
|
+
}
|
|
60
79
|
if (client === 'vscode') {
|
|
61
80
|
const add = vscodeAddArgs(launch);
|
|
62
81
|
const added = runTool('code', add);
|
|
@@ -77,6 +96,8 @@ function install(client, launch) {
|
|
|
77
96
|
function preview(client, launch) {
|
|
78
97
|
if (client === 'claude-code')
|
|
79
98
|
return { target: 'command', text: shellLine('claude', claudeCodeAddArgs(launch)) };
|
|
99
|
+
if (client === 'codex')
|
|
100
|
+
return { target: 'command', text: shellLine('codex', codexAddArgs(launch)) };
|
|
80
101
|
if (client === 'vscode')
|
|
81
102
|
return { target: 'command', text: shellLine('code', vscodeAddArgs(launch)) };
|
|
82
103
|
return {
|
|
@@ -87,7 +108,7 @@ function preview(client, launch) {
|
|
|
87
108
|
const installSub = defineCommand({
|
|
88
109
|
meta: {
|
|
89
110
|
name: 'install',
|
|
90
|
-
description: 'Add the DeviceCloud MCP server to Claude Code, Claude Desktop, Cursor or VS Code',
|
|
111
|
+
description: 'Add the DeviceCloud MCP server to Claude Code, Claude Desktop, Codex, Cursor or VS Code',
|
|
91
112
|
},
|
|
92
113
|
args: {
|
|
93
114
|
client: {
|
|
@@ -138,7 +159,7 @@ const installSub = defineCommand({
|
|
|
138
159
|
}
|
|
139
160
|
logger.log(ui.success(`${result.replaced ? 'Updated' : 'Added'} DeviceCloud in ${CLIENT_LABELS[client]}`));
|
|
140
161
|
const rows = [
|
|
141
|
-
[client === 'claude-code' || client === 'vscode' ? 'ran' : 'wrote', result.target],
|
|
162
|
+
[client === 'claude-code' || client === 'codex' || client === 'vscode' ? 'ran' : 'wrote', result.target],
|
|
142
163
|
['starts', colors.highlight(shellLine(launch.command, launch.args))],
|
|
143
164
|
];
|
|
144
165
|
logger.log(ui.branch(ui.fields(rows)));
|
|
@@ -157,7 +178,7 @@ const installSub = defineCommand({
|
|
|
157
178
|
export const mcpCommand = defineCommand({
|
|
158
179
|
meta: {
|
|
159
180
|
name: 'mcp',
|
|
160
|
-
description: 'MCP server for AI agents, started by your MCP client (Claude, Cursor, VS Code)',
|
|
181
|
+
description: 'MCP server for AI agents, started by your MCP client (Claude, Codex, Cursor, VS Code)',
|
|
161
182
|
},
|
|
162
183
|
args: {
|
|
163
184
|
'read-only': {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/** The runner types offered in help text, error messages and the MCP schema. */
|
|
2
|
+
export declare const RUNNER_TYPE_OPTIONS: readonly ["default", "m4", "m1", "cpu1"];
|
|
3
|
+
/**
|
|
4
|
+
* Runner types that were removed but are still accepted, so scripts that pass
|
|
5
|
+
* them keep working. gpu1 was removed on 9 November 2026 and the API runs it
|
|
6
|
+
* on cpu1. Never offered anywhere a user picks from.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RETIRED_RUNNER_TYPES: readonly ["gpu1"];
|
|
1
9
|
/**
|
|
2
10
|
* Test execution and flow management flags
|
|
3
11
|
*/
|
|
@@ -45,6 +53,6 @@ export declare const executionFlags: {
|
|
|
45
53
|
readonly 'runner-type': {
|
|
46
54
|
readonly type: "string";
|
|
47
55
|
readonly default: "default";
|
|
48
|
-
readonly description: "[experimental] The type of runner to use (options: default, m4, m1,
|
|
56
|
+
readonly description: "[experimental] The type of runner to use (options: default, m4, m1, cpu1) - note: anything other than default or cpu1 will incur premium pricing tiers. See https://docs.devicecloud.dev/configuration/runner-type for more information.";
|
|
49
57
|
};
|
|
50
58
|
};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/** The runner types offered in help text, error messages and the MCP schema. */
|
|
2
|
+
export const RUNNER_TYPE_OPTIONS = ['default', 'm4', 'm1', 'cpu1'];
|
|
3
|
+
/**
|
|
4
|
+
* Runner types that were removed but are still accepted, so scripts that pass
|
|
5
|
+
* them keep working. gpu1 was removed on 9 November 2026 and the API runs it
|
|
6
|
+
* on cpu1. Never offered anywhere a user picks from.
|
|
7
|
+
*/
|
|
8
|
+
export const RETIRED_RUNNER_TYPES = ['gpu1'];
|
|
1
9
|
/**
|
|
2
10
|
* Test execution and flow management flags
|
|
3
11
|
*/
|
|
@@ -45,6 +53,6 @@ export const executionFlags = {
|
|
|
45
53
|
'runner-type': {
|
|
46
54
|
type: 'string',
|
|
47
55
|
default: 'default',
|
|
48
|
-
description: '[experimental] The type of runner to use (options: default, m4, m1,
|
|
56
|
+
description: '[experimental] The type of runner to use (options: default, m4, m1, cpu1) - note: anything other than default or cpu1 will incur premium pricing tiers. See https://docs.devicecloud.dev/configuration/runner-type for more information.',
|
|
49
57
|
},
|
|
50
58
|
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ export declare const flags: {
|
|
|
127
127
|
readonly 'runner-type': {
|
|
128
128
|
readonly type: "string";
|
|
129
129
|
readonly default: "default";
|
|
130
|
-
readonly description: "[experimental] The type of runner to use (options: default, m4, m1,
|
|
130
|
+
readonly description: "[experimental] The type of runner to use (options: default, m4, m1, cpu1) - note: anything other than default or cpu1 will incur premium pricing tiers. See https://docs.devicecloud.dev/configuration/runner-type for more information.";
|
|
131
131
|
};
|
|
132
132
|
readonly env: {
|
|
133
133
|
readonly type: "string";
|
|
@@ -8,7 +8,11 @@ import type { StoredSession } from '../utils/config-store.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class SessionRefreshError extends Error {
|
|
10
10
|
readonly definitive: boolean;
|
|
11
|
-
|
|
11
|
+
/** Supabase Auth's error code (`session_expired`, …), when it sent one. */
|
|
12
|
+
readonly code?: string | undefined;
|
|
13
|
+
constructor(message: string, definitive: boolean,
|
|
14
|
+
/** Supabase Auth's error code (`session_expired`, …), when it sent one. */
|
|
15
|
+
code?: string | undefined);
|
|
12
16
|
}
|
|
13
17
|
export interface RefreshedSession {
|
|
14
18
|
access_token: string;
|
|
@@ -20,5 +24,4 @@ export interface RefreshedSession {
|
|
|
20
24
|
}
|
|
21
25
|
export declare const CliAuthGateway: {
|
|
22
26
|
refresh(supabaseUrl: string, env: DcdEnvName, session: StoredSession): Promise<RefreshedSession>;
|
|
23
|
-
signOut(supabaseUrl: string, env: DcdEnvName, session: StoredSession): Promise<void>;
|
|
24
27
|
};
|