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 * as Effect from "effect/Effect"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import { makeHttpStreamBinding } from "./StreamHttp.ts"; |
| 4 | import { WriteStream } from "./WriteStream.ts"; |
| 5 | |
| 6 | /** |
| 7 | * HTTP-backed implementation of the {@link WriteStream} service. Creates |
| 8 | * a scoped `AccountApiToken` with the `Pipelines Send` permission, binds |
| 9 | * it into the host, and POSTs records to the stream's HTTP ingest |
| 10 | * endpoint (`https://{stream_id}.ingest.cloudflare.com`). |
| 11 | * |
| 12 | * The stream must have its HTTP endpoint enabled — declare it with |
| 13 | * `http: true` (authenticated). Records are validated and encoded with |
| 14 | * the stream's Effect Schema exactly as with `WriteStreamBinding`. |
| 15 | * ### Providing the Layer |
| 16 | * **Example:** Send over HTTP from any host |
| 17 | * ```typescript |
| 18 | * const Events = Cloudflare.Basin.Stream("Events", { http: true }); |
| 19 | * |
| 20 | * Effect.gen(function* () { |
| 21 | * const events = yield* Cloudflare.Basin.WriteStream(Events); |
| 22 | * // ... |
| 23 | * }).pipe(Effect.provide(Cloudflare.Basin.WriteStreamHttp)); |
| 24 | * ``` |
| 25 | * |
| 26 | * @layer |
| 27 | * @provides Cloudflare.Pipelines.WriteStream |
| 28 | * @product Pipelines |
| 29 | * @category Storage & Databases |
| 30 | */ |
| 31 | export const WriteStreamHttp = Layer.effect( |
| 32 | WriteStream, |
| 33 | Effect.suspend(() => |
| 34 | makeHttpStreamBinding({ layer: "WriteStreamHttp", makeClient: (client) => client }), |
| 35 | ), |
| 36 | ); |