MCPcopy Index your code
hub / github.com/anomalyco/opencode / createWorkerFetch

Function createWorkerFetch

packages/opencode/src/cli/cmd/tui.ts:24–40  ·  view source on GitHub ↗
(client: RpcClient)

Source from the content-addressed store, hash-verified

22type RpcClient = ReturnType<typeof Rpc.client<typeof rpc>>
23
24function createWorkerFetch(client: RpcClient): typeof fetch {
25 const fn = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
26 const request = new Request(input, init)
27 const body = request.body ? await request.text() : undefined
28 const result = await client.call("fetch", {
29 url: request.url,
30 method: request.method,
31 headers: Object.fromEntries(request.headers.entries()),
32 body,
33 })
34 return new Response(result.body, {
35 status: result.status,
36 headers: result.headers,
37 })
38 }
39 return fn as typeof fetch
40}
41
42function createEventSource(client: RpcClient): EventSource {
43 return {

Callers 1

tui.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected