@@ -171,6 +171,40 @@ describe("AgentDevice startup", () => {
171171 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
172172 ) ;
173173
174+ it . effect ( "uses a registered daemon when reading startup command output fails" , ( ) =>
175+ Effect . gen ( function * ( ) {
176+ const fs = yield * FileSystem . FileSystem ;
177+ const cause = new ProcessRunner . ProcessReadError ( {
178+ command : process . execPath ,
179+ argumentCount : 3 ,
180+ stream : "stdout" ,
181+ cause : new Error ( "output read failed after registration" ) ,
182+ } ) ;
183+ let attempts = 0 ;
184+ const { host } = yield * agentFixture ( ( stateDir ) =>
185+ Effect . gen ( function * ( ) {
186+ attempts ++ ;
187+ yield * fs
188+ . writeFileString (
189+ `${ stateDir } /daemon.json` ,
190+ JSON . stringify ( { httpPort : 12345 , token : "test-token" } ) ,
191+ )
192+ . pipe ( Effect . orDie ) ;
193+ return yield * cause ;
194+ } ) ,
195+ ) ;
196+ const ready = yield * host . ensureAgentReady ( ( ) => Effect . void ) ;
197+ expect ( ready . agentDevice ) . toMatchObject ( {
198+ baseUrl : "http://127.0.0.1:12345" ,
199+ token : "test-token" ,
200+ } ) ;
201+ expect ( ( yield * host . ensureAgentReady ( ( ) => Effect . void ) ) . agentDevice ) . toEqual (
202+ ready . agentDevice ,
203+ ) ;
204+ expect ( attempts ) . toBe ( 1 ) ;
205+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
206+ ) ;
207+
174208 it . effect ( "allows retry and uses a registered daemon even when discovery exits nonzero" , ( ) =>
175209 Effect . gen ( function * ( ) {
176210 const fs = yield * FileSystem . FileSystem ;
0 commit comments