From 06647f3ba889e2f953924e2b19abf1cfeae30edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Tue, 30 Jun 2026 10:57:20 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20move=20contracts.ts=20into=20src/ke?= =?UTF-8?q?rnel=20=E2=80=94=20Phase=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relocate the central contracts barrel into the kernel/ dependency sink alongside device/errors/redaction/snapshot (kernel now owns the pure domain types per plans/perfect-shape.md ยง5.5). - src/contracts.ts -> src/kernel/contracts.ts (git rename) - repoint all 44 internal importers to ../kernel/contracts.ts - rslib entry keeps key 'contracts' so dist output stays dist/src/contracts.js; the public 'agent-device/contracts' subpath is byte-identical (proven by the metro precedent in #947 and verified via build + package-exports test) - update .fallowrc.json entrypoint + fallow-baselines/health.json key Behaviorless path codemod (49 files, +57/-57). typecheck/lint/build/fallow audit/public-contract tests all green. --- .fallowrc.json | 2 +- fallow-baselines/health.json | 2 +- rslib.config.ts | 2 +- src/__tests__/client.test.ts | 2 +- src/__tests__/contracts-schema-public.test.ts | 2 +- src/backend.ts | 2 +- src/batch-contract.ts | 2 +- src/cli.ts | 2 +- src/cli/batch-steps.ts | 2 +- src/cli/commands/__tests__/generic.test.ts | 2 +- src/cli/commands/__tests__/screenshot.test.ts | 2 +- src/cli/commands/agent-cdp.ts | 2 +- src/cli/commands/connection-runtime.ts | 2 +- src/cli/commands/connection.ts | 2 +- src/cli/commands/generic.ts | 2 +- src/cli/commands/screenshot.ts | 2 +- src/client-types.ts | 2 +- src/client.ts | 2 +- src/commands/batch/metadata.ts | 2 +- src/commands/batch/public.test.ts | 2 +- src/commands/management/install.ts | 2 +- src/commands/observability/index.ts | 2 +- src/commands/observability/output.ts | 2 +- src/core/batch.ts | 2 +- src/core/lease-scope.ts | 2 +- src/daemon-error.ts | 2 +- src/daemon/__tests__/request-router-cost.test.ts | 2 +- .../request-router-response-level.test.ts | 2 +- src/daemon/config.ts | 2 +- src/daemon/handlers/session-observability.ts | 2 +- src/daemon/http-server.ts | 4 ++-- src/daemon/lease-context.ts | 2 +- src/daemon/lease-registry.ts | 2 +- src/daemon/network-log.ts | 2 +- src/daemon/request-router.ts | 2 +- src/daemon/response-views.ts | 2 +- src/daemon/types.ts | 4 ++-- src/index.ts | 2 +- src/{ => kernel}/contracts.ts | 14 +++++++------- src/mcp/command-tools.ts | 2 +- src/mcp/router.ts | 2 +- src/mcp/server.ts | 2 +- src/metro/metro-types.ts | 2 +- src/metro/metro.ts | 2 +- src/remote-config-schema.ts | 2 +- src/remote-connection-state.ts | 2 +- src/utils/cli-flags.ts | 2 +- src/utils/install-source-config.ts | 2 +- src/utils/runtime-transport.ts | 2 +- 49 files changed, 57 insertions(+), 57 deletions(-) rename src/{ => kernel}/contracts.ts (97%) diff --git a/.fallowrc.json b/.fallowrc.json index 46d1a6110..8f4b9da7c 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -10,7 +10,7 @@ "src/install-source.ts", "src/android-adb.ts", "src/android-snapshot-helper.ts", - "src/contracts.ts", + "src/kernel/contracts.ts", "src/selectors.ts", "src/finders.ts", "src/bin.ts", diff --git a/fallow-baselines/health.json b/fallow-baselines/health.json index e9f93d4d4..fa1f5e50b 100644 --- a/fallow-baselines/health.json +++ b/fallow-baselines/health.json @@ -133,7 +133,7 @@ "count": 1 } }, - "src/contracts.ts": { + "src/kernel/contracts.ts": { "crap_moderate": { "count": 1 } diff --git a/rslib.config.ts b/rslib.config.ts index 9abe2a5f5..e8daba84a 100644 --- a/rslib.config.ts +++ b/rslib.config.ts @@ -31,7 +31,7 @@ export default defineConfig({ 'install-source': 'src/install-source.ts', 'android-adb': 'src/android-adb.ts', 'android-snapshot-helper': 'src/android-snapshot-helper.ts', - contracts: 'src/contracts.ts', + contracts: 'src/kernel/contracts.ts', selectors: 'src/selectors.ts', finders: 'src/finders.ts', 'internal/bin': 'src/bin.ts', diff --git a/src/__tests__/client.test.ts b/src/__tests__/client.test.ts index 0bd732989..885604700 100644 --- a/src/__tests__/client.test.ts +++ b/src/__tests__/client.test.ts @@ -2,7 +2,7 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; import { createAgentDeviceClient, type AgentDeviceClientConfig } from '../client.ts'; import { runCommand } from '../commands/command-surface.ts'; -import type { DaemonRequest, DaemonResponse } from '../contracts.ts'; +import type { DaemonRequest, DaemonResponse } from '../kernel/contracts.ts'; import { AppError } from '../kernel/errors.ts'; function createTransport( diff --git a/src/__tests__/contracts-schema-public.test.ts b/src/__tests__/contracts-schema-public.test.ts index 12a165267..67f04ffdd 100644 --- a/src/__tests__/contracts-schema-public.test.ts +++ b/src/__tests__/contracts-schema-public.test.ts @@ -26,7 +26,7 @@ import { type AppErrorCode, type Rect, type SnapshotNode, -} from '../contracts.ts'; +} from '../kernel/contracts.ts'; const invalidArgsCode = 'INVALID_ARGS' satisfies AppErrorCode; const rect = { x: 1, y: 2, width: 3, height: 4 } satisfies Rect; diff --git a/src/backend.ts b/src/backend.ts index e0f895ddf..6e4af2d41 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -1,7 +1,7 @@ import type { AlertAction, AlertInfo } from './alert-contract.ts'; import type { AppsFilter } from './contracts/app-inventory.ts'; import type { Point, SnapshotNode, SnapshotOptions, SnapshotState } from './kernel/snapshot.ts'; -import type { NetworkIncludeMode } from './contracts.ts'; +import type { NetworkIncludeMode } from './kernel/contracts.ts'; import type { DeviceTarget, Platform, PlatformSelector } from './kernel/device.ts'; import type { BackMode } from './core/back-mode.ts'; import type { RepeatedInput } from './commands/command-input.ts'; diff --git a/src/batch-contract.ts b/src/batch-contract.ts index 62cf5c093..988e095f6 100644 --- a/src/batch-contract.ts +++ b/src/batch-contract.ts @@ -1,4 +1,4 @@ -import { daemonRuntimeSchema, type SessionRuntimeHints } from './contracts.ts'; +import { daemonRuntimeSchema, type SessionRuntimeHints } from './kernel/contracts.ts'; import { AppError } from './kernel/errors.ts'; import { isRecord } from './utils/parsing.ts'; diff --git a/src/cli.ts b/src/cli.ts index 7d3df3e41..44f1a0092 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -34,7 +34,7 @@ import { } from './remote-connection-state.ts'; import { resolveRemoteAuthForCli } from './cli/auth-session.ts'; import type { CliFlags, FlagKey } from './utils/cli-flags.ts'; -import type { SessionRuntimeHints } from './contracts.ts'; +import type { SessionRuntimeHints } from './kernel/contracts.ts'; type CliDeps = { sendToDaemon: typeof sendToDaemon; diff --git a/src/cli/batch-steps.ts b/src/cli/batch-steps.ts index 7955bfe17..67e269e69 100644 --- a/src/cli/batch-steps.ts +++ b/src/cli/batch-steps.ts @@ -1,5 +1,5 @@ import type { BatchStep } from '../client-types.ts'; -import { type SessionRuntimeHints } from '../contracts.ts'; +import { type SessionRuntimeHints } from '../kernel/contracts.ts'; import { parseBatchStepRuntime } from '../batch-contract.ts'; import { readInputFromCli } from '../commands/cli-grammar.ts'; import { isCommandName, type CommandName } from '../commands/command-metadata.ts'; diff --git a/src/cli/commands/__tests__/generic.test.ts b/src/cli/commands/__tests__/generic.test.ts index 3873e3009..fe9f3b46a 100644 --- a/src/cli/commands/__tests__/generic.test.ts +++ b/src/cli/commands/__tests__/generic.test.ts @@ -1,7 +1,7 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; import { createAgentDeviceClient } from '../../../client.ts'; -import type { DaemonResponse } from '../../../contracts.ts'; +import type { DaemonResponse } from '../../../kernel/contracts.ts'; import type { CliFlags } from '../../../utils/cli-flags.ts'; import type { ClientBackedCliCommandName } from '../../../command-catalog.ts'; import { runGenericClientBackedCommand } from '../generic.ts'; diff --git a/src/cli/commands/__tests__/screenshot.test.ts b/src/cli/commands/__tests__/screenshot.test.ts index 4062bf16a..a5e7cd007 100644 --- a/src/cli/commands/__tests__/screenshot.test.ts +++ b/src/cli/commands/__tests__/screenshot.test.ts @@ -1,7 +1,7 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; import { createAgentDeviceClient } from '../../../client.ts'; -import type { DaemonResponse } from '../../../contracts.ts'; +import type { DaemonResponse } from '../../../kernel/contracts.ts'; import type { CliFlags } from '../../../utils/cli-flags.ts'; import { screenshotCommand } from '../screenshot.ts'; diff --git a/src/cli/commands/agent-cdp.ts b/src/cli/commands/agent-cdp.ts index 2daad9c24..99d715658 100644 --- a/src/cli/commands/agent-cdp.ts +++ b/src/cli/commands/agent-cdp.ts @@ -1,7 +1,7 @@ import { runCmdStreaming } from '../../utils/exec.ts'; import { AppError } from '../../kernel/errors.ts'; import { isRemoteBridgeBackend } from './remote-bridge.ts'; -import type { SessionRuntimeHints } from '../../contracts.ts'; +import type { SessionRuntimeHints } from '../../kernel/contracts.ts'; import type { CliFlags } from '../../utils/cli-flags.ts'; const AGENT_CDP_VERSION = '1.6.0'; diff --git a/src/cli/commands/connection-runtime.ts b/src/cli/commands/connection-runtime.ts index 272df6fe5..4e3fc5994 100644 --- a/src/cli/commands/connection-runtime.ts +++ b/src/cli/commands/connection-runtime.ts @@ -17,7 +17,7 @@ import { import { profileToCliFlags } from '../../utils/remote-config.ts'; import type { BatchStep } from '../../client-types.ts'; import { AppError } from '../../kernel/errors.ts'; -import type { LeaseBackend, SessionRuntimeHints } from '../../contracts.ts'; +import type { LeaseBackend, SessionRuntimeHints } from '../../kernel/contracts.ts'; import type { CliFlags } from '../../utils/cli-flags.ts'; import type { AgentDeviceClient, Lease } from '../../client.ts'; import type { MetroPrepareKind } from '../../metro/client-metro.ts'; diff --git a/src/cli/commands/connection.ts b/src/cli/commands/connection.ts index 8dcdf94e4..b336bd3d8 100644 --- a/src/cli/commands/connection.ts +++ b/src/cli/commands/connection.ts @@ -24,7 +24,7 @@ import { stopReactDevtoolsCleanup, } from './connection-runtime.ts'; import { writeCommandOutput } from './shared.ts'; -import type { LeaseBackend } from '../../contracts.ts'; +import type { LeaseBackend } from '../../kernel/contracts.ts'; import type { CliFlags } from '../../utils/cli-flags.ts'; import type { ClientCommandHandler } from './router-types.ts'; diff --git a/src/cli/commands/generic.ts b/src/cli/commands/generic.ts index aa5dc3758..1ad700c5b 100644 --- a/src/cli/commands/generic.ts +++ b/src/cli/commands/generic.ts @@ -6,7 +6,7 @@ import type { CliOutput } from '../../commands/command-contract.ts'; import type { ReplaySuiteResult } from '../../daemon/types.ts'; import type { CliFlags } from '../../utils/cli-flags.ts'; import { readCommandMessage } from '../../utils/success-text.ts'; -import { isNonDefaultResponseLevel } from '../../contracts.ts'; +import { isNonDefaultResponseLevel } from '../../kernel/contracts.ts'; import { writeCommandOutput } from './shared.ts'; import type { ClientBackedCliCommandName } from '../../command-catalog.ts'; import type { ClientCommandParams } from './router-types.ts'; diff --git a/src/cli/commands/screenshot.ts b/src/cli/commands/screenshot.ts index 465dc612f..79fbcbe5d 100644 --- a/src/cli/commands/screenshot.ts +++ b/src/cli/commands/screenshot.ts @@ -1,6 +1,6 @@ import { formatScreenshotDiffText, formatSnapshotDiffText } from '../../utils/output.ts'; import { AppError } from '../../kernel/errors.ts'; -import { isNonDefaultResponseLevel } from '../../contracts.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'; diff --git a/src/client-types.ts b/src/client-types.ts index 4be45ea61..5fbca8fa0 100644 --- a/src/client-types.ts +++ b/src/client-types.ts @@ -11,7 +11,7 @@ import type { ResponseLevel, SessionIsolationMode, SessionRuntimeHints, -} from './contracts.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'; diff --git a/src/client.ts b/src/client.ts index 37c28a13a..7e3158dd6 100644 --- a/src/client.ts +++ b/src/client.ts @@ -47,7 +47,7 @@ import type { MetroPrepareOptions, } from './client-types.ts'; import type { CommandResult } from './core/command-descriptor/command-result.ts'; -import { isNonDefaultResponseLevel, type ResponseLevel } from './contracts.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'; diff --git a/src/commands/batch/metadata.ts b/src/commands/batch/metadata.ts index 54d050f9c..370128b7c 100644 --- a/src/commands/batch/metadata.ts +++ b/src/commands/batch/metadata.ts @@ -7,7 +7,7 @@ import { readBatchStepRecord, type BatchStepErrorFactory, } from '../../batch-contract.ts'; -import { type SessionRuntimeHints } from '../../contracts.ts'; +import { type SessionRuntimeHints } from '../../kernel/contracts.ts'; import { STRUCTURED_BATCH_COMMAND_NAMES, readStructuredBatchCommandName, diff --git a/src/commands/batch/public.test.ts b/src/commands/batch/public.test.ts index 8ead6f9fe..da8513690 100644 --- a/src/commands/batch/public.test.ts +++ b/src/commands/batch/public.test.ts @@ -8,7 +8,7 @@ import { runBatch, validateAndNormalizeBatchSteps, } from '../../batch.ts'; -import type { DaemonRequest } from '../../contracts.ts'; +import type { DaemonRequest } from '../../kernel/contracts.ts'; test('public batch entrypoint exports daemon-compatible orchestration helpers', async () => { const seenCommands: string[] = []; diff --git a/src/commands/management/install.ts b/src/commands/management/install.ts index 1b5c0aa8d..0c4c67cf9 100644 --- a/src/commands/management/install.ts +++ b/src/commands/management/install.ts @@ -1,5 +1,5 @@ import { INTERNAL_COMMANDS, PUBLIC_COMMANDS } from '../../command-catalog.ts'; -import type { DaemonInstallSource } from '../../contracts.ts'; +import type { DaemonInstallSource } from '../../kernel/contracts.ts'; import type { CliFlags } from '../../utils/cli-flags.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; import { AppError } from '../../kernel/errors.ts'; diff --git a/src/commands/observability/index.ts b/src/commands/observability/index.ts index a0124f2e6..0bab2977c 100644 --- a/src/commands/observability/index.ts +++ b/src/commands/observability/index.ts @@ -1,5 +1,5 @@ import type { LogsOptions, NetworkOptions } from '../../client-types.ts'; -import { NETWORK_INCLUDE_MODES, type NetworkIncludeMode } from '../../contracts.ts'; +import { NETWORK_INCLUDE_MODES, type NetworkIncludeMode } from '../../kernel/contracts.ts'; import { AppError } from '../../kernel/errors.ts'; import { parseStringMember } from '../../utils/string-enum.ts'; import type { CommandSchemaOverride } from '../../utils/cli-command-schema-types.ts'; diff --git a/src/commands/observability/output.ts b/src/commands/observability/output.ts index a6cdb6169..8001503c2 100644 --- a/src/commands/observability/output.ts +++ b/src/commands/observability/output.ts @@ -1,5 +1,5 @@ import type { BackendNetworkEntry } from '../../backend.ts'; -import type { NetworkIncludeMode } from '../../contracts.ts'; +import type { NetworkIncludeMode } from '../../kernel/contracts.ts'; import type { NetworkEntry } from '../../daemon/network-log.ts'; import type { CliOutput } from '../command-contract.ts'; import { resultOutput, type CliOutputFormatter } from '../output-common.ts'; diff --git a/src/core/batch.ts b/src/core/batch.ts index 0d8f5fc76..0a88ee9ba 100644 --- a/src/core/batch.ts +++ b/src/core/batch.ts @@ -1,4 +1,4 @@ -import { type DaemonRequest, type DaemonResponse } from '../contracts.ts'; +import { type DaemonRequest, type DaemonResponse } from '../kernel/contracts.ts'; import { AppError, asAppError } from '../kernel/errors.ts'; import { isRecord } from '../utils/parsing.ts'; import { diff --git a/src/core/lease-scope.ts b/src/core/lease-scope.ts index 690623b4a..81d6e3ebe 100644 --- a/src/core/lease-scope.ts +++ b/src/core/lease-scope.ts @@ -1,4 +1,4 @@ -import type { LeaseBackend } from '../contracts.ts'; +import type { LeaseBackend } from '../kernel/contracts.ts'; import { stripUndefined } from '../utils/parsing.ts'; const PROXY_LEASE_PROVIDER = 'proxy'; diff --git a/src/daemon-error.ts b/src/daemon-error.ts index 4565047a7..5d6c71a0e 100644 --- a/src/daemon-error.ts +++ b/src/daemon-error.ts @@ -1,5 +1,5 @@ import { AppError, toAppErrorCode } from './kernel/errors.ts'; -import type { DaemonError } from './contracts.ts'; +import type { DaemonError } from './kernel/contracts.ts'; export function throwDaemonError(error: DaemonError): never { throw new AppError(toAppErrorCode(error.code), error.message, { diff --git a/src/daemon/__tests__/request-router-cost.test.ts b/src/daemon/__tests__/request-router-cost.test.ts index 369e36873..b2fce0af0 100644 --- a/src/daemon/__tests__/request-router-cost.test.ts +++ b/src/daemon/__tests__/request-router-cost.test.ts @@ -19,7 +19,7 @@ import { createRequestHandler } from '../request-router.ts'; import type { DaemonRequest, SessionState } from '../types.ts'; import { LeaseRegistry } from '../lease-registry.ts'; import { makeSessionStore } from '../../__tests__/test-utils/store-factory.ts'; -import { daemonCommandRequestSchema } from '../../contracts.ts'; +import { daemonCommandRequestSchema } from '../../kernel/contracts.ts'; import { emitDiagnostic } from '../../utils/diagnostics.ts'; const mockDispatch = vi.mocked(dispatchCommand); diff --git a/src/daemon/__tests__/request-router-response-level.test.ts b/src/daemon/__tests__/request-router-response-level.test.ts index 827855000..a5de26780 100644 --- a/src/daemon/__tests__/request-router-response-level.test.ts +++ b/src/daemon/__tests__/request-router-response-level.test.ts @@ -35,7 +35,7 @@ import { createRequestHandler } from '../request-router.ts'; import type { DaemonRequest, SessionState } from '../types.ts'; import { LeaseRegistry } from '../lease-registry.ts'; import { makeSessionStore } from '../../__tests__/test-utils/store-factory.ts'; -import { daemonCommandRequestSchema } from '../../contracts.ts'; +import { daemonCommandRequestSchema } from '../../kernel/contracts.ts'; const mockDispatch = vi.mocked(dispatchCommand); diff --git a/src/daemon/config.ts b/src/daemon/config.ts index aba6f8e8c..dbf58eec9 100644 --- a/src/daemon/config.ts +++ b/src/daemon/config.ts @@ -9,7 +9,7 @@ import type { DaemonServerMode, DaemonTransportPreference, SessionIsolationMode, -} from '../contracts.ts'; +} from '../kernel/contracts.ts'; export type { DaemonServerMode, DaemonTransportPreference, SessionIsolationMode }; export type DaemonPaths = { diff --git a/src/daemon/handlers/session-observability.ts b/src/daemon/handlers/session-observability.ts index fd78b5b98..a7beac954 100644 --- a/src/daemon/handlers/session-observability.ts +++ b/src/daemon/handlers/session-observability.ts @@ -34,7 +34,7 @@ import { import { handleNativePerfCommand as handleAndroidNativePerfCommand } from './session-native-perf.ts'; import { errorResponse, requireCommandSupported, type DaemonFailureResponse } from './response.ts'; import { handleNativePerfCommand as handleAppleNativePerfCommand } from './session-perf-xctrace.ts'; -import { NETWORK_INCLUDE_MODES, type NetworkIncludeMode } from '../../contracts.ts'; +import { NETWORK_INCLUDE_MODES, type NetworkIncludeMode } from '../../kernel/contracts.ts'; import type { LogBackend } from '../network-log.ts'; import { LOG_ACTION_VALUES as LOG_ACTIONS, diff --git a/src/daemon/http-server.ts b/src/daemon/http-server.ts index 9c7045061..bb91bb32b 100644 --- a/src/daemon/http-server.ts +++ b/src/daemon/http-server.ts @@ -8,8 +8,8 @@ import type { JsonRpcId, JsonRpcRequestEnvelope, LeaseBackend, -} from '../contracts.ts'; -import { commandRpcParamsSchema } from '../contracts.ts'; +} from '../kernel/contracts.ts'; +import { commandRpcParamsSchema } from '../kernel/contracts.ts'; import type { DaemonInstallSource, DaemonInvokeFn, DaemonRequest } from './types.ts'; import { normalizeTenantId } from './config.ts'; import { diff --git a/src/daemon/lease-context.ts b/src/daemon/lease-context.ts index e5c5aac03..a75ce38e0 100644 --- a/src/daemon/lease-context.ts +++ b/src/daemon/lease-context.ts @@ -1,5 +1,5 @@ import type { DaemonRequest } from './types.ts'; -import type { LeaseBackend } from '../contracts.ts'; +import type { LeaseBackend } from '../kernel/contracts.ts'; import type { DeviceLease } from './lease-registry.ts'; import type { RunnerLogicalLeaseContext } from '../core/runner-lease-context.ts'; import { stripUndefined } from '../utils/parsing.ts'; diff --git a/src/daemon/lease-registry.ts b/src/daemon/lease-registry.ts index fbf6952ff..dc45fb232 100644 --- a/src/daemon/lease-registry.ts +++ b/src/daemon/lease-registry.ts @@ -1,5 +1,5 @@ import crypto from 'node:crypto'; -import type { LeaseBackend } from '../contracts.ts'; +import type { LeaseBackend } from '../kernel/contracts.ts'; import { AppError } from '../kernel/errors.ts'; import { normalizeTenantId } from './config.ts'; diff --git a/src/daemon/network-log.ts b/src/daemon/network-log.ts index f15421d26..9b9ba2297 100644 --- a/src/daemon/network-log.ts +++ b/src/daemon/network-log.ts @@ -18,7 +18,7 @@ const ANDROID_NEARBY_LINE_RADIUS = 5; const ANDROID_PACKET_SCAN_RADIUS = 12; const NETWORK_LOG_MEMORY_PATH = ''; -import type { NetworkIncludeMode } from '../contracts.ts'; +import type { NetworkIncludeMode } from '../kernel/contracts.ts'; export type { NetworkIncludeMode }; export type LogBackend = 'ios-simulator' | 'ios-device' | 'android' | 'macos'; diff --git a/src/daemon/request-router.ts b/src/daemon/request-router.ts index a3b07d282..66a4d2ac1 100644 --- a/src/daemon/request-router.ts +++ b/src/daemon/request-router.ts @@ -5,7 +5,7 @@ import { import { AppError, normalizeError, retriableForErrorCode } from '../kernel/errors.ts'; import { supportedPlatformsForCommand } from '../core/capabilities.ts'; import { timingSafeStringEqual } from '../utils/timing-safe-equal.ts'; -import type { DaemonError, ResponseCost } from '../contracts.ts'; +import type { DaemonError, ResponseCost } from '../kernel/contracts.ts'; import type { DaemonInvokeFn, DaemonRequest, DaemonResponse, DaemonResponseData } from './types.ts'; import { RESPONSE_VIEWS } from './response-views.ts'; import { SessionStore } from './session-store.ts'; diff --git a/src/daemon/response-views.ts b/src/daemon/response-views.ts index 65c8b3655..5203d553d 100644 --- a/src/daemon/response-views.ts +++ b/src/daemon/response-views.ts @@ -1,4 +1,4 @@ -import type { ResponseLevel } from '../contracts.ts'; +import type { ResponseLevel } from '../kernel/contracts.ts'; import type { ScreenshotOverlayRef, SnapshotNode } from '../kernel/snapshot.ts'; import type { DaemonResponseData } from './types.ts'; diff --git a/src/daemon/types.ts b/src/daemon/types.ts index 8ba4be955..19ac6e73d 100644 --- a/src/daemon/types.ts +++ b/src/daemon/types.ts @@ -8,8 +8,8 @@ import type { DaemonError, LeaseBackend, SessionRuntimeHints as PublicSessionRuntimeHints, -} from '../contracts.ts'; -export type { DaemonLockPolicy } from '../contracts.ts'; +} from '../kernel/contracts.ts'; +export type { DaemonLockPolicy } from '../kernel/contracts.ts'; import type { CommandFlags } from '../core/dispatch.ts'; import type { GestureReferenceFrame, ScrollDirection } from '../core/scroll-gesture.ts'; import type { LogBackend } from './network-log.ts'; diff --git a/src/index.ts b/src/index.ts index 24e81b392..ab4f7a194 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,7 @@ export type { } from './cli-test-reporters/types.ts'; export type { CommandResult } from './core/command-descriptor/command-result.ts'; -export type { ResponseLevel } from './contracts.ts'; +export type { ResponseLevel } from './kernel/contracts.ts'; export type { BootCommandResult, ShutdownCommandResult } from './contracts/device.ts'; export type { ViewportCommandResult } from './contracts/viewport.ts'; diff --git a/src/contracts.ts b/src/kernel/contracts.ts similarity index 97% rename from src/contracts.ts rename to src/kernel/contracts.ts index 147d5680d..8b949a071 100644 --- a/src/contracts.ts +++ b/src/kernel/contracts.ts @@ -1,14 +1,14 @@ -export type { AppErrorCode } from './kernel/errors.ts'; -export { defaultHintForCode, normalizeError } from './kernel/errors.ts'; +export type { AppErrorCode } from './errors.ts'; +export { defaultHintForCode, normalizeError } from './errors.ts'; export type { DebugSymbolsCrashFrame, DebugSymbolsCrashSummary, DebugSymbolsImage, DebugSymbolsOptions, DebugSymbolsResult, -} from './contracts/debug-symbols.ts'; -import type { PlatformSelector } from './kernel/device.ts'; -import { PLATFORM_SELECTORS } from './kernel/device.ts'; +} from '../contracts/debug-symbols.ts'; +import type { PlatformSelector } from './device.ts'; +import { PLATFORM_SELECTORS } from './device.ts'; export type SessionRuntimeHints = { platform?: 'ios' | 'android'; @@ -212,8 +212,8 @@ export type JsonRpcRequestEnvelope = { params?: TParams; }; -export { centerOfRect } from './kernel/snapshot.ts'; -export type { Rect, SnapshotNode } from './kernel/snapshot.ts'; +export { centerOfRect } from './snapshot.ts'; +export type { Rect, SnapshotNode } from './snapshot.ts'; type RuntimeSchema = { parse(input: unknown): T; diff --git a/src/mcp/command-tools.ts b/src/mcp/command-tools.ts index 1487b25ca..0f82cc24b 100644 --- a/src/mcp/command-tools.ts +++ b/src/mcp/command-tools.ts @@ -1,6 +1,6 @@ import type { AgentDeviceClient, AgentDeviceClientConfig } from '../client-types.ts'; import type { JsonSchema } from '../commands/command-contract.ts'; -import { RESPONSE_LEVELS, type ResponseLevel } from '../contracts.ts'; +import { RESPONSE_LEVELS, type ResponseLevel } from '../kernel/contracts.ts'; import { formatCliOutput } from '../commands/cli-output.ts'; import { isCommandName, diff --git a/src/mcp/router.ts b/src/mcp/router.ts index a3684e12f..0c0d20a02 100644 --- a/src/mcp/router.ts +++ b/src/mcp/router.ts @@ -1,6 +1,6 @@ import { listCommandTools, commandToolExecutor, type ToolResult } from './command-tools.ts'; import { readVersion } from '../utils/version.ts'; -import type { JsonRpcId, JsonRpcRequestEnvelope } from '../contracts.ts'; +import type { JsonRpcId, JsonRpcRequestEnvelope } from '../kernel/contracts.ts'; const MCP_SERVER_NAME = 'agent-device'; const SUPPORTED_PROTOCOL_VERSION = '2025-11-25'; diff --git a/src/mcp/server.ts b/src/mcp/server.ts index a2fa30427..09a7b0c15 100644 --- a/src/mcp/server.ts +++ b/src/mcp/server.ts @@ -1,5 +1,5 @@ import { handleMcpMessage, type JsonRpcMessage } from './router.ts'; -import { jsonRpcRequestSchema, type JsonRpcId } from '../contracts.ts'; +import { jsonRpcRequestSchema, type JsonRpcId } from '../kernel/contracts.ts'; type JsonRpcResponse = Awaited>>; type MessageSink = (payload: unknown) => void; diff --git a/src/metro/metro-types.ts b/src/metro/metro-types.ts index 2fcbe3ec8..0c75e3642 100644 --- a/src/metro/metro-types.ts +++ b/src/metro/metro-types.ts @@ -1,4 +1,4 @@ -import type { SessionRuntimeHints } from '../contracts.ts'; +import type { SessionRuntimeHints } from '../kernel/contracts.ts'; /** Re-export of {@link SessionRuntimeHints} under the Metro-specific alias used by public API consumers. */ export type MetroRuntimeHints = SessionRuntimeHints; diff --git a/src/metro/metro.ts b/src/metro/metro.ts index 511f65f60..1bdd3d93e 100644 --- a/src/metro/metro.ts +++ b/src/metro/metro.ts @@ -1,4 +1,4 @@ -import type { SessionRuntimeHints } from '../contracts.ts'; +import type { SessionRuntimeHints } from '../kernel/contracts.ts'; import { buildMetroRuntimeHints, prepareMetroRuntime, diff --git a/src/remote-config-schema.ts b/src/remote-config-schema.ts index 5840b73f2..b0362d6e9 100644 --- a/src/remote-config-schema.ts +++ b/src/remote-config-schema.ts @@ -4,7 +4,7 @@ import type { DaemonTransportPreference, LeaseBackend, SessionIsolationMode, -} from './contracts.ts'; +} from './kernel/contracts.ts'; import { PLATFORM_SELECTORS, type DeviceTarget, type PlatformSelector } from './kernel/device.ts'; import type { MetroPrepareKind } from './metro/client-metro.ts'; diff --git a/src/remote-connection-state.ts b/src/remote-connection-state.ts index 0e471ea85..01239dd64 100644 --- a/src/remote-connection-state.ts +++ b/src/remote-connection-state.ts @@ -5,7 +5,7 @@ import { resolveRemoteConfigPath, resolveRemoteConfigProfile } from './remote-co import { AppError } from './kernel/errors.ts'; import { emitDiagnostic } from './utils/diagnostics.ts'; import type { CliFlags } from './utils/cli-flags.ts'; -import type { LeaseBackend, SessionRuntimeHints } from './contracts.ts'; +import type { LeaseBackend, SessionRuntimeHints } from './kernel/contracts.ts'; import { leaseScopeFromOptions, leaseScopeToCommandFlags, diff --git a/src/utils/cli-flags.ts b/src/utils/cli-flags.ts index 6245ef41e..c8b7b1c27 100644 --- a/src/utils/cli-flags.ts +++ b/src/utils/cli-flags.ts @@ -14,7 +14,7 @@ import { type ResponseLevel, type SessionRuntimeHints, type SessionIsolationMode, -} from '../contracts.ts'; +} from '../kernel/contracts.ts'; import type { RemoteConfigMetroOptions } from '../remote-config-schema.ts'; import { SCREENSHOT_SPECIFIC_FLAG_DEFINITIONS, diff --git a/src/utils/install-source-config.ts b/src/utils/install-source-config.ts index 2299ddded..a76906276 100644 --- a/src/utils/install-source-config.ts +++ b/src/utils/install-source-config.ts @@ -1,4 +1,4 @@ -import type { DaemonInstallSource } from '../contracts.ts'; +import type { DaemonInstallSource } from '../kernel/contracts.ts'; import { AppError } from '../kernel/errors.ts'; export function parseGitHubActionsArtifactInstallSourceSpec( diff --git a/src/utils/runtime-transport.ts b/src/utils/runtime-transport.ts index 0b3c7f881..8202fc4b4 100644 --- a/src/utils/runtime-transport.ts +++ b/src/utils/runtime-transport.ts @@ -1,5 +1,5 @@ import { URL } from 'node:url'; -import type { SessionRuntimeHints } from '../contracts.ts'; +import type { SessionRuntimeHints } from '../kernel/contracts.ts'; import { AppError } from '../kernel/errors.ts'; export type ResolvedRuntimeTransport = {