-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathcli-command-overrides.ts
More file actions
142 lines (130 loc) · 6.61 KB
/
Copy pathcli-command-overrides.ts
File metadata and controls
142 lines (130 loc) · 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import type { CommandName } from '../commands/command-metadata.ts';
import { listCommandFamilyCliSchemas } from '../commands/family/registry.ts';
import type { LocalCliCommandName } from '../command-catalog.ts';
import type { CommandSchema, CommandSchemaOverride } from './cli-command-schema-types.ts';
import { COMMON_COMMAND_SUPPORTED_FLAG_KEYS, METRO_PREPARE_FLAGS } from './cli-flags.ts';
type SchemaOnlyCliCommandName = Exclude<LocalCliCommandName, CommandName>;
const SCHEMA_ONLY_CLI_COMMAND_SCHEMAS = {
cdp: {
usageOverride: 'cdp [...args]',
listUsageOverride: 'cdp',
helpDescription:
'Run CDP commands for React Native diagnostics, JS heap usage, heap snapshots, and leak analysis',
summary:
'Inspect React Native CDP targets, JS heap growth, heap snapshots, retainers, and leak signals',
positionalArgs: ['args?'],
allowsExtraPositionals: true,
supportedFlags: COMMON_COMMAND_SUPPORTED_FLAG_KEYS,
},
auth: {
usageOverride: 'auth status|login|logout',
listUsageOverride: 'auth',
helpDescription: 'Manage cloud login state used by remote daemon and cloud device workflows.',
summary: 'Manage cloud login state used by remote daemon and cloud device workflows',
positionalArgs: ['status|login|logout'],
supportedFlags: ['remoteConfig', 'stateDir'],
},
connect: {
usageOverride:
'connect [--remote-config <path>] [--daemon-base-url <url>] [--tenant <id>] [--run-id <id>] [--lease-id <id>] [--lease-backend <backend>] [--force] [--no-login]',
helpDescription:
'Connect to a remote daemon, authenticate when needed, and save remote session state. AGENT_DEVICE_CLOUD_BASE_URL is the bridge/control-plane API origin; use AGENT_DEVICE_DAEMON_AUTH_TOKEN=adc_live_... for CI/service-token automation.',
listUsageOverride: 'connect',
summary:
'Attach CLI commands to a saved remote daemon/cloud lease; inspect for remote runs, tenants, or service-token CI',
allowedFlags: [
'remoteConfig',
'daemonBaseUrl',
'tenant',
'runId',
'leaseId',
'leaseBackend',
'force',
'noLogin',
],
supportedFlags: [
'stateDir',
'daemonAuthToken',
'session',
'platform',
...METRO_PREPARE_FLAGS,
'launchUrl',
],
},
connection: {
usageOverride: 'connection status',
listUsageOverride: 'connection',
helpDescription: 'Inspect active remote connection state',
summary: 'Inspect the active saved remote connection before assuming commands are local',
positionalArgs: ['status'],
supportedFlags: ['remoteConfig', 'stateDir', 'session'],
},
disconnect: {
helpDescription:
'Disconnect remote daemon state, stop owned Metro companion, and release lease',
listUsageOverride: 'disconnect',
summary:
'Clear remote connection state, stop owned Metro companions, and release remote leases',
allowedFlags: ['shutdown'],
supportedFlags: ['remoteConfig', 'stateDir', 'session'],
},
mcp: {
helpDescription:
'Start the official stdio MCP server. It exposes structured command tools backed by the agent-device client.',
summary: 'Start MCP server',
},
proxy: {
usageOverride:
'proxy [--host <host>] [--port <port>] [--daemon-auth-token <token>] [--state-dir <path>]',
listUsageOverride: 'proxy',
helpDescription: `Expose the local daemon HTTP contract through a tunnel-friendly reverse proxy.
Run this on the host that has access to simulators/devices, then point another machine at the printed daemon base URL with --daemon-base-url or AGENT_DEVICE_DAEMON_BASE_URL.
The proxy starts or reuses a local HTTP daemon, accepts /health, /rpc, /upload, and /artifacts/*, and also accepts the same routes under /agent-device/*. Health is unauthenticated for reachability probes. Other routes require the generated bearer token printed at startup, or the explicit --daemon-auth-token value when provided. The proxy rewrites authorized client requests to the upstream daemon token instead of exposing the local daemon token.
Use the /agent-device base path when connecting through cloudflared, ngrok, or another shared origin. Treat the bearer token as a secret; anyone with it can control the proxied daemon. This direct proxy flow does not use agent-device auth.
Examples:
agent-device proxy --port 4310
cloudflared tunnel --url http://127.0.0.1:4310
agent-device devices --daemon-base-url https://example.trycloudflare.com/agent-device --daemon-auth-token <token>`,
summary: 'Expose a local daemon through cloudflared, ngrok, or another HTTP tunnel',
allowedFlags: ['proxyHost', 'proxyPort', 'daemonAuthToken', 'stateDir'],
},
'react-devtools': {
usageOverride: 'react-devtools [...args]',
listUsageOverride: 'react-devtools',
helpDescription:
'Run pinned agent-react-devtools commands for React Native performance profiling, component trees, props/state/hooks, and render analysis',
summary:
'Inspect React Native components, props, hooks, errors, slow renders, and rerender profiles',
positionalArgs: ['args?'],
allowsExtraPositionals: true,
supportedFlags: COMMON_COMMAND_SUPPORTED_FLAG_KEYS,
},
web: {
usageOverride: 'web setup | web doctor',
listUsageOverride: 'web setup|doctor',
helpDescription: `Install and inspect the managed web automation backend used by --platform web.
First-run flow:
agent-device web setup
agent-device open "https://example.com" --platform web
agent-device snapshot -i --platform web
agent-device close --platform web
Runtime web commands do not install the backend implicitly. If the managed backend is missing, run agent-device web setup. The backend is resolved only from the managed install in the effective agent-device state dir.
Use web setup to install or reuse the pinned backend. Use web doctor after setup to verify browser backend health.`,
summary: 'Manage web automation backend',
positionalArgs: ['setup|doctor'],
supportedFlags: ['stateDir'],
},
} as const satisfies Record<SchemaOnlyCliCommandName, CommandSchema>;
const CLI_COMMAND_OVERRIDES = listCommandFamilyCliSchemas() as Partial<
Record<CommandName, CommandSchemaOverride>
>;
export function getSchemaOnlyCliCommandSchema(command: string): CommandSchema | undefined {
return Object.hasOwn(SCHEMA_ONLY_CLI_COMMAND_SCHEMAS, command)
? SCHEMA_ONLY_CLI_COMMAND_SCHEMAS[command as keyof typeof SCHEMA_ONLY_CLI_COMMAND_SCHEMAS]
: undefined;
}
export function getCliCommandOverride(command: string): CommandSchemaOverride | undefined {
return Object.hasOwn(CLI_COMMAND_OVERRIDES, command)
? CLI_COMMAND_OVERRIDES[command as keyof typeof CLI_COMMAND_OVERRIDES]
: undefined;
}