import { AbstractInterface } from '@midscene/core/device'; import type { ActionParam } from '@midscene/core'; import type { ActionReturn } from '@midscene/core'; import { Agent } from '@midscene/core/agent'; import { AgentBehaviorInitArgs } from '@midscene/shared/agent-tools/agent-behavior-init-args'; import { AgentOpt } from '@midscene/core/agent'; import { AgentTestRunnerNodeDefinition } from '@midscene/core/agent'; import { AgentTestRunnerNodeDefinition as AgentTestRunnerNodeDefinition_2 } from '@midscene/core/agent/test'; import { BaseMidsceneTools } from '@midscene/shared/agent-tools/base-tools'; import { DeviceAction } from '@midscene/core'; import type { ElementInfo } from '@midscene/shared/extractor'; import { HarmonyDeviceInputOpt as HarmonyDeviceInputOpt_2 } from '@midscene/core/device'; import { HarmonyDeviceOpt as HarmonyDeviceOpt_2 } from '@midscene/core/device'; import { InitArgSpec } from '@midscene/shared/agent-tools/base-tools'; import { InterfaceType } from '@midscene/core'; import { MobileInputPrimitives } from '@midscene/core/device'; import { overrideAIConfig } from '@midscene/shared/env'; import { PlaygroundPlatformDescriptor } from '@midscene/playground'; import { Point } from '@midscene/core'; import { Size } from '@midscene/core'; import type { ToolDefinition } from '@midscene/shared/agent-tools/types'; import { z } from 'zod/v4'; declare type ActionArgs = [ActionParam] extends [undefined] ? [] : [ActionParam]; export declare function agentFromHdcDevice(deviceId?: string, opts?: HarmonyAgentOpt & HarmonyDeviceOpt): Promise; declare type DeviceActionHarmonyBackButton = DeviceAction; declare type DeviceActionHarmonyHomeButton = DeviceAction; declare type DeviceActionHarmonyRecentAppsButton = DeviceAction; export declare function getConnectedDevices(hdcPath?: string, options?: HarmonyDeviceDiscoveryOptions): Promise; export declare class HarmonyAgent extends Agent { static getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[]; back: WrappedAction; home: WrappedAction; recentApps: WrappedAction; constructor(device: HarmonyDevice, opts?: HarmonyAgentOpt); launch(uri: string): Promise; terminate(uri: string): Promise; runHdcShell(command: string): Promise; private createActionWrapper; } export declare type HarmonyAgentOpt = AgentOpt & { /** * Custom mapping of app names to bundle names or explicit bundle/ability * targets. Bundle-only targets use bundle metadata to resolve their declared * launch ability. User-provided mappings take precedence over defaults. */ appNameMapping?: Record; }; export declare const harmonyAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition_2[]; export declare class HarmonyDevice implements AbstractInterface { private deviceId; private hdc; private connecting; private destroyed; private descriptionText; private customActions?; private cachedScreenSize; private appNameMapping; private lastTapPosition; interfaceType: InterfaceType; uri: string | undefined; options?: HarmonyDeviceOpt; readonly inputPrimitives: MobileInputPrimitives; actionSpace(): DeviceAction[]; private performActionScroll; constructor(deviceId: string, options?: HarmonyDeviceOpt); describe(): string; connect(): Promise; getHdc(): Promise; /** * Set app-name aliases used by launch and terminate. * Keys are normalized here so callers do not need to know the internal * comparison format. */ setAppNameMapping(mapping: Record): void; private resolveMappedAppTarget; private resolveBundleNameForTerminate; launch(uri: string): Promise; /** * Terminate (force-stop) a HarmonyOS app by bundle name. * Supports app name resolution via setAppNameMapping. * If uri contains "/" (e.g. com.example.app/MainAbility), only the bundle part is used. */ terminate(uri: string): Promise; getScreenSize(): Promise<{ width: number; height: number; }>; size(): Promise; private remoteScreenshotPath; private localScreenshotPath; screenshotBase64(): Promise; private tapPoint; private doubleTapPoint; private longPressPoint; private typeText; clearInput(element?: ElementInfo): Promise; private pressKey; scroll(deltaX: number, deltaY: number, speed?: number): Promise; private scrollInDirection; scrollDown(distance?: number, startPoint?: Point): Promise; scrollUp(distance?: number, startPoint?: Point): Promise; scrollLeft(distance?: number, startPoint?: Point): Promise; scrollRight(distance?: number, startPoint?: Point): Promise; private scrollUntilEdge; scrollUntilTop(startPoint?: Point): Promise; scrollUntilBottom(startPoint?: Point): Promise; scrollUntilLeft(startPoint?: Point): Promise; scrollUntilRight(startPoint?: Point): Promise; back(): Promise; home(): Promise; recentApps(): Promise; hideKeyboard(options?: HarmonyDeviceInputOpt): Promise; /** * Get the current device-local time as a formatted string. * This avoids formatting a device timestamp in the host machine's timezone. */ getDeviceLocalTimeString(format?: string): Promise; destroy(): Promise; } declare interface HarmonyDeviceDiscoveryOptions { timeout?: number; } declare interface HarmonyDeviceInfo { deviceId: string; } declare type HarmonyDeviceInputOpt = HarmonyDeviceInputOpt_2 & { keyboardDismissStrategy?: KeyboardDismissStrategy; }; declare type HarmonyDeviceOpt = HarmonyDeviceOpt_2 & HarmonyDeviceInputOpt; declare type HarmonyInitArgs = AgentBehaviorInitArgs & { deviceId?: string; }; export declare class HarmonyMidsceneTools extends BaseMidsceneTools { private lastInitArgsSignature?; protected getCliReportSessionName(): string; protected readonly initArgSpec: InitArgSpec; protected createTemporaryDevice(): HarmonyDevice; protected ensureAgent(initArgs?: HarmonyInitArgs): Promise; protected preparePlatformTools(): ToolDefinition[]; } declare interface HarmonyPlatformOptions { deferConnection?: boolean; deviceId?: string; staticDir?: string; getAgentOptions?: () => HarmonyAgentOpt; } export declare const harmonyPlaygroundPlatform: PlaygroundPlatformDescriptor; declare class HdcClient { private hdcPath; private deviceId; private timeout; private execMutex; private launchAbilityCache; constructor(options: HdcOptions); private buildArgs; exec(...args: string[]): Promise; shell(command: string): Promise; private assertUiInputSucceeded; private runUiInput; private buildPointerMovementArgs; fileSend(localPath: string, remotePath: string): Promise; fileRecv(remotePath: string, localPath: string): Promise; screenshot(remotePath: string): Promise; click(x: number, y: number): Promise; doubleClick(x: number, y: number): Promise; longClick(x: number, y: number): Promise; swipe(fromX: number, fromY: number, toX: number, toY: number, speed?: number): Promise; fling(fromX: number, fromY: number, toX: number, toY: number, speed?: number): Promise; drag(fromX: number, fromY: number, toX: number, toY: number, speed?: number): Promise; inputText(x: number, y: number, text: string): Promise; keyEvent(...keys: string[]): Promise; /** Select all text in the focused field with Ctrl+A, then delete it. */ clearTextField(): Promise; startAbility(bundleName: string, abilityName: string, moduleName?: string): Promise; private queryLaunchAbility; /** * Launch an app by bundle name using its system-declared entry ability. * Successful resolutions are cached for this HDC connection. If a cached * target becomes stale, it is queried again and retried only when it changed. */ launchBundle(bundleName: string): Promise; forceStop(bundleName: string): Promise; getScreenInfo(): Promise<{ width: number; height: number; }>; listTargets(): Promise; } declare interface HdcOptions { hdcPath?: string; deviceId?: string; timeout?: number; } declare type KeyboardDismissStrategy = 'esc-first' | 'back-first'; export declare const launchInputSchema: z.ZodObject<{ uri: z.ZodString; }, z.core.$strict>; export declare type LaunchNodeInput = z.infer; export { overrideAIConfig } export declare const runHdcShellInputSchema: z.ZodObject<{ command: z.ZodString; }, z.core.$strict>; export declare type RunHdcShellNodeInput = z.infer; export declare const terminateInputSchema: z.ZodObject<{ uri: z.ZodString; }, z.core.$strict>; export declare type TerminateNodeInput = z.infer; declare type WrappedAction = (...args: ActionArgs) => Promise>; export { }