@@ -217,7 +217,7 @@ async function startGatewayStabilityRpcServer(
217217 ws ,
218218 frame . id ,
219219 buildMinimalGatewayHelloOkPayload ( {
220- methods : [ "diagnostics.stability" ] ,
220+ methods : [ "diagnostics.stability" , "status" ] ,
221221 auth : {
222222 role : "operator" ,
223223 scopes : [ "operator.admin" ] ,
@@ -233,6 +233,13 @@ async function startGatewayStabilityRpcServer(
233233 calls . push ( frame . method ) ;
234234 if ( frame . method === "diagnostics.stability" ) {
235235 sendMinimalGatewayResponse ( ws , frame . id , EMPTY_STABILITY_SNAPSHOT ) ;
236+ return ;
237+ }
238+ if ( frame . method === "status" ) {
239+ sendMinimalGatewayResponse ( ws , frame . id , {
240+ runtimeVersion : "2026.8.17-test" ,
241+ status : "ok" ,
242+ } ) ;
236243 }
237244 } ) ;
238245 } ) ;
@@ -615,6 +622,71 @@ describe("gateway-backed CLI process exit", () => {
615622 expect ( await snapshotSharedStateArtifacts ( stateDir ) ) . toEqual ( before ) ;
616623 } , 30_000 ) ;
617624
625+ it . each ( [
626+ { label : "absent" , seeded : false } ,
627+ { label : "seeded" , seeded : true } ,
628+ ] ) (
629+ "requires a reachable status RPC without changing $label shared state" ,
630+ async ( { label, seeded } ) => {
631+ const root = tempDirs . make ( `openclaw-gateway-status-${ label } -` ) ;
632+ const stateDir = path . join ( root , "state" ) ;
633+ const configPath = path . join ( stateDir , "openclaw.json" ) ;
634+ const token = "configured-token" ;
635+ const gateway = await startGatewayStabilityRpcServer ( token , "issued-device-token" ) ;
636+ const stateEnv = {
637+ ...process . env ,
638+ HOME : root ,
639+ OPENCLAW_HOME : root ,
640+ OPENCLAW_STATE_DIR : stateDir ,
641+ } ;
642+ await fs . mkdir ( stateDir , { recursive : true } ) ;
643+ await fs . writeFile (
644+ configPath ,
645+ JSON . stringify ( { gateway : { mode : "remote" , remote : { url : gateway . url , token } } } ) ,
646+ ) ;
647+ if ( seeded ) {
648+ const identity = loadOrCreateDeviceIdentity ( { env : stateEnv } ) ;
649+ storeOriginDeviceToken ( {
650+ gatewayScope : gatewayOriginScope ( gateway . url ) ,
651+ deviceId : identity . deviceId ,
652+ role : "operator" ,
653+ token,
654+ scopes : [ "operator.admin" ] ,
655+ env : stateEnv ,
656+ } ) ;
657+ closeOpenClawStateDatabaseForTest ( ) ;
658+ }
659+ const before = await snapshotSharedStateArtifacts ( stateDir ) ;
660+ expect ( Object . keys ( before ) . includes ( "openclaw.sqlite" ) ) . toBe ( seeded ) ;
661+
662+ const result = await runIsolatedGatewayCli ( {
663+ args : [
664+ "gateway" ,
665+ "status" ,
666+ "--url" ,
667+ gateway . url ,
668+ "--token" ,
669+ token ,
670+ "--require-rpc" ,
671+ "--json" ,
672+ "--timeout" ,
673+ "2000" ,
674+ ] ,
675+ root,
676+ stateDir,
677+ configPath,
678+ } ) ;
679+
680+ expect ( result , result . stderr ) . toMatchObject ( { code : 0 , signal : null , stderr : "" } ) ;
681+ expect ( JSON . parse ( result . stdout ) ) . toMatchObject ( {
682+ rpc : { ok : true , kind : "read" } ,
683+ } ) ;
684+ expect ( gateway . calls ) . toEqual ( [ "status" ] ) ;
685+ expect ( await snapshotSharedStateArtifacts ( stateDir ) ) . toEqual ( before ) ;
686+ } ,
687+ 30_000 ,
688+ ) ;
689+
618690 it . each ( [
619691 { label : "absent" , seeded : false } ,
620692 { label : "seeded" , seeded : true } ,
0 commit comments