@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 06:00 UTC

main
ts 30 lines 1.21 KB
Raw
1 import * as Layer from "effect/Layer";
2 import { makeLocalTunnelClient } from "./TunnelLocalBinding.ts";
3 import { WriteTunnel, writeClient } from "./WriteTunnel.ts";
4
5 /**
6 * Local implementation of the {@link WriteTunnel} binding — creates, updates,
7 * and deletes Cloudflare Tunnels over the cfd_tunnel HTTP API using the
8 * **current credentials** instead of a native Worker binding
9 * (`WriteTunnelBinding`) or a scoped API token. No `host.bind`, no minted
10 * token, no Worker host.
11 *
12 * Provide it on an {@link Action} (or any deploy-time Effect) so you can mutate
13 * tunnels with the same `create`/`update`/`delete`/`putConfiguration` client
14 * you'd use inside a Worker.
15 *
16 * @example Provision a tunnel from an Action
17 * ```typescript
18 * const Provision = Alchemy.Action(
19 * "Provision",
20 * Effect.gen(function* () {
21 * const tunnels = yield* Cloudflare.Tunnel.WriteTunnel();
22 * return Effect.fn(function* () {
23 * const tunnel = yield* tunnels.create({ name: "on-demand-tunnel" });
24 * return tunnel.result?.id;
25 * });
26 * }).pipe(Effect.provide(Cloudflare.Tunnel.WriteTunnelLocal)),
27 * );
28 * ```
29 */
30 export const WriteTunnelLocal = Layer.effect(WriteTunnel, makeLocalTunnelClient(writeClient));