| 64 | }) |
| 65 | |
| 66 | function 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 | |
| 94 | const configLayer = ( |
| 95 | options: { |