The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type * as runtime from "@cloudflare/workers-types"; |
| 2 | import * as Predicate from "effect/Predicate"; |
| 3 | import * as Stream from "effect/Stream"; |
| 4 | |
| 5 | type ReplaceEffectStream<T> = T extends Stream.Stream<any> ? runtime.ReadableStream<any> : T; |
| 6 | |
| 7 | /** |
| 8 | * If the value is an Effect stream, converts it to a ReadableStream. |
| 9 | * Otherwise, returns the value unchanged. |
| 10 | */ |
| 11 | export function replaceEffectStream<T>(value: T): ReplaceEffectStream<T> { |
| 12 | if (isEffectStream(value)) { |
| 13 | return Stream.toReadableStream(value) as ReplaceEffectStream<T>; |
| 14 | } |
| 15 | return value as ReplaceEffectStream<T>; |
| 16 | } |
| 17 | |
| 18 | const isEffectStream = (value: unknown): value is Stream.Stream<any> => |
| 19 | Predicate.hasProperty(value, "~effect/Stream"); |