Skip to content

Commit 6a6f267

Browse files
committed
refactor(commands): keep bindCommands as the only catalog surface
`commands` was an `@internal` aggregate of the unbound command tables, kept alive by nothing but two probe tests: `commands/interaction/runtime/index.test.ts` read `typeof` off it, and `runtime-public.test.ts` asserted `typeof ... === 'function'` for 38 entries. A production caller cannot reach an unbound table — every real path goes through `bindCommands`, which ADR 0023 keeps as the command catalog boundary — so those assertions cannot fail for a reason worth hearing. Drop the const, its `AgentDeviceCommands` type, and the imports only it consumed. `bindCommands`, `BoundAgentDeviceCommands`, and the `ScreenshotCommandOptions` re-export are unchanged. The runtime coverage the probes stood in front of already lives at the owners: `commands/interaction/runtime/interactions.test.ts` drives bound `device.interactions.*` calls through real runtimes, and `package-exports` plus `runtime-public` exercise the published surface. `runtime-public.test.ts` keeps the part that was not a probe: the `satisfies ScreenshotCommandOptions` literal, which pins the option shape.
1 parent 2db7c42 commit 6a6f267

3 files changed

Lines changed: 6 additions & 102 deletions

File tree

‎src/__tests__/runtime-public.test.ts‎

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type CommandSessionStore,
1212
} from '../runtime.ts';
1313
import type { AgentDeviceBackend } from '../backend.ts';
14-
import { commands, type ScreenshotCommandOptions } from '../commands/index.ts';
14+
import type { ScreenshotCommandOptions } from '../commands/index.ts';
1515
import {
1616
createLocalArtifactAdapter,
1717
type ArtifactAdapter,
@@ -230,42 +230,10 @@ test('runtime commands work with async command session stores', async () => {
230230
assert.equal(records.get('default')?.snapshot?.nodes[0]?.label, 'Ready');
231231
});
232232

233-
test('internal backend, commands, and io modules are usable', () => {
233+
test('public screenshot options carry an explicit output target', () => {
234234
const options = {
235235
out: { kind: 'path', path: '/tmp/screen.png' },
236236
} satisfies ScreenshotCommandOptions;
237+
237238
assert.equal(options.out.kind, 'path');
238-
assert.equal(typeof commands.capture.screenshot, 'function');
239-
assert.equal(typeof commands.capture.diffScreenshot, 'function');
240-
assert.equal(typeof commands.capture.snapshot, 'function');
241-
assert.equal(typeof commands.capture.diffSnapshot, 'function');
242-
assert.equal(typeof commands.selectors.find, 'function');
243-
assert.equal(typeof commands.selectors.get, 'function');
244-
assert.equal(typeof commands.selectors.getText, 'function');
245-
assert.equal(typeof commands.selectors.is, 'function');
246-
assert.equal(typeof commands.selectors.isVisible, 'function');
247-
assert.equal(typeof commands.selectors.wait, 'function');
248-
assert.equal(typeof commands.selectors.waitForText, 'function');
249-
assert.equal(typeof commands.interactions.click, 'function');
250-
assert.equal(typeof commands.interactions.press, 'function');
251-
assert.equal(typeof commands.interactions.fill, 'function');
252-
assert.equal(typeof commands.interactions.focus, 'function');
253-
assert.equal(typeof commands.interactions.longPress, 'function');
254-
assert.equal(typeof commands.interactions.gesture, 'function');
255-
assert.equal(typeof commands.system.back, 'function');
256-
assert.equal(typeof commands.system.home, 'function');
257-
assert.equal(typeof commands.system.orientation, 'function');
258-
assert.equal(typeof commands.system.keyboard, 'function');
259-
assert.equal(typeof commands.system.clipboard, 'function');
260-
assert.equal(typeof commands.system.settings, 'function');
261-
assert.equal(typeof commands.system.alert, 'function');
262-
assert.equal(typeof commands.system.appSwitcher, 'function');
263-
assert.equal(typeof commands.system.tvRemote, 'function');
264-
assert.equal(typeof commands.admin.devices, 'function');
265-
assert.equal(typeof commands.admin.install, 'function');
266-
assert.equal(typeof commands.recording.record, 'function');
267-
assert.equal(typeof commands.recording.trace, 'function');
268-
assert.equal(typeof commands.diagnostics.logs, 'function');
269-
assert.equal(typeof commands.diagnostics.network, 'function');
270-
assert.equal(typeof commands.diagnostics.perf, 'function');
271239
});

‎src/commands/index.ts‎

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,27 @@
11
import type { AgentDeviceRuntime } from '../runtime-contract.ts';
22
import { bindRuntimeCommands } from './runtime-types.ts';
3-
import {
4-
bindCaptureCommands,
5-
captureCommands,
6-
type BoundCaptureCommands,
7-
type CaptureCommands,
8-
} from './capture/runtime/index.ts';
3+
import { bindCaptureCommands, type BoundCaptureCommands } from './capture/runtime/index.ts';
94
import {
105
bindInteractionCommands,
116
bindSelectorCommands,
12-
interactionCommands,
13-
selectorCommands,
147
type BoundInteractionCommands,
158
type BoundSelectorCommands,
16-
type InteractionCommands,
17-
type SelectorCommands,
189
} from './interaction/runtime/index.ts';
1910
import {
2011
adminCommands,
21-
appCommands,
2212
bindAppCommands,
23-
type AdminCommands,
24-
type AppCommands,
2513
type BoundAdminCommands,
2614
type BoundAppCommands,
2715
} from './management/runtime/index.ts';
2816
import {
2917
diagnosticsCommands,
3018
type BoundObservabilityCommands,
31-
type DiagnosticsCommands,
3219
} from './observability/runtime/index.ts';
33-
import {
34-
recordingCommands,
35-
type BoundRecordingCommands,
36-
type RecordingCommands,
37-
} from './recording/runtime/index.ts';
38-
import {
39-
systemCommands,
40-
type BoundSystemCommands,
41-
type SystemCommands,
42-
} from './system/runtime/index.ts';
20+
import { recordingCommands, type BoundRecordingCommands } from './recording/runtime/index.ts';
21+
import { systemCommands, type BoundSystemCommands } from './system/runtime/index.ts';
4322

4423
export type { ScreenshotCommandOptions } from './runtime-types.ts';
4524

46-
export type AgentDeviceCommands = {
47-
capture: CaptureCommands;
48-
selectors: SelectorCommands;
49-
interactions: InteractionCommands;
50-
system: SystemCommands;
51-
apps: AppCommands;
52-
admin: AdminCommands;
53-
recording: RecordingCommands;
54-
diagnostics: DiagnosticsCommands;
55-
};
56-
5725
export type BoundAgentDeviceCommands = {
5826
capture: BoundCaptureCommands;
5927
selectors: BoundSelectorCommands;
@@ -65,20 +33,6 @@ export type BoundAgentDeviceCommands = {
6533
observability: BoundObservabilityCommands;
6634
};
6735

68-
/**
69-
* @internal Runtime command catalog used by parity/type tests.
70-
*/
71-
export const commands: AgentDeviceCommands = {
72-
capture: captureCommands,
73-
selectors: selectorCommands,
74-
interactions: interactionCommands,
75-
system: systemCommands,
76-
apps: appCommands,
77-
admin: adminCommands,
78-
recording: recordingCommands,
79-
diagnostics: diagnosticsCommands,
80-
};
81-
8236
export function bindCommands(runtime: AgentDeviceRuntime): BoundAgentDeviceCommands {
8337
return {
8438
capture: bindCaptureCommands(runtime),

‎src/commands/interaction/runtime/index.test.ts‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)