| ... | @@ -2817,16 +2817,25 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | ... | @@ -2817,16 +2817,25 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( |
| 2817 | providerRefs: {}, | 2817 | providerRefs: {}, |
| 2818 | }); | 2818 | }); |
| 2819 | | 2819 | |
| 2820 | const streamFiber = runFork(runSdkStream(context)); | 2820 | let streamFiber: Fiber.Fiber<void, never>; |
| | 2821 | streamFiber = runFork( |
| | 2822 | Effect.exit(runSdkStream(context)).pipe( |
| | 2823 | Effect.flatMap((exit) => { |
| | 2824 | if (context.stopped) { |
| | 2825 | return Effect.void; |
| | 2826 | } |
| | 2827 | if (context.streamFiber === streamFiber) { |
| | 2828 | context.streamFiber = undefined; |
| | 2829 | } |
| | 2830 | return handleStreamExit(context, exit); |
| | 2831 | }), |
| | 2832 | ), |
| | 2833 | ); |
| 2821 | context.streamFiber = streamFiber; | 2834 | context.streamFiber = streamFiber; |
| 2822 | streamFiber.addObserver((exit) => { | 2835 | streamFiber.addObserver(() => { |
| 2823 | if (context.stopped) { | | |
| 2824 | return; | | |
| 2825 | } | | |
| 2826 | if (context.streamFiber === streamFiber) { | 2836 | if (context.streamFiber === streamFiber) { |
| 2827 | context.streamFiber = undefined; | 2837 | context.streamFiber = undefined; |
| 2828 | } | 2838 | } |
| 2829 | runFork(handleStreamExit(context, exit)); | | |
| 2830 | }); | 2839 | }); |
| 2831 | | 2840 | |
| 2832 | return { | 2841 | return { |