import { type LogcatOptions } from "./logcat.js"; export { escapeAndroidInputText, splitArgs } from "./text-escape.js"; export { UiTreeCache } from "./ui-tree-cache.js"; export { ANDROID_KEYCODES, ANDROID_KEYCODES_FAST, resolveKeyCode } from "./keycodes.js"; export { EXEC_TIMEOUT_MS, EXEC_RAW_TIMEOUT_MS, execAdb, execAdbAsync, execAdbRaw, execAdbRawAsync, } from "./exec.js"; export interface Device { id: string; state: string; model?: string; } export declare class AdbClient { private deviceId?; private readonly uiTreeCache; constructor(deviceId?: string); private get deviceFlag(); /** * SECURITY: All adb invocations route through this argv-form path (execFileSync — no /bin/sh -c). * Shell metacharacters in `args` are passed as literal argv slots, not parsed by the host shell. * This structurally prevents host-side OS Command Injection (CWE-78) — see issue #40. */ private execArgs; private execArgsRaw; private execArgsAsync; /** * Execute ADB command and return stdout as string. * SECURITY: Command is whitespace-split into argv tokens — shell metachars in the input * are NOT interpreted (no /bin/sh -c). For commands needing spaces inside an argument * (e.g. text input with spaces), use the new argv-form via internal helpers. */ exec(command: string, deviceIdOverride?: string): string; /** * Execute ADB command and return raw bytes (for screenshots) */ execRaw(command: string, deviceIdOverride?: string): Buffer; /** * Execute ADB command async (non-blocking) */ execAsync(command: string, deviceIdOverride?: string): Promise; /** * Execute ADB command async and return raw bytes (for screenshots) */ execRawAsync(command: string, deviceIdOverride?: string): Promise; /** * Get list of connected devices */ getDevices(): Device[]; /** * Set active device */ setDevice(deviceId: string): void; /** * Get currently configured device ID */ getDeviceId(): string | undefined; /** * Take screenshot and return raw PNG buffer */ screenshotRaw(): Buffer; /** * Take screenshot async (non-blocking) */ screenshotRawAsync(): Promise; /** * Take screenshot and return as base64 PNG (legacy) */ screenshot(): string; /** * Tap at coordinates */ tap(x: number, y: number): void; /** * Double tap at coordinates. * Device-side composition via single sh -c argv slot — host shell never parses the metachars. * Inputs are validated numerics; user-controlled strings never reach this code path. */ doubleTap(x: number, y: number, intervalMs?: number): void; /** * Select all text in focused input */ selectAll(): void; /** * Copy to clipboard */ copyToClipboard(): void; /** * Paste from clipboard */ pasteFromClipboard(): void; /** * Get clipboard text */ getClipboardText(): string; /** * Long press at coordinates */ longPress(x: number, y: number, durationMs?: number): void; /** * Swipe gesture */ swipe(x1: number, y1: number, x2: number, y2: number, durationMs?: number): void; /** * Swipe in direction (uses screen center) */ swipeDirection(direction: "up" | "down" | "left" | "right", distance?: number): void; /** * Input text. * The full `shell input text ""` string passes as a SINGLE argv slot to adb, * so the host shell never parses it (host-side CWE-78 closed). adb ships the string * verbatim to the device shell, which parses the double-quoted form safely thanks to * the per-character escape below. */ inputText(text: string): void; /** * Press key by name or keycode */ pressKey(key: string): void; /** * Invalidate the turbo UI tree cache. * Call after actions that mutate the screen (tap, swipe, input, etc.) * so the next getUiHierarchy call fetches fresh data. */ invalidateUiTreeCache(): void; /** * Get UI hierarchy XML (sync — blocks event loop) */ getUiHierarchy(turbo?: boolean): string; /** * Get UI hierarchy XML async (non-blocking) */ getUiHierarchyAsync(turbo?: boolean): Promise; /** * Execute an action + uiautomator dump in a single adb shell invocation (turbo only). * Reduces two process spawns to one, saving ~150-300ms per step. * Returns { actionOutput: string; uiXml: string }. * * SECURITY: Device-side composition via single sh -c argv slot — host shell never parses * the metachars. `actionCommand` originates from internal turbo helpers (tap/swipe/press), * which validate numeric inputs; user-controlled strings do not reach this path. */ execWithUiDump(actionCommand: string, deviceIdOverride?: string): Promise<{ actionOutput: string; uiXml: string; }>; /** * Tap at coordinates (async, non-blocking — for turbo mode). */ tapAsync(x: number, y: number, deviceIdOverride?: string): Promise; /** * Swipe gesture (async, non-blocking — for turbo mode). */ swipeAsync(x1: number, y1: number, x2: number, y2: number, durationMs?: number, deviceIdOverride?: string): Promise; /** * Press key (async, non-blocking — for turbo mode). */ pressKeyAsync(key: string, deviceIdOverride?: string): Promise; /** * Input text (async, non-blocking — for turbo mode). */ inputTextAsync(text: string, deviceIdOverride?: string): Promise; /** * Launch app by package name */ launchApp(packageName: string): string; /** * Stop app */ stopApp(packageName: string): void; /** * Clear app data */ clearAppData(packageName: string): void; /** * Grant runtime permission to app */ grantPermission(packageName: string, permission: string): void; /** * Revoke runtime permission from app */ revokePermission(packageName: string, permission: string): void; /** * Reset all permissions for app (clears app data) */ resetPermissions(packageName: string): void; /** * Install APK */ installApk(apkPath: string): string; /** * Uninstall app */ uninstallApp(packageName: string): string; /** * Get current activity */ getCurrentActivity(): string; /** * Get screen size */ getScreenSize(): { width: number; height: number; }; /** * Wait for device */ waitForDevice(): void; /** * Execute shell command */ shell(command: string): string; /** * Get device logs (logcat) * @param options - filter options */ getLogs(options?: LogcatOptions): string; /** * Clear logcat buffer */ clearLogs(): void; /** * Get network stats (first 100 lines). * Node-side filter replaces device-side `| head -100` so we can use argv-form (no shell pipe). */ getNetworkStats(): string; /** * Get battery info */ getBatteryInfo(): string; /** * Get memory info */ getMemoryInfo(packageName?: string): string; /** * Get CPU info (first 20 lines). */ getCpuInfo(): string; } //# sourceMappingURL=client.d.ts.map