@@ -36,6 +36,17 @@ export type AdminBootCommandResult = {
3636 target ?: BackendDeviceTarget ;
3737} & BackendResultEnvelope ;
3838
39+ export type AdminShutdownCommandOptions = CommandContext & {
40+ target ?: BackendDeviceTarget ;
41+ } ;
42+
43+ export type AdminShutdownCommandResult = {
44+ kind : 'deviceShutdown' ;
45+ target ?: BackendDeviceTarget ;
46+ backendResult ?: Record < string , unknown > ;
47+ message ?: string ;
48+ } ;
49+
3950export type AdminInstallCommandOptions = CommandContext & {
4051 app : string ;
4152 source : BackendInstallSource ;
@@ -95,6 +106,27 @@ export const bootCommand: RuntimeCommand<
95106 } ;
96107} ;
97108
109+ export const shutdownCommand : RuntimeCommand <
110+ AdminShutdownCommandOptions | undefined ,
111+ AdminShutdownCommandResult
112+ > = async ( runtime , options = { } ) : Promise < AdminShutdownCommandResult > => {
113+ if ( ! runtime . backend . shutdownDevice ) {
114+ throw new AppError ( 'UNSUPPORTED_OPERATION' , 'admin.shutdown is not supported by this backend' ) ;
115+ }
116+ const target = normalizeDeviceTarget ( options . target ) ;
117+ const backendResult = await runtime . backend . shutdownDevice (
118+ toBackendContext ( runtime , options ) ,
119+ target ,
120+ ) ;
121+ const formattedBackendResult = toBackendResult ( backendResult ) ;
122+ return {
123+ kind : 'deviceShutdown' ,
124+ ...( target ? { target } : { } ) ,
125+ ...( formattedBackendResult ? { backendResult : formattedBackendResult } : { } ) ,
126+ ...successText ( 'Shutdown device' ) ,
127+ } ;
128+ } ;
129+
98130export const installCommand : RuntimeCommand <
99131 AdminInstallCommandOptions ,
100132 AdminInstallCommandResult
0 commit comments