@@ -152,6 +152,7 @@ const replayHttpClient = (
152152 controller : OpenCodeReplayController ,
153153 replayGate : ProviderReplayGate | undefined ,
154154 onPrompt : ( ( input : unknown ) => void ) | undefined ,
155+ beforeResponse : ( ( path : string ) => Effect . Effect < void > ) | undefined ,
155156) =>
156157 HttpClient . make ( ( request , url ) =>
157158 Effect . tryPromise ( {
@@ -210,13 +211,18 @@ const replayHttpClient = (
210211 new HttpClientError . HttpClientError ( {
211212 reason : new HttpClientError . TransportError ( { request, cause } ) ,
212213 } ) ,
213- } ) . pipe ( Effect . map ( ( response ) => HttpClientResponse . fromWeb ( request , response ) ) ) ,
214+ } ) . pipe (
215+ Effect . map ( ( response ) => HttpClientResponse . fromWeb ( request , response ) ) ,
216+ Effect . tap ( ( ) => beforeResponse ?.( url . pathname ) ?? Effect . void ) ,
217+ ) ,
214218 ) ;
215219
216220export const replayServer = (
217221 transcript : ProviderReplayTranscript ,
218222 options ?: {
219223 readonly external ?: boolean ;
224+ readonly processExit ?: Effect . Effect < void > ;
225+ readonly beforeResponse ?: ( path : string ) => Effect . Effect < void > ;
220226 readonly onPrompt ?: ( input : unknown ) => void ;
221227 readonly replayGate ?: ProviderReplayGate ;
222228 readonly borrowers ?: { current : number } ;
@@ -233,14 +239,20 @@ export const replayServer = (
233239 const opencode = yield * OpenCode2Client . make . pipe (
234240 Effect . provideService (
235241 HttpClient . HttpClient ,
236- replayHttpClient ( controller , options ?. replayGate , options ?. onPrompt ) ,
242+ replayHttpClient (
243+ controller ,
244+ options ?. replayGate ,
245+ options ?. onPrompt ,
246+ options ?. beforeResponse ,
247+ ) ,
237248 ) ,
238249 ) ;
239250 const connection = {
240251 ...( yield * opencode . connect ( { baseUrl : BASE_URL , password : "replay" } ) ) ,
241252 url : BASE_URL ,
242253 version : transcript . version ,
243254 external : options ?. external ?? false ,
255+ ...( options ?. external ? { } : { processExit : options ?. processExit ?? Effect . never } ) ,
244256 } ;
245257 const borrowers = options ?. borrowers ;
246258 return OpenCode2Server . OpenCode2Server . of ( {
@@ -265,6 +277,8 @@ const makeReplayAdapter = (
265277 transcript : ProviderReplayTranscript ,
266278 options ?: {
267279 readonly external ?: boolean ;
280+ readonly processExit ?: Effect . Effect < void > ;
281+ readonly beforeResponse ?: ( path : string ) => Effect . Effect < void > ;
268282 readonly onPrompt ?: ( input : unknown ) => void ;
269283 readonly replayGate ?: ProviderReplayGate ;
270284 readonly borrowers ?: { current : number } ;
@@ -318,6 +332,8 @@ export const openCode2ReplayRuntime = (
318332 entries : ReadonlyArray < ProviderReplayEntry > ,
319333 options ?: {
320334 readonly external ?: boolean ;
335+ readonly processExit ?: Effect . Effect < void > ;
336+ readonly beforeResponse ?: ( path : string ) => Effect . Effect < void > ;
321337 readonly version ?: string ;
322338 readonly onPrompt ?: ( input : unknown ) => void ;
323339 readonly borrowers ?: { current : number } ;
0 commit comments