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

Function createSdkForServer

packages/app/src/utils/server.ts:20–41  ·  view source on GitHub ↗
({
  server,
  ...config
}: Omit<NonNullable<Parameters<typeof createOpencodeClient>[0]>, "baseUrl"> & {
  server: ServerConnection.HttpBase
})

Source from the content-addressed store, hash-verified

18}
19
20export function createSdkForServer({
21 server,
22 ...config
23}: Omit<NonNullable<Parameters<typeof createOpencodeClient>[0]>, "baseUrl"> & {
24 server: ServerConnection.HttpBase
25}) {
26 const auth = (() => {
27 if (!server.password) return
28 return {
29 Authorization: `Basic ${authTokenFromCredentials({ username: server.username, password: server.password })}`,
30 }
31 })()
32
33 return createOpencodeClient({
34 ...config,
35 headers: {
36 ...(config.headers instanceof Headers ? Object.fromEntries(config.headers.entries()) : config.headers),
37 ...auth,
38 },
39 baseUrl: server.url,
40 })
41}

Callers 3

attemptFunction · 0.90
createClientFunction · 0.90

Calls 2

createOpencodeClientFunction · 0.90
authTokenFromCredentialsFunction · 0.85

Tested by

no test coverage detected