@@ -41,6 +41,10 @@ import {
4141 stopIosSimulatorRecordingProcess ,
4242} from './record-trace-ios-simulator.ts' ;
4343import { resolveImplicitSessionScope , resolvePublicSessionName } from '../session-routing.ts' ;
44+ import {
45+ startHarmonyRecording ,
46+ stopHarmonyRecording ,
47+ } from '../../platforms/harmonyos/recording.ts' ;
4448
4549const IOS_DEVICE_RECORD_MIN_FPS = 1 ;
4650const IOS_DEVICE_RECORD_MAX_FPS = 120 ;
@@ -175,6 +179,35 @@ async function startIosSimulatorRecording(params: {
175179 } ;
176180}
177181
182+ // --- HarmonyOS start helper ---
183+
184+ async function startHarmonyOsRecording ( params : {
185+ device : SessionState [ 'device' ] ;
186+ recordingBase : RecordingBase ;
187+ } ) : Promise < DaemonResponse | NonNullable < SessionState [ 'recording' ] > > {
188+ const { device, recordingBase } = params ;
189+ const remotePath = `/data/local/tmp/agent-device-recording-${ Date . now ( ) } .mp4` ;
190+
191+ let startResult : { remotePid : string } ;
192+ try {
193+ startResult = await startHarmonyRecording ( device , remotePath ) ;
194+ } catch ( error ) {
195+ return errorResponse (
196+ 'COMMAND_FAILED' ,
197+ error instanceof Error ? error . message : String ( error ) ,
198+ ) ;
199+ }
200+
201+ const recording : Extract < NonNullable < SessionState [ 'recording' ] > , { platform : 'harmonyos' } > = {
202+ platform : 'harmonyos' ,
203+ remotePath,
204+ remotePid : startResult . remotePid ,
205+ ...recordingBase ,
206+ startedAt : Date . now ( ) ,
207+ } ;
208+ return recording ;
209+ }
210+
178211// --- Start recording orchestrator ---
179212
180213// fallow-ignore-next-line complexity
@@ -276,6 +309,8 @@ async function startRecording(params: {
276309 recordingBase,
277310 resolvedOut,
278311 } ) ;
312+ } else if ( device . platform === 'harmonyos' ) {
313+ recording = await startHarmonyOsRecording ( { device, recordingBase } ) ;
279314 } else {
280315 recording = await startAndroidRecording ( { device, recordingBase } ) ;
281316 }
@@ -427,6 +462,28 @@ function removeInvalidRecordingOutput(outPath: string): void {
427462 }
428463}
429464
465+ async function stopHarmonyOsRecording ( params : {
466+ device : SessionState [ 'device' ] ;
467+ recording : Extract < NonNullable < SessionState [ 'recording' ] > , { platform : 'harmonyos' } > ;
468+ stopRequestedAt : number ;
469+ } ) : Promise < DaemonResponse | null > {
470+ const { device, recording, stopRequestedAt } = params ;
471+ try {
472+ await stopHarmonyRecording ( {
473+ device,
474+ remotePid : recording . remotePid ,
475+ remotePath : recording . remotePath ,
476+ localPath : recording . outPath ,
477+ } ) ;
478+ } catch ( error ) {
479+ const message = error instanceof Error ? error . message : String ( error ) ;
480+ const failure = buildRecordStopFailure ( message , recording , stopRequestedAt ) ;
481+ removeInvalidRecordingOutput ( recording . outPath ) ;
482+ return errorResponse ( 'COMMAND_FAILED' , failure . message ) ;
483+ }
484+ return null ;
485+ }
486+
430487async function stopRecording ( params : {
431488 req : DaemonRequest ;
432489 activeSession : SessionState ;
@@ -450,7 +507,9 @@ async function stopRecording(params: {
450507 ? await stopIosDeviceRecording ( { req, activeSession, device, logPath, deps, recording } )
451508 : recording . platform === 'macos-runner'
452509 ? await stopMacOsRecording ( { req, activeSession, device, logPath, deps, recording } )
453- : await stopNonRunnerRecording ( { deps, device, recording, stopRequestedAt } ) ;
510+ : recording . platform === 'harmonyos'
511+ ? await stopHarmonyOsRecording ( { device, recording, stopRequestedAt } )
512+ : await stopNonRunnerRecording ( { deps, device, recording, stopRequestedAt } ) ;
454513 if ( stopError ) {
455514 return stopError ;
456515 }
0 commit comments