Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fallowrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions fallow-baselines/health.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
"count": 1
}
},
"src/client-companion-tunnel-worker.ts": {
"src/client/client-companion-tunnel-worker.ts": {
"complexity_high": {
"count": 1
},
"crap_moderate": {
"count": 3
}
},
"src/client-companion-tunnel.ts": {
"src/client/client-companion-tunnel.ts": {
"crap_high": {
"count": 2
},
Expand All @@ -95,7 +95,7 @@
"count": 3
}
},
"src/client-shared.ts": {
"src/client/client-shared.ts": {
"crap_moderate": {
"count": 1
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
]
}
2 changes: 1 addition & 1 deletion rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/cli-client-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/cli-react-devtools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));
Expand All @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions src/__tests__/client-companion-tunnel-worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
Expand Down Expand Up @@ -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: {
Expand Down
20 changes: 10 additions & 10 deletions src/__tests__/client-metro-companion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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',
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client-normalizers.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client-shared.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/client.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/cloud-connect-auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/cloud-connect-profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/remote-connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}));

Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/batch-steps.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/__tests__/generic.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/__tests__/screenshot.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
8 changes: 4 additions & 4 deletions src/cli/commands/connection-runtime.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/generic.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/react-devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/router-types.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/router.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading