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

Function createOpencodeClient

packages/sdk/js/src/client.ts:33–57  ·  view source on GitHub ↗
(config?: Config & { directory?: string })

Source from the content-addressed store, hash-verified

31}
32
33export function createOpencodeClient(config?: Config & { directory?: string }) {
34 if (!config?.fetch) {
35 const customFetch: any = (req: any) => {
36 // @ts-ignore
37 req.timeout = false
38 return fetch(req)
39 }
40 config = {
41 ...config,
42 fetch: customFetch,
43 }
44 }
45
46 if (config?.directory) {
47 config.headers = {
48 ...config.headers,
49 "x-opencode-directory": encodeURIComponent(config.directory),
50 }
51 }
52
53 const client = createClient(config)
54 client.interceptors.request.use((request) => rewrite(request, config?.directory))
55 client.interceptors.error.use(wrapClientError)
56 return new OpencodeClient({ client })
57}

Callers 7

daemon.tsFile · 0.90
clientFunction · 0.90
index.tsFile · 0.90
createSdkForServerFunction · 0.90
example.tsFile · 0.90
createOpencodeFunction · 0.90
createOpencodeFunction · 0.90

Calls 3

createClientFunction · 0.90
rewriteFunction · 0.70
useMethod · 0.45

Tested by 1

clientFunction · 0.72