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

Function withFetch

packages/opencode/test/tool/webfetch.test.ts:30–38  ·  view source on GitHub ↗
(
  fetch: (req: Request) => Response | Promise<Response>,
  fn: (url: URL) => Effect.Effect<A, E, R>,
)

Source from the content-addressed store, hash-verified

28}
29
30const withFetch = <A, E, R>(
31 fetch: (req: Request) => Response | Promise<Response>,
32 fn: (url: URL) => Effect.Effect<A, E, R>,
33) =>
34 Effect.acquireUseRelease(
35 Effect.sync(() => Bun.serve({ port: 0, fetch })),
36 (server) => fn(server.url),
37 (server) => Effect.sync(() => server.stop(true)),
38 )
39
40const exec = Effect.fn("WebFetchToolTest.exec")(function* (args: Tool.InferParameters<typeof WebFetchTool>) {
41 const info = yield* WebFetchTool

Callers 1

webfetch.test.tsFile · 0.85

Calls 3

syncMethod · 0.80
fnFunction · 0.50
stopMethod · 0.45

Tested by

no test coverage detected