( runtime: AgentDeviceRuntime, options: PressCommandOptions, action: 'click' | 'press', )
| 152 | }; |
| 153 | |
| 154 | async function tapCommand( |
| 155 | runtime: AgentDeviceRuntime, |
| 156 | options: PressCommandOptions, |
| 157 | action: 'click' | 'press', |
| 158 | ): Promise<PressCommandResult> { |
| 159 | const nativeRefTap = await maybeTapRefTarget(runtime, options, action); |
| 160 | if (nativeRefTap) return nativeRefTap; |
| 161 | |
| 162 | const resolved = await resolveInteractionTarget(runtime, options, { |
| 163 | action, |
| 164 | requireInteractive: true, |
| 165 | promoteToHittableAncestor: true, |
| 166 | }); |
| 167 | if (!runtime.backend.tap) { |
| 168 | throw new AppError('UNSUPPORTED_OPERATION', 'tap is not supported by this backend'); |
| 169 | } |
| 170 | const point = requireResolvedPoint(resolved); |
| 171 | const backendResult = await runtime.backend.tap(toBackendContext(runtime, options), point, { |
| 172 | button: options.button, |
| 173 | count: options.count, |
| 174 | intervalMs: options.intervalMs, |
| 175 | holdMs: options.holdMs, |
| 176 | jitterPx: options.jitterPx, |
| 177 | doubleTap: options.doubleTap, |
| 178 | }); |
| 179 | const formattedBackendResult = toBackendResult(backendResult); |
| 180 | return { |
| 181 | ...resolved, |
| 182 | ...(formattedBackendResult ? { backendResult: formattedBackendResult } : {}), |
| 183 | }; |
| 184 | } |
| 185 | |
| 186 | function requireResolvedPoint(result: { point?: Point }): Point { |
| 187 | if (!result.point) { |
no test coverage detected
searching dependent graphs…