MCPcopy Create free account
hub / github.com/anomalyco/opencode / makeRuntime

Function makeRuntime

packages/opencode/src/effect/run-service.ts:33–47  ·  view source on GitHub ↗
(service: Context.Service<I, S>, layer: Layer.Layer<I, E>)

Source from the content-addressed store, hash-verified

31}
32
33export function makeRuntime<I, S, E>(service: Context.Service<I, S>, layer: Layer.Layer<I, E>) {
34 let rt: ManagedRuntime.ManagedRuntime<I, E> | undefined
35 const getRuntime = () => (rt ??= ManagedRuntime.make(Layer.provideMerge(layer, Observability.layer), { memoMap }))
36
37 return {
38 runSync: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runSync(attach(service.use(fn))),
39 runPromiseExit: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) =>
40 getRuntime().runPromiseExit(attach(service.use(fn)), options),
41 runPromise: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) =>
42 getRuntime().runPromise(attach(service.use(fn)), options),
43 runFork: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runFork(attach(service.use(fn))),
44 runCallback: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) =>
45 getRuntime().runCallback(attach(service.use(fn))),
46 }
47}

Callers 5

runtime.boot.tsFile · 0.90
createVariantRuntimeFunction · 0.90
createSessionTransportFunction · 0.90
handlerFunction · 0.50

Calls 3

getRuntimeFunction · 0.70
attachFunction · 0.70
useMethod · 0.45

Tested by

no test coverage detected