diff --git a/.fallowrc.json b/.fallowrc.json index 4148921ff..f222b162b 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -14,7 +14,7 @@ "src/selectors.ts", "src/finders.ts", "src/bin.ts", - "src/companion-tunnel.ts", + "src/client/companion-tunnel.ts", "src/daemon.ts", "src/utils/png-worker.ts", "scripts/patch-xcuitest-runner-icon.ts", diff --git a/fallow-baselines/health.json b/fallow-baselines/health.json index 83f87a904..eb07648fb 100644 --- a/fallow-baselines/health.json +++ b/fallow-baselines/health.json @@ -74,7 +74,7 @@ "count": 1 } }, - "src/client-companion-tunnel-worker.ts": { + "src/client/client-companion-tunnel-worker.ts": { "complexity_high": { "count": 1 }, @@ -82,7 +82,7 @@ "count": 3 } }, - "src/client-companion-tunnel.ts": { + "src/client/client-companion-tunnel.ts": { "crap_high": { "count": 2 }, @@ -95,7 +95,7 @@ "count": 3 } }, - "src/client-shared.ts": { + "src/client/client-shared.ts": { "crap_moderate": { "count": 1 } @@ -688,7 +688,7 @@ "src/snapshot/snapshot-processing.ts:high impact", "src/daemon/handlers/session-device-utils.ts:high impact", "src/commands/cli-grammar/common.ts:high impact", - "src/client-shared.ts:high impact", + "src/client/client-shared.ts:high impact", "src/replay/script.ts:complexity", "src/commands/selector-read-utils.ts:high impact", "src/core/interaction-targeting.ts:high impact", @@ -736,6 +736,6 @@ "src/platforms/android/app-parsers.ts:high impact", "src/utils/source-value.ts:high impact", "src/platforms/android/sdk.ts:high impact", - "src/client-companion-tunnel-worker.ts:complexity" + "src/client/client-companion-tunnel-worker.ts:complexity" ] } diff --git a/rslib.config.ts b/rslib.config.ts index bbb746d9e..8056ee373 100644 --- a/rslib.config.ts +++ b/rslib.config.ts @@ -35,7 +35,7 @@ export default defineConfig({ selectors: 'src/selectors.ts', finders: 'src/finders.ts', 'internal/bin': 'src/bin.ts', - 'internal/companion-tunnel': 'src/companion-tunnel.ts', + 'internal/companion-tunnel': 'src/client/companion-tunnel.ts', 'internal/daemon': 'src/daemon.ts', 'internal/png-worker': 'src/utils/png-worker.ts', 'internal/update-check-entry': 'src/utils/update-check-entry.ts', diff --git a/src/__tests__/cli-client-commands.test.ts b/src/__tests__/cli-client-commands.test.ts index 000e7b2a4..7a2559c4e 100644 --- a/src/__tests__/cli-client-commands.test.ts +++ b/src/__tests__/cli-client-commands.test.ts @@ -12,8 +12,8 @@ import type { AppOpenOptions, MetroPrepareOptions, MetroReloadOptions, -} from '../client.ts'; -import type { SettingsUpdateOptions } from '../client-types.ts'; +} from '../client/client.ts'; +import type { SettingsUpdateOptions } from '../client/client-types.ts'; import { AppError } from '../kernel/errors.ts'; import { resolveCliOptions } from '../utils/cli-options.ts'; diff --git a/src/__tests__/cli-react-devtools.test.ts b/src/__tests__/cli-react-devtools.test.ts index aae904aca..d3ac0549b 100644 --- a/src/__tests__/cli-react-devtools.test.ts +++ b/src/__tests__/cli-react-devtools.test.ts @@ -6,7 +6,7 @@ vi.mock('../utils/exec.ts', () => ({ runCmdStreaming: vi.fn(), })); -vi.mock('../client-react-devtools-companion.ts', () => ({ +vi.mock('../client/client-react-devtools-companion.ts', () => ({ ensureReactDevtoolsCompanion: vi.fn(), stopReactDevtoolsCompanion: vi.fn(), })); @@ -15,7 +15,7 @@ import { runCmdStreaming } from '../utils/exec.ts'; import { ensureReactDevtoolsCompanion, stopReactDevtoolsCompanion, -} from '../client-react-devtools-companion.ts'; +} from '../client/client-react-devtools-companion.ts'; import { AGENT_REACT_DEVTOOLS_PACKAGE, buildReactDevtoolsNpmExecArgs, diff --git a/src/__tests__/client-companion-tunnel-worker.test.ts b/src/__tests__/client-companion-tunnel-worker.test.ts index 30e1e6dc3..03341f18e 100644 --- a/src/__tests__/client-companion-tunnel-worker.test.ts +++ b/src/__tests__/client-companion-tunnel-worker.test.ts @@ -11,7 +11,7 @@ import { afterEach, test } from 'vitest'; import { buildCompanionPayload, runCompanionTunnelWorker, -} from '../client-companion-tunnel-worker.ts'; +} from '../client/client-companion-tunnel-worker.ts'; import { closeLoopbackServer, listenOnLoopback } from './test-utils/index.ts'; type Deferred = { @@ -243,7 +243,11 @@ function spawnMetroCompanionWorker(options: { const localBaseUrl = options.localBaseUrl ?? `http://127.0.0.1:${options.localPort}`; const companion = spawn( process.execPath, - ['--experimental-strip-types', 'src/companion-tunnel.ts', '--agent-device-run-metro-companion'], + [ + '--experimental-strip-types', + 'src/client/companion-tunnel.ts', + '--agent-device-run-metro-companion', + ], { cwd: process.cwd(), env: { diff --git a/src/__tests__/client-metro-companion.test.ts b/src/__tests__/client-metro-companion.test.ts index 8ec2324bb..5bdab58a3 100644 --- a/src/__tests__/client-metro-companion.test.ts +++ b/src/__tests__/client-metro-companion.test.ts @@ -23,7 +23,7 @@ import { waitForProcessExit, } from '../utils/process-identity.ts'; import { ensureMetroCompanion, stopMetroCompanion } from '../metro/client-metro-companion.ts'; -import { ensureReactDevtoolsCompanion } from '../client-react-devtools-companion.ts'; +import { ensureReactDevtoolsCompanion } from '../client/client-react-devtools-companion.ts'; const TEST_BRIDGE_SCOPE = { tenantId: 'tenant-1', @@ -41,7 +41,7 @@ function assertCompanionSpawnTarget(): void { assert.ok(firstCall, 'expected runCmdDetached to be called'); assert.equal(firstCall[0], process.execPath); assert.ok( - firstCall[1].some((arg) => arg.includes('src/companion-tunnel.ts')), + firstCall[1].some((arg) => arg.includes('src/client/companion-tunnel.ts')), `expected companion entry path in ${JSON.stringify(firstCall[1])}`, ); assert.equal(firstCall[1].at(-1), '--agent-device-run-metro-companion'); @@ -62,7 +62,7 @@ test('companion ownership is profile-scoped and consumer-counted', async () => { pid === 111 ? 'start-111' : 'start-222', ); vi.mocked(readProcessCommand).mockImplementation( - () => `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + () => `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, ); vi.mocked(waitForProcessExit).mockResolvedValue(true); const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true); @@ -161,7 +161,7 @@ test('launchUrl changes force a companion respawn for the same profile', async ( pid === 333 ? 'start-333' : 'start-444', ); vi.mocked(readProcessCommand).mockImplementation( - () => `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + () => `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, ); vi.mocked(waitForProcessExit).mockResolvedValue(true); const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true); @@ -212,8 +212,8 @@ test('metro and React DevTools companions use distinct profile state paths', asy ); vi.mocked(readProcessCommand).mockImplementation((pid) => pid === 888 - ? `${process.execPath} src/companion-tunnel.ts --agent-device-run-react-devtools-companion` - : `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + ? `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-react-devtools-companion` + : `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, ); const profileKey = '/tmp/shared-remote.json'; @@ -257,7 +257,7 @@ test('spawned companion uses neutral env names', async () => { vi.mocked(runCmdDetached).mockReturnValueOnce(999); vi.mocked(readProcessStartTime).mockReturnValue('start-999'); vi.mocked(readProcessCommand).mockReturnValue( - `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, ); await ensureMetroCompanion({ @@ -298,7 +298,7 @@ test('state sentinel exists before spawning companion worker', async () => { }); vi.mocked(readProcessStartTime).mockReturnValue('start-1001'); vi.mocked(readProcessCommand).mockReturnValue( - `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, ); const spawned = await ensureMetroCompanion({ @@ -333,7 +333,7 @@ test('legacy state without bridge scope is stopped before respawn', async () => `${JSON.stringify({ pid: 555, startTime: 'start-555', - command: `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + command: `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, serverBaseUrl: 'https://bridge.example.test', localBaseUrl: 'http://127.0.0.1:8081', tokenHash: 'legacy-token-hash', @@ -345,7 +345,7 @@ test('legacy state without bridge scope is stopped before respawn', async () => vi.mocked(isProcessAlive).mockReturnValue(true); vi.mocked(readProcessStartTime).mockReturnValue('start-555'); vi.mocked(readProcessCommand).mockReturnValue( - `${process.execPath} src/companion-tunnel.ts --agent-device-run-metro-companion`, + `${process.execPath} src/client/companion-tunnel.ts --agent-device-run-metro-companion`, ); vi.mocked(waitForProcessExit).mockResolvedValue(true); const killSpy = vi.spyOn(process, 'kill').mockImplementation(() => true); diff --git a/src/__tests__/client-normalizers.test.ts b/src/__tests__/client-normalizers.test.ts index a64d2f589..7a3e5c09f 100644 --- a/src/__tests__/client-normalizers.test.ts +++ b/src/__tests__/client-normalizers.test.ts @@ -1,6 +1,6 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; -import { normalizeOpenDevice } from '../client-normalizers.ts'; +import { normalizeOpenDevice } from '../client/client-normalizers.ts'; import { PLATFORMS } from '../kernel/device.ts'; test('normalizeOpenDevice accepts exactly the canonical leaf platforms', () => { diff --git a/src/__tests__/client-shared.test.ts b/src/__tests__/client-shared.test.ts index 356e0fc19..03d876f2a 100644 --- a/src/__tests__/client-shared.test.ts +++ b/src/__tests__/client-shared.test.ts @@ -5,7 +5,7 @@ import { serializeOpenResult, serializeSnapshotResult, serializeSessionListEntry, -} from '../client-shared.ts'; +} from '../client/client-shared.ts'; test('serializeSessionListEntry preserves legacy android session payload shape', () => { const data = serializeSessionListEntry({ diff --git a/src/__tests__/client.test.ts b/src/__tests__/client.test.ts index 885604700..28175e0ed 100644 --- a/src/__tests__/client.test.ts +++ b/src/__tests__/client.test.ts @@ -1,6 +1,6 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; -import { createAgentDeviceClient, type AgentDeviceClientConfig } from '../client.ts'; +import { createAgentDeviceClient, type AgentDeviceClientConfig } from '../client/client.ts'; import { runCommand } from '../commands/command-surface.ts'; import type { DaemonRequest, DaemonResponse } from '../kernel/contracts.ts'; import { AppError } from '../kernel/errors.ts'; diff --git a/src/__tests__/cloud-connect-auth.test.ts b/src/__tests__/cloud-connect-auth.test.ts index cd74b75c9..25c4c74bd 100644 --- a/src/__tests__/cloud-connect-auth.test.ts +++ b/src/__tests__/cloud-connect-auth.test.ts @@ -6,7 +6,7 @@ import path from 'node:path'; import { connectCommand } from '../cli/commands/connection.ts'; import { resolveCloudAccessForConnect } from '../cli/auth-session.ts'; import { readActiveConnectionState } from '../remote/remote-connection-state.ts'; -import type { AgentDeviceClient } from '../client.ts'; +import type { AgentDeviceClient } from '../client/client.ts'; afterEach(() => { vi.unstubAllEnvs(); diff --git a/src/__tests__/cloud-connect-profile.test.ts b/src/__tests__/cloud-connect-profile.test.ts index 25e9f7039..5cb04b44b 100644 --- a/src/__tests__/cloud-connect-profile.test.ts +++ b/src/__tests__/cloud-connect-profile.test.ts @@ -10,7 +10,7 @@ import { readActiveConnectionState, type RemoteConnectionState, } from '../remote/remote-connection-state.ts'; -import type { AgentDeviceClient } from '../client.ts'; +import type { AgentDeviceClient } from '../client/client.ts'; vi.mock('../cli/auth-session.ts', () => ({ resolveCloudAccessForConnect: vi.fn(), diff --git a/src/__tests__/remote-connection.test.ts b/src/__tests__/remote-connection.test.ts index 0a989fb7d..1db15781e 100644 --- a/src/__tests__/remote-connection.test.ts +++ b/src/__tests__/remote-connection.test.ts @@ -8,7 +8,7 @@ vi.mock('../metro/client-metro-companion.ts', () => ({ stopMetroCompanion: vi.fn(), })); -vi.mock('../client-react-devtools-companion.ts', () => ({ +vi.mock('../client/client-react-devtools-companion.ts', () => ({ stopReactDevtoolsCompanion: vi.fn(), })); @@ -31,7 +31,7 @@ import { readRemoteConnectionState, writeRemoteConnectionState, } from '../remote/remote-connection-state.ts'; -import type { AgentDeviceClient } from '../client.ts'; +import type { AgentDeviceClient } from '../client/client.ts'; afterEach(() => { vi.clearAllMocks(); diff --git a/src/cli.ts b/src/cli.ts index c2dfbe935..2e0320455 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -5,12 +5,12 @@ import { readVersion } from './utils/version.ts'; import { pathToFileURL } from 'node:url'; import { sendToDaemon } from './daemon-client.ts'; import fs from 'node:fs'; -import type { BatchStep } from './client-types.ts'; +import type { BatchStep } from './client/client-types.ts'; import { createAgentDeviceClient, type AgentDeviceClientConfig, type AgentDeviceDaemonTransport, -} from './client.ts'; +} from './client/client.ts'; import { materializeRemoteConnectionForCommand } from './cli/commands/connection-runtime.ts'; import { tryRunClientBackedCommand } from './cli/commands/router.ts'; import { runAgentCdpCommand } from './cli/commands/agent-cdp.ts'; diff --git a/src/cli/batch-steps.ts b/src/cli/batch-steps.ts index 7f91a6ffc..9dd57c1fd 100644 --- a/src/cli/batch-steps.ts +++ b/src/cli/batch-steps.ts @@ -1,4 +1,4 @@ -import type { BatchStep } from '../client-types.ts'; +import type { BatchStep } from '../client/client-types.ts'; import { type SessionRuntimeHints } from '../kernel/contracts.ts'; import { parseBatchStepRuntime } from '../batch-contract.ts'; import { readInputFromCli } from '../commands/cli-grammar.ts'; diff --git a/src/cli/commands/__tests__/generic.test.ts b/src/cli/commands/__tests__/generic.test.ts index 1885c6784..4e82a3518 100644 --- a/src/cli/commands/__tests__/generic.test.ts +++ b/src/cli/commands/__tests__/generic.test.ts @@ -1,6 +1,6 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; -import { createAgentDeviceClient } from '../../../client.ts'; +import { createAgentDeviceClient } from '../../../client/client.ts'; import type { DaemonResponse } from '../../../kernel/contracts.ts'; import type { CliFlags } from '../../parser/cli-flags.ts'; import type { ClientBackedCliCommandName } from '../../../command-catalog.ts'; diff --git a/src/cli/commands/__tests__/screenshot.test.ts b/src/cli/commands/__tests__/screenshot.test.ts index 6d3a25d45..2e2494a07 100644 --- a/src/cli/commands/__tests__/screenshot.test.ts +++ b/src/cli/commands/__tests__/screenshot.test.ts @@ -1,6 +1,6 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; -import { createAgentDeviceClient } from '../../../client.ts'; +import { createAgentDeviceClient } from '../../../client/client.ts'; import type { DaemonResponse } from '../../../kernel/contracts.ts'; import type { CliFlags } from '../../parser/cli-flags.ts'; import { screenshotCommand } from '../screenshot.ts'; diff --git a/src/cli/commands/connection-runtime.ts b/src/cli/commands/connection-runtime.ts index 6af725b4e..3c68f56a5 100644 --- a/src/cli/commands/connection-runtime.ts +++ b/src/cli/commands/connection-runtime.ts @@ -1,10 +1,10 @@ import { resolveDaemonPaths } from '../../daemon/config.ts'; -import { stopReactDevtoolsCompanion } from '../../client-react-devtools-companion.ts'; +import { stopReactDevtoolsCompanion } from '../../client/client-react-devtools-companion.ts'; import { stopMetroTunnel } from '../../metro/metro.ts'; import { resolveRemoteConfigProfile } from '../../remote/remote-config.ts'; import { resolveDevice, type DeviceInfo } from '../../kernel/device.ts'; import { shouldAgentCdpUseRemoteBridgeUrl } from './agent-cdp.ts'; -import type { MetroBridgeScope } from '../../client-companion-tunnel-contract.ts'; +import type { MetroBridgeScope } from '../../client/client-companion-tunnel-contract.ts'; import { buildRemoteConnectionDaemonState, buildRemoteConnectionRequestMetadata, @@ -15,11 +15,11 @@ import { type RemoteConnectionRequestMetadata, } from '../../remote/remote-connection-state.ts'; import { profileToCliFlags } from '../../utils/remote-config.ts'; -import type { BatchStep } from '../../client-types.ts'; +import type { BatchStep } from '../../client/client-types.ts'; import { AppError } from '../../kernel/errors.ts'; import type { LeaseBackend, SessionRuntimeHints } from '../../kernel/contracts.ts'; import type { CliFlags } from '../parser/cli-flags.ts'; -import type { AgentDeviceClient, Lease } from '../../client.ts'; +import type { AgentDeviceClient, Lease } from '../../client/client.ts'; import type { MetroPrepareKind } from '../../metro/client-metro.ts'; import { INTERNAL_COMMANDS, PUBLIC_COMMANDS } from '../../command-catalog.ts'; diff --git a/src/cli/commands/generic.ts b/src/cli/commands/generic.ts index fcdb7491f..4aad24134 100644 --- a/src/cli/commands/generic.ts +++ b/src/cli/commands/generic.ts @@ -1,4 +1,4 @@ -import type { CommandRequestResult } from '../../client.ts'; +import type { CommandRequestResult } from '../../client/client.ts'; import { renderReplayTestResponse } from '../../cli-test.ts'; import { runCliCommandWithOutput } from '../../commands/cli-runner.ts'; import type { CommandName } from '../../commands/command-metadata.ts'; diff --git a/src/cli/commands/react-devtools.ts b/src/cli/commands/react-devtools.ts index 603d37b13..04dda8067 100644 --- a/src/cli/commands/react-devtools.ts +++ b/src/cli/commands/react-devtools.ts @@ -2,7 +2,7 @@ import { runCmdStreaming } from '../../utils/exec.ts'; import { ensureReactDevtoolsCompanion, stopReactDevtoolsCompanion, -} from '../../client-react-devtools-companion.ts'; +} from '../../client/client-react-devtools-companion.ts'; import { AppError } from '../../kernel/errors.ts'; import { isRemoteBridgeBackend } from './remote-bridge.ts'; import type { CliFlags } from '../parser/cli-flags.ts'; diff --git a/src/cli/commands/router-types.ts b/src/cli/commands/router-types.ts index fe7cd0a25..8824e7f3c 100644 --- a/src/cli/commands/router-types.ts +++ b/src/cli/commands/router-types.ts @@ -1,5 +1,5 @@ import type { CliFlags } from '../parser/cli-flags.ts'; -import type { AgentDeviceClient } from '../../client.ts'; +import type { AgentDeviceClient } from '../../client/client.ts'; import type { CliCommandName } from '../../command-catalog.ts'; export type ClientCommandParams = { diff --git a/src/cli/commands/router.ts b/src/cli/commands/router.ts index 72e3f0409..650bfacbe 100644 --- a/src/cli/commands/router.ts +++ b/src/cli/commands/router.ts @@ -1,5 +1,5 @@ import type { CliFlags } from '../parser/cli-flags.ts'; -import type { AgentDeviceClient } from '../../client.ts'; +import type { AgentDeviceClient } from '../../client/client.ts'; import { isClientBackedCliCommandName, type ClientBackedCliCommandName, diff --git a/src/cli/commands/screenshot.ts b/src/cli/commands/screenshot.ts index bcab7e893..7bcdc8f78 100644 --- a/src/cli/commands/screenshot.ts +++ b/src/cli/commands/screenshot.ts @@ -3,7 +3,7 @@ import { AppError } from '../../kernel/errors.ts'; import { isNonDefaultResponseLevel } from '../../kernel/contracts.ts'; import { resolveUserPath } from '../../utils/path-resolution.ts'; import type { AgentDeviceBackend } from '../../backend.ts'; -import type { AgentDeviceClient, CaptureScreenshotResult } from '../../client.ts'; +import type { AgentDeviceClient, CaptureScreenshotResult } from '../../client/client.ts'; import { createLocalArtifactAdapter } from '../../io.ts'; import { createAgentDevice, localCommandPolicy } from '../../runtime.ts'; import { runCliCommand } from '../../commands/cli-runner.ts'; diff --git a/src/client-companion-tunnel-contract.ts b/src/client/client-companion-tunnel-contract.ts similarity index 100% rename from src/client-companion-tunnel-contract.ts rename to src/client/client-companion-tunnel-contract.ts diff --git a/src/client-companion-tunnel-worker.ts b/src/client/client-companion-tunnel-worker.ts similarity index 99% rename from src/client-companion-tunnel-worker.ts rename to src/client/client-companion-tunnel-worker.ts index 493000c35..24dc4d3a8 100644 --- a/src/client-companion-tunnel-worker.ts +++ b/src/client/client-companion-tunnel-worker.ts @@ -24,8 +24,8 @@ import { import type { MetroTunnelRequestMessage as MetroCompanionRequest, MetroTunnelResponseMessage, -} from './metro/metro.ts'; -import { normalizeBaseUrl } from './utils/url.ts'; +} from '../metro/metro.ts'; +import { normalizeBaseUrl } from '../utils/url.ts'; const COMPANION_REGISTER_TIMEOUT_MS = 5_000; const COMPANION_REGISTER_MAX_RETRY_DELAY_MS = 60_000; diff --git a/src/client-companion-tunnel.ts b/src/client/client-companion-tunnel.ts similarity index 99% rename from src/client-companion-tunnel.ts rename to src/client/client-companion-tunnel.ts index ab42cf1c7..bee0b03c8 100644 --- a/src/client-companion-tunnel.ts +++ b/src/client/client-companion-tunnel.ts @@ -17,14 +17,14 @@ import { ENV_COMPANION_TUNNEL_UNREGISTER_PATH, } from './client-companion-tunnel-contract.ts'; import type { CompanionTunnelScope } from './client-companion-tunnel-contract.ts'; -import { normalizeBaseUrl } from './utils/url.ts'; -import { runCmdDetached } from './utils/exec.ts'; +import { normalizeBaseUrl } from '../utils/url.ts'; +import { runCmdDetached } from '../utils/exec.ts'; import { isProcessAlive, readProcessCommand, readProcessStartTime, waitForProcessExit, -} from './utils/process-identity.ts'; +} from '../utils/process-identity.ts'; const COMPANION_TUNNEL_TERM_TIMEOUT_MS = 1_000; const COMPANION_TUNNEL_KILL_TIMEOUT_MS = 1_000; diff --git a/src/client-normalizers.ts b/src/client/client-normalizers.ts similarity index 95% rename from src/client-normalizers.ts rename to src/client/client-normalizers.ts index caf8d77ac..a502402d1 100644 --- a/src/client-normalizers.ts +++ b/src/client/client-normalizers.ts @@ -1,15 +1,15 @@ -import type { CommandFlags } from './core/dispatch.ts'; -import { screenshotFlagsFromOptions } from './contracts/screenshot.ts'; -import type { DaemonRequest, SessionRuntimeHints } from './daemon/types.ts'; -import { AppError, type NormalizedError } from './kernel/errors.ts'; -import type { SnapshotNode } from './kernel/snapshot.ts'; +import type { CommandFlags } from '../core/dispatch.ts'; +import { screenshotFlagsFromOptions } from '../contracts/screenshot.ts'; +import type { DaemonRequest, SessionRuntimeHints } from '../daemon/types.ts'; +import { AppError, type NormalizedError } from '../kernel/errors.ts'; +import type { SnapshotNode } from '../kernel/snapshot.ts'; import { buildAppIdentifiers, buildDeviceIdentifiers } from './client-shared.ts'; -import { isPlatform } from './kernel/device.ts'; +import { isPlatform } from '../kernel/device.ts'; import { leaseScopeFromOptions, leaseScopeToCommandFlags, leaseScopeToRequestMeta, -} from './core/lease-scope.ts'; +} from '../core/lease-scope.ts'; import type { AgentDeviceDevice, AgentDeviceSession, @@ -32,9 +32,9 @@ import { readRequiredPlatform, readRequiredString, stripUndefined, -} from './utils/parsing.ts'; +} from '../utils/parsing.ts'; -export { readOptionalString, readRequiredString } from './utils/parsing.ts'; +export { readOptionalString, readRequiredString } from '../utils/parsing.ts'; const DEFAULT_SESSION_NAME = 'default'; diff --git a/src/client-react-devtools-companion.ts b/src/client/client-react-devtools-companion.ts similarity index 100% rename from src/client-react-devtools-companion.ts rename to src/client/client-react-devtools-companion.ts diff --git a/src/client-shared.ts b/src/client/client-shared.ts similarity index 97% rename from src/client-shared.ts rename to src/client/client-shared.ts index eba9084e9..5c6c1db38 100644 --- a/src/client-shared.ts +++ b/src/client/client-shared.ts @@ -13,9 +13,9 @@ import type { import { publicSnapshotCaptureAnnotations, type SnapshotCaptureAnnotations, -} from './snapshot-capture-annotations.ts'; -import type { Platform } from './kernel/device.ts'; -import { successText, withSuccessText } from './utils/success-text.ts'; +} from '../snapshot-capture-annotations.ts'; +import type { Platform } from '../kernel/device.ts'; +import { successText, withSuccessText } from '../utils/success-text.ts'; export function buildAppIdentifiers(params: { session?: string; diff --git a/src/client-types.ts b/src/client/client-types.ts similarity index 91% rename from src/client-types.ts rename to src/client/client-types.ts index 57d793fb8..180aa75a6 100644 --- a/src/client-types.ts +++ b/src/client/client-types.ts @@ -1,5 +1,5 @@ -import type { PublicSnapshotCaptureAnnotations } from './snapshot-capture-annotations.ts'; -import type { SnapshotDiagnosticsSummary } from './snapshot-diagnostics.ts'; +import type { PublicSnapshotCaptureAnnotations } from '../snapshot-capture-annotations.ts'; +import type { SnapshotDiagnosticsSummary } from '../snapshot-diagnostics.ts'; import type { DaemonResponseData, DaemonInstallSource, @@ -11,58 +11,58 @@ import type { ResponseLevel, SessionIsolationMode, SessionRuntimeHints, -} from './kernel/contracts.ts'; -import type { DeviceKind, DeviceTarget, Platform, PlatformSelector } from './kernel/device.ts'; -import type { BackMode } from './core/back-mode.ts'; -import type { ClickButton } from './core/click-button.ts'; -import type { RecordingExportQuality } from './core/recording-export-quality.ts'; -import type { DeviceRotation } from './core/device-rotation.ts'; +} from '../kernel/contracts.ts'; +import type { DeviceKind, DeviceTarget, Platform, PlatformSelector } from '../kernel/device.ts'; +import type { BackMode } from '../core/back-mode.ts'; +import type { ClickButton } from '../core/click-button.ts'; +import type { RecordingExportQuality } from '../core/recording-export-quality.ts'; +import type { DeviceRotation } from '../core/device-rotation.ts'; import type { ScrollDirection, SwipePattern, SwipePreset, TransformGestureParams, -} from './core/scroll-gesture.ts'; -import type { ScrollInputDirection } from './commands/interaction/runtime/gestures.ts'; -import type { LogAction } from './contracts/logs.ts'; -import type { SessionSurface } from './core/session-surface.ts'; -import type { FindLocator } from './utils/finders.ts'; -import type { SnapshotNode, SnapshotUnchanged, SnapshotVisibility } from './kernel/snapshot.ts'; -import type { ScreenshotResultData } from './utils/screenshot-result.ts'; +} from '../core/scroll-gesture.ts'; +import type { ScrollInputDirection } from '../commands/interaction/runtime/gestures.ts'; +import type { LogAction } from '../contracts/logs.ts'; +import type { SessionSurface } from '../core/session-surface.ts'; +import type { FindLocator } from '../utils/finders.ts'; +import type { SnapshotNode, SnapshotUnchanged, SnapshotVisibility } from '../kernel/snapshot.ts'; +import type { ScreenshotResultData } from '../utils/screenshot-result.ts'; import type { MetroPrepareKind, PrepareMetroRuntimeResult, ReloadMetroResult, -} from './metro/client-metro.ts'; +} from '../metro/client-metro.ts'; import type { MetroBridgeScope } from './client-companion-tunnel-contract.ts'; -import type { AppsFilter } from './contracts/app-inventory.ts'; -import type { ScreenshotRequestFlags } from './contracts/screenshot.ts'; -import type { BatchRunResult, DaemonBatchStep } from './core/batch.ts'; -export type { BatchRunResult } from './core/batch.ts'; -import type { TargetShutdownResult } from './target-shutdown-contract.ts'; -export type { TargetShutdownResult } from './target-shutdown-contract.ts'; -import type { PerfAction, PerfArea, PerfKind, PerfSubject } from './contracts/perf.ts'; -import type { AlertAction } from './alert-contract.ts'; -import type { DebugSymbolsOptions, DebugSymbolsResult } from './contracts/debug-symbols.ts'; -import type { RemoteConnectionProfileFields } from './remote/remote-config-schema.ts'; -import type { CommandResult } from './core/command-descriptor/command-result.ts'; - -export type { FindLocator } from './utils/finders.ts'; +import type { AppsFilter } from '../contracts/app-inventory.ts'; +import type { ScreenshotRequestFlags } from '../contracts/screenshot.ts'; +import type { BatchRunResult, DaemonBatchStep } from '../core/batch.ts'; +export type { BatchRunResult } from '../core/batch.ts'; +import type { TargetShutdownResult } from '../target-shutdown-contract.ts'; +export type { TargetShutdownResult } from '../target-shutdown-contract.ts'; +import type { PerfAction, PerfArea, PerfKind, PerfSubject } from '../contracts/perf.ts'; +import type { AlertAction } from '../alert-contract.ts'; +import type { DebugSymbolsOptions, DebugSymbolsResult } from '../contracts/debug-symbols.ts'; +import type { RemoteConnectionProfileFields } from '../remote/remote-config-schema.ts'; +import type { CommandResult } from '../core/command-descriptor/command-result.ts'; + +export type { FindLocator } from '../utils/finders.ts'; export type { CompanionTunnelScope, MetroBridgeScope } from './client-companion-tunnel-contract.ts'; -export type { AppsFilter } from './contracts/app-inventory.ts'; -export type { AlertAction, AlertInfo, AlertPlatform, AlertSource } from './alert-contract.ts'; -export type { DebugSymbolsOptions, DebugSymbolsResult } from './contracts/debug-symbols.ts'; -export type { BootCommandResult, ShutdownCommandResult } from './contracts/device.ts'; -export type { ViewportCommandResult } from './contracts/viewport.ts'; +export type { AppsFilter } from '../contracts/app-inventory.ts'; +export type { AlertAction, AlertInfo, AlertPlatform, AlertSource } from '../alert-contract.ts'; +export type { DebugSymbolsOptions, DebugSymbolsResult } from '../contracts/debug-symbols.ts'; +export type { BootCommandResult, ShutdownCommandResult } from '../contracts/device.ts'; +export type { ViewportCommandResult } from '../contracts/viewport.ts'; export type { AppSwitcherCommandResult, BackCommandResult, HomeCommandResult, RotateCommandResult, -} from './contracts/navigation.ts'; -export type { ClipboardCommandResult } from './contracts/clipboard.ts'; -export type { AppStateCommandResult } from './contracts/app-state.ts'; -export type { KeyboardCommandResult } from './contracts/keyboard.ts'; +} from '../contracts/navigation.ts'; +export type { ClipboardCommandResult } from '../contracts/clipboard.ts'; +export type { AppStateCommandResult } from '../contracts/app-state.ts'; +export type { KeyboardCommandResult } from '../contracts/keyboard.ts'; export type AgentDeviceDaemonTransport = ( req: Omit, diff --git a/src/client.ts b/src/client/client.ts similarity index 94% rename from src/client.ts rename to src/client/client.ts index 7e3158dd6..a71524ea7 100644 --- a/src/client.ts +++ b/src/client/client.ts @@ -1,14 +1,14 @@ -import { sendToDaemon } from './daemon-client.ts'; -import { prepareMetroRuntime, reloadMetro } from './metro/client-metro.ts'; -import { resolveDaemonPaths } from './daemon/config.ts'; -import { symbolicateCrashArtifact } from './platforms/ios/debug-symbols.ts'; -import { INTERNAL_COMMANDS } from './command-catalog.ts'; +import { sendToDaemon } from '../daemon-client.ts'; +import { prepareMetroRuntime, reloadMetro } from '../metro/client-metro.ts'; +import { resolveDaemonPaths } from '../daemon/config.ts'; +import { symbolicateCrashArtifact } from '../platforms/ios/debug-symbols.ts'; +import { INTERNAL_COMMANDS } from '../command-catalog.ts'; import { prepareDaemonCommandRequest, type DaemonCommandName, -} from './commands/command-projection.ts'; -import { buildRequestFlags } from './commands/command-flags.ts'; -import { throwDaemonError } from './daemon-error.ts'; +} from '../commands/command-projection.ts'; +import { buildRequestFlags } from '../commands/command-flags.ts'; +import { throwDaemonError } from '../daemon-error.ts'; import { buildMeta, normalizeDeployResult, @@ -25,8 +25,8 @@ import { readSnapshotNodes, resolveSessionName, } from './client-normalizers.ts'; -import { readScreenshotResultData } from './utils/screenshot-result.ts'; -import { isRecord } from './utils/parsing.ts'; +import { readScreenshotResultData } from '../utils/screenshot-result.ts'; +import { isRecord } from '../utils/parsing.ts'; import type { AgentDeviceClient, AgentDeviceClientConfig, @@ -46,11 +46,11 @@ import type { MaterializationReleaseOptions, MetroPrepareOptions, } from './client-types.ts'; -import type { CommandResult } from './core/command-descriptor/command-result.ts'; -import { isNonDefaultResponseLevel, type ResponseLevel } from './kernel/contracts.ts'; -import { readSerializedSnapshotCaptureAnnotations } from './snapshot-capture-annotations.ts'; -import { readSnapshotDiagnosticsSummary } from './snapshot-diagnostics.ts'; -import type { CommandFlags } from './core/dispatch-context.ts'; +import type { CommandResult } from '../core/command-descriptor/command-result.ts'; +import { isNonDefaultResponseLevel, type ResponseLevel } from '../kernel/contracts.ts'; +import { readSerializedSnapshotCaptureAnnotations } from '../snapshot-capture-annotations.ts'; +import { readSnapshotDiagnosticsSummary } from '../snapshot-diagnostics.ts'; +import type { CommandFlags } from '../core/dispatch-context.ts'; export function createAgentDeviceClient( config: AgentDeviceClientConfig = {}, diff --git a/src/companion-tunnel.ts b/src/client/companion-tunnel.ts similarity index 100% rename from src/companion-tunnel.ts rename to src/client/companion-tunnel.ts diff --git a/src/commands/__tests__/command-flags.test.ts b/src/commands/__tests__/command-flags.test.ts index ee32b99c9..45b2ff431 100644 --- a/src/commands/__tests__/command-flags.test.ts +++ b/src/commands/__tests__/command-flags.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; -import type { InternalRequestOptions } from '../../client-types.ts'; +import type { InternalRequestOptions } from '../../client/client-types.ts'; import { findCommandMetadata } from '../command-metadata.ts'; import { readMetadataCommandFlags } from '../command-flags.ts'; diff --git a/src/commands/batch/index.ts b/src/commands/batch/index.ts index 5739ac2b1..b066c4395 100644 --- a/src/commands/batch/index.ts +++ b/src/commands/batch/index.ts @@ -1,4 +1,4 @@ -import type { BatchRunOptions } from '../../client-types.ts'; +import type { BatchRunOptions } from '../../client/client-types.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { commonInputFromFlags } from '../cli-grammar/common.ts'; import type { CliReader } from '../cli-grammar/types.ts'; diff --git a/src/commands/capture/alert.ts b/src/commands/capture/alert.ts index cc25e4736..d4576a320 100644 --- a/src/commands/capture/alert.ts +++ b/src/commands/capture/alert.ts @@ -1,6 +1,6 @@ import { ALERT_ACTIONS, type AlertAction } from '../../alert-contract.ts'; import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { AlertCommandOptions } from '../../client-types.ts'; +import type { AlertCommandOptions } from '../../client/client-types.ts'; import { compactRecord, enumField, integerField } from '../command-input.ts'; import { defineExecutableCommand } from '../command-contract.ts'; import { diff --git a/src/commands/capture/output.ts b/src/commands/capture/output.ts index 273e4e4ce..c58e8531c 100644 --- a/src/commands/capture/output.ts +++ b/src/commands/capture/output.ts @@ -1,5 +1,5 @@ -import { serializeSnapshotResult } from '../../client-shared.ts'; -import type { CaptureSnapshotResult } from '../../client-types.ts'; +import { serializeSnapshotResult } from '../../client/client-shared.ts'; +import type { CaptureSnapshotResult } from '../../client/client-types.ts'; import { formatSnapshotText } from '../../utils/output.ts'; import type { CliOutput } from '../command-contract.ts'; import { messageOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/commands/capture/screenshot.ts b/src/commands/capture/screenshot.ts index 5bc297cac..72ec7a185 100644 --- a/src/commands/capture/screenshot.ts +++ b/src/commands/capture/screenshot.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { CaptureScreenshotOptions } from '../../client-types.ts'; +import type { CaptureScreenshotOptions } from '../../client/client-types.ts'; import { SESSION_SURFACES } from '../../core/session-surface.ts'; import { SCREENSHOT_COMMAND_FLAG_KEYS, diff --git a/src/commands/capture/settings.ts b/src/commands/capture/settings.ts index 316a35502..eedf934b7 100644 --- a/src/commands/capture/settings.ts +++ b/src/commands/capture/settings.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { SettingsUpdateOptions } from '../../client-types.ts'; +import type { SettingsUpdateOptions } from '../../client/client-types.ts'; import { SETTINGS_USAGE_OVERRIDE } from '../../core/settings-contract.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import type { CliFlags } from '../../cli/parser/cli-flags.ts'; diff --git a/src/commands/capture/wait.ts b/src/commands/capture/wait.ts index f96760599..e4d2a06e1 100644 --- a/src/commands/capture/wait.ts +++ b/src/commands/capture/wait.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { WaitCommandOptions } from '../../client-types.ts'; +import type { WaitCommandOptions } from '../../client/client-types.ts'; import { parseWaitPositionals } from '../../core/wait-positionals.ts'; import { SELECTOR_SNAPSHOT_FLAGS, type CliFlags } from '../../cli/parser/cli-flags.ts'; import { AppError } from '../../kernel/errors.ts'; diff --git a/src/commands/cli-grammar/common.ts b/src/commands/cli-grammar/common.ts index 1059a302a..16972dd21 100644 --- a/src/commands/cli-grammar/common.ts +++ b/src/commands/cli-grammar/common.ts @@ -2,7 +2,7 @@ import type { ElementTarget, InteractionTarget, InternalRequestOptions, -} from '../../client-types.ts'; +} from '../../client/client-types.ts'; import { splitSelectorFromArgs } from '../../utils/selectors-parse.ts'; import type { CliFlags } from '../../cli/parser/cli-flags.ts'; import { AppError } from '../../kernel/errors.ts'; diff --git a/src/commands/cli-grammar/types.ts b/src/commands/cli-grammar/types.ts index d77727b77..14fdec8e0 100644 --- a/src/commands/cli-grammar/types.ts +++ b/src/commands/cli-grammar/types.ts @@ -1,4 +1,4 @@ -import type { InteractionTarget, InternalRequestOptions } from '../../client-types.ts'; +import type { InteractionTarget, InternalRequestOptions } from '../../client/client-types.ts'; import type { CommandFlags } from '../../core/dispatch-context.ts'; import type { CliFlags } from '../../cli/parser/cli-flags.ts'; import type { ClickButton } from '../../core/click-button.ts'; diff --git a/src/commands/cli-runner.ts b/src/commands/cli-runner.ts index 48d1057b0..35188b8c3 100644 --- a/src/commands/cli-runner.ts +++ b/src/commands/cli-runner.ts @@ -1,4 +1,4 @@ -import type { AgentDeviceClient, CommandRequestResult } from '../client.ts'; +import type { AgentDeviceClient, CommandRequestResult } from '../client/client.ts'; import { formatCliOutput } from './cli-output.ts'; import { readInputFromCli } from './cli-grammar.ts'; import { runCommand, type CommandName } from './command-surface.ts'; diff --git a/src/commands/command-contract.ts b/src/commands/command-contract.ts index 2e16fbbcc..d1c723f87 100644 --- a/src/commands/command-contract.ts +++ b/src/commands/command-contract.ts @@ -1,4 +1,4 @@ -import type { AgentDeviceClient } from '../client-types.ts'; +import type { AgentDeviceClient } from '../client/client-types.ts'; export type JsonSchema = { type?: string | readonly string[]; diff --git a/src/commands/command-flags.ts b/src/commands/command-flags.ts index eac662c3a..f55d57c5a 100644 --- a/src/commands/command-flags.ts +++ b/src/commands/command-flags.ts @@ -1,7 +1,7 @@ -import { buildFlags } from '../client-normalizers.ts'; +import { buildFlags } from '../client/client-normalizers.ts'; import type { CommandFlags } from '../core/dispatch-context.ts'; import { getFlagDefinitions } from '../cli/parser/cli-flags.ts'; -import type { InternalRequestOptions } from '../client-types.ts'; +import type { InternalRequestOptions } from '../client/client-types.ts'; import type { CommandMetadata } from './command-contract.ts'; const CLI_FLAG_KEYS: ReadonlySet = new Set( diff --git a/src/commands/command-input.ts b/src/commands/command-input.ts index 20b169e37..de0116db4 100644 --- a/src/commands/command-input.ts +++ b/src/commands/command-input.ts @@ -3,7 +3,7 @@ import type { AgentDeviceSelectionOptions, ElementTarget, InteractionTarget, -} from '../client-types.ts'; +} from '../client/client-types.ts'; import { DEVICE_TARGETS, PLATFORM_SELECTORS, diff --git a/src/commands/command-surface.ts b/src/commands/command-surface.ts index d3db68ab6..eeedeb235 100644 --- a/src/commands/command-surface.ts +++ b/src/commands/command-surface.ts @@ -1,4 +1,4 @@ -import type { AgentDeviceClient } from '../client-types.ts'; +import type { AgentDeviceClient } from '../client/client-types.ts'; import { listCommandFamilyDefinitions, type CommandFamilyDefinition } from './family/registry.ts'; import type { BatchCommandName } from './command-projection.ts'; import type { CommandName } from './command-metadata.ts'; diff --git a/src/commands/debugging/output.ts b/src/commands/debugging/output.ts index a51e608a1..a3bb9541c 100644 --- a/src/commands/debugging/output.ts +++ b/src/commands/debugging/output.ts @@ -1,4 +1,4 @@ -import type { DebugSymbolsResult } from '../../client-types.ts'; +import type { DebugSymbolsResult } from '../../client/client-types.ts'; import type { CliOutput } from '../command-contract.ts'; import { resultOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/commands/family/types.ts b/src/commands/family/types.ts index 6d3d32a23..1ad2a758f 100644 --- a/src/commands/family/types.ts +++ b/src/commands/family/types.ts @@ -1,4 +1,4 @@ -import type { AgentDeviceClient } from '../../client-types.ts'; +import type { AgentDeviceClient } from '../../client/client-types.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import type { CliReader, DaemonWriter } from '../cli-grammar/types.ts'; import type { CommandMetadata, JsonSchema } from '../command-contract.ts'; diff --git a/src/commands/interaction/gesture.ts b/src/commands/interaction/gesture.ts index 72a617f01..96b9d46bd 100644 --- a/src/commands/interaction/gesture.ts +++ b/src/commands/interaction/gesture.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { FlingOptions, RotateGestureOptions } from '../../client-types.ts'; +import type { FlingOptions, RotateGestureOptions } from '../../client/client-types.ts'; import type { CliFlags } from '../../cli/parser/cli-flags.ts'; import { AppError } from '../../kernel/errors.ts'; import { diff --git a/src/commands/interaction/index.ts b/src/commands/interaction/index.ts index 553c47e3d..411e5f44d 100644 --- a/src/commands/interaction/index.ts +++ b/src/commands/interaction/index.ts @@ -16,7 +16,7 @@ import type { SwipeOptions, TransformGestureOptions, TypeTextOptions, -} from '../../client-types.ts'; +} from '../../client/client-types.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { REPEATED_TOUCH_FLAGS, SELECTOR_SNAPSHOT_FLAGS } from '../../cli/parser/cli-flags.ts'; import { defineCommandFacet, defineCommandFamilyFromFacets } from '../family/types.ts'; diff --git a/src/commands/interaction/interactions.ts b/src/commands/interaction/interactions.ts index 6327e4972..2864c2091 100644 --- a/src/commands/interaction/interactions.ts +++ b/src/commands/interaction/interactions.ts @@ -5,7 +5,7 @@ import type { InteractionTarget, LongPressOptions, TypeTextOptions, -} from '../../client-types.ts'; +} from '../../client/client-types.ts'; import { readFillTargetFromPositionals, readInteractionTargetFromPositionals, diff --git a/src/commands/interaction/output.ts b/src/commands/interaction/output.ts index 7c9804b78..e0a12fa13 100644 --- a/src/commands/interaction/output.ts +++ b/src/commands/interaction/output.ts @@ -1,4 +1,4 @@ -import type { CommandRequestResult } from '../../client-types.ts'; +import type { CommandRequestResult } from '../../client/client-types.ts'; import type { CliOutput } from '../command-contract.ts'; import { messageCliOutput, resultOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/commands/interaction/selectors.ts b/src/commands/interaction/selectors.ts index 120a95857..3073855ec 100644 --- a/src/commands/interaction/selectors.ts +++ b/src/commands/interaction/selectors.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { FindOptions, IsOptions } from '../../client-types.ts'; +import type { FindOptions, IsOptions } from '../../client/client-types.ts'; import type { CliFlags } from '../../cli/parser/cli-flags.ts'; import { AppError } from '../../kernel/errors.ts'; import { diff --git a/src/commands/management/app.ts b/src/commands/management/app.ts index ea4eadfc7..c873747ef 100644 --- a/src/commands/management/app.ts +++ b/src/commands/management/app.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { AppCloseOptions } from '../../client-types.ts'; +import type { AppCloseOptions } from '../../client/client-types.ts'; import { DEFAULT_APPS_FILTER } from '../../contracts/app-inventory.ts'; import { SESSION_SURFACES } from '../../core/session-surface.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; diff --git a/src/commands/management/output.ts b/src/commands/management/output.ts index ac1bf3cde..618d8ab62 100644 --- a/src/commands/management/output.ts +++ b/src/commands/management/output.ts @@ -5,7 +5,7 @@ import { serializeInstallFromSourceResult, serializeOpenResult, serializeSessionListEntry, -} from '../../client-shared.ts'; +} from '../../client/client-shared.ts'; import type { AgentDeviceDevice, AgentDeviceSession, @@ -15,7 +15,7 @@ import type { AppOpenResult, CommandRequestResult, SessionCloseResult, -} from '../../client-types.ts'; +} from '../../client/client-types.ts'; import { readCommandMessage } from '../../utils/success-text.ts'; import type { CliOutput } from '../command-contract.ts'; import { diff --git a/src/commands/management/push.ts b/src/commands/management/push.ts index 04067e63c..536747366 100644 --- a/src/commands/management/push.ts +++ b/src/commands/management/push.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { AppPushOptions, AppTriggerEventOptions } from '../../client-types.ts'; +import type { AppPushOptions, AppTriggerEventOptions } from '../../client/client-types.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { jsonSchemaField, diff --git a/src/commands/management/viewport.ts b/src/commands/management/viewport.ts index 71c0fa080..5bc394606 100644 --- a/src/commands/management/viewport.ts +++ b/src/commands/management/viewport.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { ViewportCommandOptions } from '../../client-types.ts'; +import type { ViewportCommandOptions } from '../../client/client-types.ts'; import { readViewportDimension } from '../../core/viewport-dimension.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { integerField, requiredField } from '../command-input.ts'; diff --git a/src/commands/metro/index.ts b/src/commands/metro/index.ts index d484eb7c1..b6eeda85e 100644 --- a/src/commands/metro/index.ts +++ b/src/commands/metro/index.ts @@ -4,7 +4,7 @@ import type { MetroPrepareResult, MetroReloadOptions, MetroReloadResult, -} from '../../client-types.ts'; +} from '../../client/client-types.ts'; import { AppError } from '../../kernel/errors.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { diff --git a/src/commands/observability/index.ts b/src/commands/observability/index.ts index 0bab2977c..028fa54c2 100644 --- a/src/commands/observability/index.ts +++ b/src/commands/observability/index.ts @@ -1,4 +1,4 @@ -import type { LogsOptions, NetworkOptions } from '../../client-types.ts'; +import type { LogsOptions, NetworkOptions } from '../../client/client-types.ts'; import { NETWORK_INCLUDE_MODES, type NetworkIncludeMode } from '../../kernel/contracts.ts'; import { AppError } from '../../kernel/errors.ts'; import { parseStringMember } from '../../utils/string-enum.ts'; diff --git a/src/commands/perf/index.ts b/src/commands/perf/index.ts index b34bfbfe1..98bec5382 100644 --- a/src/commands/perf/index.ts +++ b/src/commands/perf/index.ts @@ -1,4 +1,4 @@ -import type { PerfOptions } from '../../client-types.ts'; +import type { PerfOptions } from '../../client/client-types.ts'; import { AppError } from '../../kernel/errors.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { enumField, stringField } from '../command-input.ts'; diff --git a/src/commands/perf/output.ts b/src/commands/perf/output.ts index ec39cc40e..42efe5c85 100644 --- a/src/commands/perf/output.ts +++ b/src/commands/perf/output.ts @@ -1,4 +1,4 @@ -import type { CommandRequestResult } from '../../client-types.ts'; +import type { CommandRequestResult } from '../../client/client-types.ts'; import { isRecord } from '../../utils/parsing.ts'; import type { CliOutput } from '../command-contract.ts'; import { resultOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/commands/recording/index.ts b/src/commands/recording/index.ts index 16eaee504..e9590aef9 100644 --- a/src/commands/recording/index.ts +++ b/src/commands/recording/index.ts @@ -1,4 +1,4 @@ -import type { RecordOptions } from '../../client-types.ts'; +import type { RecordOptions } from '../../client/client-types.ts'; import { RECORDING_EXPORT_QUALITIES } from '../../core/recording-export-quality.ts'; import { AppError } from '../../kernel/errors.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; diff --git a/src/commands/recording/output.ts b/src/commands/recording/output.ts index d36ed9c61..06e136a24 100644 --- a/src/commands/recording/output.ts +++ b/src/commands/recording/output.ts @@ -1,4 +1,4 @@ -import type { CommandRequestResult } from '../../client-types.ts'; +import type { CommandRequestResult } from '../../client/client-types.ts'; import type { CliOutput } from '../command-contract.ts'; import { resultOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/commands/system/index.ts b/src/commands/system/index.ts index b16d411e5..c921b9607 100644 --- a/src/commands/system/index.ts +++ b/src/commands/system/index.ts @@ -1,4 +1,4 @@ -import type { ClipboardCommandOptions } from '../../client-types.ts'; +import type { ClipboardCommandOptions } from '../../client/client-types.ts'; import type { BackMode } from '../../core/back-mode.ts'; import { BACK_MODES } from '../../core/back-mode.ts'; import { parseDeviceRotation, DEVICE_ROTATIONS } from '../../core/device-rotation.ts'; diff --git a/src/commands/system/output.ts b/src/commands/system/output.ts index 9c3f62487..f4190f01d 100644 --- a/src/commands/system/output.ts +++ b/src/commands/system/output.ts @@ -2,7 +2,7 @@ import type { AppStateCommandResult, ClipboardCommandResult, KeyboardCommandResult, -} from '../../client-types.ts'; +} from '../../client/client-types.ts'; import type { CliOutput } from '../command-contract.ts'; import { messageCliOutput, diff --git a/src/daemon/handlers/__tests__/snapshot-handler.test.ts b/src/daemon/handlers/__tests__/snapshot-handler.test.ts index 810655d28..85e7a2de3 100644 --- a/src/daemon/handlers/__tests__/snapshot-handler.test.ts +++ b/src/daemon/handlers/__tests__/snapshot-handler.test.ts @@ -13,7 +13,7 @@ import { buildSnapshotSignatures } from '../../android-snapshot-freshness.ts'; import { buildInteractionSurfaceSignature } from '../../interaction-outcome-policy.ts'; import { buildSnapshotPresentationKey } from '../../../kernel/snapshot.ts'; import { snapshotCliOutput } from '../../../commands/capture/output.ts'; -import type { CaptureSnapshotResult } from '../../../client-types.ts'; +import type { CaptureSnapshotResult } from '../../../client/client-types.ts'; vi.mock('../../../core/dispatch.ts', async (importOriginal) => { const actual = await importOriginal(); diff --git a/src/daemon/handlers/install-source.ts b/src/daemon/handlers/install-source.ts index 84b1be400..ed3a74e7c 100644 --- a/src/daemon/handlers/install-source.ts +++ b/src/daemon/handlers/install-source.ts @@ -14,7 +14,7 @@ import { resolveInstallSource } from '../install-source-resolution.ts'; import { SessionStore } from '../session-store.ts'; import type { DaemonRequest, DaemonResponse, SessionState } from '../types.ts'; -import { resolveInstallFromSourceResultTarget } from '../../client-shared.ts'; +import { resolveInstallFromSourceResultTarget } from '../../client/client-shared.ts'; import { AppError, normalizeError } from '../../kernel/errors.ts'; import { withSuccessText } from '../../utils/success-text.ts'; import { requireCommandSupported } from './response.ts'; diff --git a/src/daemon/handlers/session-deploy.ts b/src/daemon/handlers/session-deploy.ts index f31ae219e..3bf1d7201 100644 --- a/src/daemon/handlers/session-deploy.ts +++ b/src/daemon/handlers/session-deploy.ts @@ -5,7 +5,7 @@ import type { DeviceInfo } from '../../kernel/device.ts'; import type { DaemonRequest, DaemonResponse } from '../types.ts'; import { SessionStore } from '../session-store.ts'; import { recordSessionAction } from './handler-utils.ts'; -import { resolveDeployResultTarget } from '../../client-shared.ts'; +import { resolveDeployResultTarget } from '../../client/client-shared.ts'; import { withSuccessText } from '../../utils/success-text.ts'; import { requireSessionOrExplicitSelector, resolveCommandDevice } from './session-device-utils.ts'; import { errorResponse, requireCommandSupported } from './response.ts'; diff --git a/src/index.ts b/src/index.ts index ab4f7a194..f0e9f502c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export { createAgentDeviceClient } from './client.ts'; +export { createAgentDeviceClient } from './client/client.ts'; export { createLocalArtifactAdapter } from './io.ts'; export { AppError, isAgentDeviceError, normalizeAgentDeviceError } from './kernel/errors.ts'; export { centerOfRect } from './kernel/snapshot.ts'; @@ -118,7 +118,7 @@ export type { TraceOptions, TypeTextOptions, WaitCommandOptions, -} from './client.ts'; +} from './client/client.ts'; export type { Point, diff --git a/src/mcp/__tests__/command-tools.test.ts b/src/mcp/__tests__/command-tools.test.ts index 6d911da0a..2845b11b5 100644 --- a/src/mcp/__tests__/command-tools.test.ts +++ b/src/mcp/__tests__/command-tools.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; -import type { AgentDeviceClient } from '../../client-types.ts'; +import type { AgentDeviceClient } from '../../client/client-types.ts'; import { createCommandToolExecutor, listCommandTools } from '../command-tools.ts'; test('MCP command tool executor hides client creation behind an execution adapter', async () => { diff --git a/src/mcp/command-tools.ts b/src/mcp/command-tools.ts index 0f82cc24b..e36e9a3ff 100644 --- a/src/mcp/command-tools.ts +++ b/src/mcp/command-tools.ts @@ -1,4 +1,4 @@ -import type { AgentDeviceClient, AgentDeviceClientConfig } from '../client-types.ts'; +import type { AgentDeviceClient, AgentDeviceClientConfig } from '../client/client-types.ts'; import type { JsonSchema } from '../commands/command-contract.ts'; import { RESPONSE_LEVELS, type ResponseLevel } from '../kernel/contracts.ts'; import { formatCliOutput } from '../commands/cli-output.ts'; @@ -94,7 +94,7 @@ async function createClient( config: AgentDeviceClientConfig, ): Promise { if (deps.createClient) return await deps.createClient(config); - const { createAgentDeviceClient } = await import('../client.ts'); + const { createAgentDeviceClient } = await import('../client/client.ts'); return createAgentDeviceClient(config); } diff --git a/src/metro/client-metro-companion.ts b/src/metro/client-metro-companion.ts index 27a76bab8..099ed8e22 100644 --- a/src/metro/client-metro-companion.ts +++ b/src/metro/client-metro-companion.ts @@ -4,8 +4,8 @@ import { type CompanionTunnelDefinition, type EnsureCompanionTunnelOptions, type StopCompanionTunnelOptions, -} from '../client-companion-tunnel.ts'; -import { METRO_COMPANION_RUN_ARG } from '../client-companion-tunnel-contract.ts'; +} from '../client/client-companion-tunnel.ts'; +import { METRO_COMPANION_RUN_ARG } from '../client/client-companion-tunnel-contract.ts'; const METRO_COMPANION_REGISTER_PATH = '/api/metro/companion/register'; diff --git a/src/metro/client-metro.ts b/src/metro/client-metro.ts index 0fd71928a..002105ee0 100644 --- a/src/metro/client-metro.ts +++ b/src/metro/client-metro.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { sleep } from '../utils/timeouts.ts'; import { ensureMetroCompanion } from './client-metro-companion.ts'; -import type { MetroBridgeScope } from '../client-companion-tunnel-contract.ts'; +import type { MetroBridgeScope } from '../client/client-companion-tunnel-contract.ts'; import type { MetroBridgeDescriptor, MetroBridgeResult, @@ -31,7 +31,7 @@ type EnvSource = NodeJS.ProcessEnv | Record; export type { CompanionTunnelScope, MetroBridgeScope, -} from '../client-companion-tunnel-contract.ts'; +} from '../client/client-companion-tunnel-contract.ts'; type PackageJsonShape = { dependencies?: Record; diff --git a/src/metro/metro.ts b/src/metro/metro.ts index 1bdd3d93e..71ffb2aba 100644 --- a/src/metro/metro.ts +++ b/src/metro/metro.ts @@ -8,13 +8,13 @@ import { type ReloadMetroResult, } from './client-metro.ts'; import { ensureMetroCompanion, stopMetroCompanion } from './client-metro-companion.ts'; -import type { MetroBridgeScope } from '../client-companion-tunnel-contract.ts'; +import type { MetroBridgeScope } from '../client/client-companion-tunnel-contract.ts'; import { resolveRuntimeTransportHints } from '../utils/runtime-transport.ts'; export { buildBundleUrl, normalizeBaseUrl } from '../utils/url.ts'; export type { CompanionTunnelScope, MetroBridgeScope, -} from '../client-companion-tunnel-contract.ts'; +} from '../client/client-companion-tunnel-contract.ts'; export type { MetroBridgeDescriptor, diff --git a/test/integration/provider-scenarios/android-lifecycle.test.ts b/test/integration/provider-scenarios/android-lifecycle.test.ts index 3dfcea024..627810a3c 100644 --- a/test/integration/provider-scenarios/android-lifecycle.test.ts +++ b/test/integration/provider-scenarios/android-lifecycle.test.ts @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import { test } from 'vitest'; -import type { AgentDeviceClient } from '../../../src/client-types.ts'; +import type { AgentDeviceClient } from '../../../src/client/client-types.ts'; import { arrayEqual, assertCommandCall, diff --git a/test/integration/provider-scenarios/harness.ts b/test/integration/provider-scenarios/harness.ts index b9e9f18e1..37682f51d 100644 --- a/test/integration/provider-scenarios/harness.ts +++ b/test/integration/provider-scenarios/harness.ts @@ -1,8 +1,11 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { createAgentDeviceClient } from '../../../src/client.ts'; -import type { AgentDeviceClient, AgentDeviceDaemonTransport } from '../../../src/client-types.ts'; +import { createAgentDeviceClient } from '../../../src/client/client.ts'; +import type { + AgentDeviceClient, + AgentDeviceDaemonTransport, +} from '../../../src/client/client-types.ts'; import { createRequestHandler, type RequestRouterDeps, diff --git a/test/integration/provider-scenarios/remote-daemon-client.test.ts b/test/integration/provider-scenarios/remote-daemon-client.test.ts index b01bec140..ec0d5702a 100644 --- a/test/integration/provider-scenarios/remote-daemon-client.test.ts +++ b/test/integration/provider-scenarios/remote-daemon-client.test.ts @@ -4,7 +4,7 @@ import http from 'node:http'; import os from 'node:os'; import path from 'node:path'; import { test } from 'vitest'; -import { createAgentDeviceClient } from '../../../src/client.ts'; +import { createAgentDeviceClient } from '../../../src/client/client.ts'; import { prepareRemoteRequestArtifacts } from '../../../src/remote/daemon-artifacts.ts'; import { createDaemonProxyServer } from '../../../src/remote/daemon-proxy.ts'; import { normalizeAgentDeviceError } from '../../../src/kernel/errors.ts'; diff --git a/vitest.config.ts b/vitest.config.ts index 798c375d6..95cacb716 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -33,7 +33,7 @@ export default defineConfig({ 'src/artifacts.ts', 'src/batch.ts', 'src/bin.ts', - 'src/client-types.ts', + 'src/client/client-types.ts', 'src/core/interactor-types.ts', 'src/index.ts', 'src/install-source.ts',