@@ -2724,46 +2724,48 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
27242724 } ) . pipe ( Effect . scoped ) ,
27252725 ) ;
27262726
2727- it . effect ( "recovers an owned server after more than five failed reconciliation requests" , ( ) =>
2728- Effect . gen ( function * ( ) {
2729- const allowRecovery = yield * Deferred . make < void > ( ) ;
2730- const attempts = yield * Queue . unbounded < void > ( ) ;
2731- let attempt = 0 ;
2732- const { runtime, thread } = yield * resumed (
2733- [
2734- out ( "session.prompt" , { sessionID : SESSION , text : "<any>" } ) ,
2735- promptAccepted ,
2736- { type : "runtime_exit" , status : "success" } ,
2737- out ( "event.subscribe" ) ,
2738- ...Array . from ( { length : 6 } , ( ) => [
2739- out ( "session.active" ) ,
2740- reply ( "session.active" , { status : 503 , body : { message : "Recovering" } } ) ,
2741- ] ) . flat ( ) ,
2742- ...reconnected ( { [ SESSION ] : { type : "running" } } ) . slice ( 2 ) ,
2743- ...openRequests ( [ ] ) ,
2744- event ( "session.execution.succeeded" , { sessionID : SESSION } ) ,
2745- ] ,
2746- {
2747- beforeResponse : ( path ) =>
2748- path === "/api/session/active"
2749- ? Effect . gen ( function * ( ) {
2750- attempt += 1 ;
2751- yield * Queue . offer ( attempts , undefined ) ;
2752- if ( attempt === 7 ) yield * Deferred . await ( allowRecovery ) ;
2753- } )
2754- : Effect . void ,
2755- } ,
2756- ) ;
2757- const terminal = yield * terminalOf ( runtime ) . pipe ( Effect . forkScoped ) ;
2758- yield * runtime . startTurn ( turnInput ( thread ) ) ;
2759- for ( let retry = 0 ; retry < 6 ; retry += 1 ) {
2727+ it . effect . each ( [ 503 , 429 ] ) (
2728+ "recovers an owned server after more than five HTTP %s reconciliation replies" ,
2729+ ( status ) =>
2730+ Effect . gen ( function * ( ) {
2731+ const allowRecovery = yield * Deferred . make < void > ( ) ;
2732+ const attempts = yield * Queue . unbounded < void > ( ) ;
2733+ let attempt = 0 ;
2734+ const { runtime, thread } = yield * resumed (
2735+ [
2736+ out ( "session.prompt" , { sessionID : SESSION , text : "<any>" } ) ,
2737+ promptAccepted ,
2738+ { type : "runtime_exit" , status : "success" } ,
2739+ out ( "event.subscribe" ) ,
2740+ ...Array . from ( { length : 6 } , ( ) => [
2741+ out ( "session.active" ) ,
2742+ reply ( "session.active" , { status, body : { message : "Recovering" } } ) ,
2743+ ] ) . flat ( ) ,
2744+ ...reconnected ( { [ SESSION ] : { type : "running" } } ) . slice ( 2 ) ,
2745+ ...openRequests ( [ ] ) ,
2746+ event ( "session.execution.succeeded" , { sessionID : SESSION } ) ,
2747+ ] ,
2748+ {
2749+ beforeResponse : ( path ) =>
2750+ path === "/api/session/active"
2751+ ? Effect . gen ( function * ( ) {
2752+ attempt += 1 ;
2753+ yield * Queue . offer ( attempts , undefined ) ;
2754+ if ( attempt === 7 ) yield * Deferred . await ( allowRecovery ) ;
2755+ } )
2756+ : Effect . void ,
2757+ } ,
2758+ ) ;
2759+ const terminal = yield * terminalOf ( runtime ) . pipe ( Effect . forkScoped ) ;
2760+ yield * runtime . startTurn ( turnInput ( thread ) ) ;
2761+ for ( let retry = 0 ; retry < 6 ; retry += 1 ) {
2762+ yield * Queue . take ( attempts ) ;
2763+ yield * TestClock . adjust ( "30 seconds" ) ;
2764+ }
27602765 yield * Queue . take ( attempts ) ;
2761- yield * TestClock . adjust ( "30 seconds" ) ;
2762- }
2763- yield * Queue . take ( attempts ) ;
2764- yield * Deferred . succeed ( allowRecovery , undefined ) ;
2765- assert . equal ( ( yield * Fiber . join ( terminal ) ) ?. status , "completed" ) ;
2766- } ) . pipe ( Effect . scoped ) ,
2766+ yield * Deferred . succeed ( allowRecovery , undefined ) ;
2767+ assert . equal ( ( yield * Fiber . join ( terminal ) ) ?. status , "completed" ) ;
2768+ } ) . pipe ( Effect . scoped ) ,
27672769 ) ;
27682770
27692771 it . effect (
0 commit comments