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

Function remoteConfigClient

packages/opencode/test/config/config.test.ts:66–92  ·  view source on GitHub ↗
(input: {
  wellKnown: unknown
  remote?: unknown
  remoteHtml?: string
  seen: { wellKnown?: string; remote?: string; authorization?: string }
})

Source from the content-addressed store, hash-verified

64 })
65
66function remoteConfigClient(input: {
67 wellKnown: unknown
68 remote?: unknown
69 remoteHtml?: string
70 seen: { wellKnown?: string; remote?: string; authorization?: string }
71}) {
72 return HttpClient.make((request) => {
73 if (request.url.includes(".well-known/opencode")) {
74 input.seen.wellKnown = request.url
75 return Effect.succeed(json(request, input.wellKnown))
76 }
77 if (request.url.includes("config.example.com") && (input.remote !== undefined || input.remoteHtml !== undefined)) {
78 input.seen.remote = request.url
79 input.seen.authorization = request.headers.authorization
80 if (input.remoteHtml !== undefined) {
81 return Effect.succeed(
82 HttpClientResponse.fromWeb(
83 request,
84 new Response(input.remoteHtml, { status: 200, headers: { "content-type": "text/html; charset=utf-8" } }),
85 ),
86 )
87 }
88 return Effect.succeed(json(request, input.remote))
89 }
90 return Effect.succeed(json(request, {}, 404))
91 })
92}
93
94const configLayer = (
95 options: {

Callers 1

wellKnownFunction · 0.85

Calls 2

jsonFunction · 0.70
makeMethod · 0.45

Tested by

no test coverage detected