MCPcopy
hub / github.com/anomalyco/opencode / checkHealth

Function checkHealth

packages/desktop/src/main/server.ts:184–208  ·  view source on GitHub ↗
(url: string, password?: string | null)

Source from the content-addressed store, hash-verified

182}
183
184export async function checkHealth(url: string, password?: string | null): Promise<boolean> {
185 let healthUrl: URL
186 try {
187 healthUrl = new URL("/global/health", url)
188 } catch {
189 return false
190 }
191
192 const headers = new Headers()
193 if (password) {
194 const auth = Buffer.from(`opencode:${password}`).toString("base64")
195 headers.set("authorization", `Basic ${auth}`)
196 }
197
198 try {
199 const res = await fetch(healthUrl, {
200 method: "GET",
201 headers,
202 signal: AbortSignal.timeout(3000),
203 })
204 return res.ok
205 } catch {
206 return false
207 }
208}
209
210function createSidecarEnv(): Record<string, string> {
211 const env = Object.fromEntries(

Callers 2

spawnWslSidecarFunction · 0.90
readyFunction · 0.85

Calls 3

fetchFunction · 0.50
fromMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected