MCPcopy
hub / github.com/anomalyco/opencode / handlerLayer

Function handlerLayer

packages/llm/test/lib/http.ts:19–33  ·  view source on GitHub ↗
(handler: Handler)

Source from the content-addressed store, hash-verified

17export type Handler = (input: HandlerInput) => Effect.Effect<HttpClientResponse.HttpClientResponse>
18
19const handlerLayer = (handler: Handler): Layer.Layer<HttpClient.HttpClient> =>
20 Layer.succeed(
21 HttpClient.HttpClient,
22 HttpClient.make((request) =>
23 Effect.gen(function* () {
24 const web = yield* HttpClientRequest.toWeb(request).pipe(Effect.orDie)
25 const text = yield* Effect.promise(() => web.text())
26 return yield* handler({
27 request,
28 text,
29 respond: (body, init) => HttpClientResponse.fromWeb(request, new Response(body, init)),
30 })
31 }),
32 ),
33 )
34
35export type RuntimeEnv = RequestExecutorService | WebSocketExecutorService | LLMClientService
36

Callers 2

fixedResponseFunction · 0.85
dynamicResponseFunction · 0.85

Calls 3

textMethod · 0.65
handlerFunction · 0.50
makeMethod · 0.45

Tested by

no test coverage detected