Download packages/core/src/effect/runtime.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/effect/runtime.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/core/src/effect/runtime.ts
-
curl -L -o runtime.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/effect/runtime.ts
1.13 kB
| import { Layer, type Context, ManagedRuntime, type Effect } from "effect" | |
| import { memoMap } from "./memo-map" | |
| import { Observability } from "../observability" | |
| export function makeRuntime<I, S, E>(service: Context.Service<I, S>, layer: Layer.Layer<I, E>) { | |
| let rt: ManagedRuntime.ManagedRuntime<I, E> | undefined | |
| const getRuntime = () => | |
| (rt ??= ManagedRuntime.make(Layer.provideMerge(layer, Observability.layer) as Layer.Layer<I, E>, { | |
| memoMap, | |
| })) | |
| return { | |
| runSync: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runSync(service.use(fn)), | |
| runPromiseExit: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) => | |
| getRuntime().runPromiseExit(service.use(fn), options), | |
| runPromise: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) => | |
| getRuntime().runPromise(service.use(fn), options), | |
| runFork: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runFork(service.use(fn)), | |
| runCallback: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runCallback(service.use(fn)), | |
| } | |
| } | |