@@ -12,6 +12,7 @@ import {
1212import * as NodeCrypto from "@effect/platform-node/NodeCrypto" ;
1313import * as NodeServices from "@effect/platform-node/NodeServices" ;
1414import * as NetService from "@t3tools/shared/Net" ;
15+ import { SshCommandError } from "@t3tools/ssh/errors" ;
1516import * as Effect from "effect/Effect" ;
1617import * as Exit from "effect/Exit" ;
1718import * as Deferred from "effect/Deferred" ;
@@ -694,6 +695,84 @@ it.effect("host retry exposes actionable failure without internal IDs or diagnos
694695 } ) . pipe ( Effect . scoped ) ,
695696) ;
696697
698+ it . effect . each ( [
699+ {
700+ name : "missing Node among private diagnostic lines" ,
701+ exitCode : 1 ,
702+ stderr :
703+ "private diagnostics\r\nNode is missing from the non-interactive SSH PATH\r\nprivate diagnostics" ,
704+ expected :
705+ "Connected over SSH, but Node is not on this host's PATH for non-interactive SSH commands." ,
706+ } ,
707+ {
708+ name : "another remote command failure" ,
709+ exitCode : 2 ,
710+ stderr : "private diagnostics" ,
711+ expected : "Connected over SSH, but the device host check failed (exit code 2)." ,
712+ } ,
713+ {
714+ name : "an unrecognized exit-one diagnostic" ,
715+ exitCode : 1 ,
716+ stderr : "private diagnostics: Node is missing from the non-interactive SSH PATH" ,
717+ expected : "Connected over SSH, but the device host check failed (exit code 1)." ,
718+ } ,
719+ {
720+ name : "a connection failure" ,
721+ exitCode : 255 ,
722+ stderr : "Node is missing from the non-interactive SSH PATH" ,
723+ expected : "Could not connect to this host over SSH." ,
724+ } ,
725+ {
726+ name : "a command that could not start" ,
727+ exitCode : null ,
728+ stderr : "private diagnostics" ,
729+ expected : "Could not connect to this host over SSH." ,
730+ } ,
731+ {
732+ name : "an untyped offline cause" ,
733+ exitCode : undefined ,
734+ stderr : "private diagnostics" ,
735+ expected : "Could not connect to this host over SSH." ,
736+ } ,
737+ ] ) ( "reports $name through manual and agent host readiness" , ( { exitCode, stderr, expected } ) =>
738+ Effect . gen ( function * ( ) {
739+ const failure = new DeviceHost . DeviceHostError ( {
740+ hostId : LOCAL_DEVICE_HOST_ID ,
741+ step : "probe" ,
742+ cause :
743+ exitCode === undefined
744+ ? "offline"
745+ : new SshCommandError ( {
746+ command : [ "ssh" , "private arguments" ] ,
747+ exitCode,
748+ stderr,
749+ stdout : "private output" ,
750+ message : "private diagnostics" ,
751+ } ) ,
752+ } ) ;
753+ const { service, settings } = yield * fixture ( Effect . void , undefined , false , failure ) ;
754+ yield * Ref . update ( settings , ( current ) => ( {
755+ ...current ,
756+ enableDeviceSupport : true ,
757+ enableAgentDeviceAccess : true ,
758+ } ) ) ;
759+ for ( const readiness of [ service . readiness ( ) , service . agentReadinessIfSupported ( ) ] ) {
760+ const error = yield * readiness . pipe ( Effect . flip ) ;
761+ expect ( error ) . toMatchObject ( { reason : expected , cause : failure } ) ;
762+ expect ( ( yield * service . state ) . hostStatuses [ LOCAL_DEVICE_HOST_ID ] ) . toEqual ( {
763+ status : "failed" ,
764+ detail : expected ,
765+ } ) ;
766+ }
767+ for ( const state of [ yield * service . list , yield * service . retryHost ( LOCAL_DEVICE_HOST_ID ) ] ) {
768+ expect ( state . hostStatuses [ LOCAL_DEVICE_HOST_ID ] ) . toEqual ( {
769+ status : "failed" ,
770+ detail : expected ,
771+ } ) ;
772+ }
773+ } ) . pipe ( Effect . scoped ) ,
774+ ) ;
775+
697776it . effect ( "version discovery does not grant consent or start device tools" , ( ) =>
698777 Effect . gen ( function * ( ) {
699778 const { service, starts, agentStarts, requests } = yield * fixture ( ) ;
0 commit comments