refactor(cli): unify server endpoint handling

This commit is contained in:
Dax Raad 2026-07-08 21:51:37 -04:00
commit be7a684791
18 changed files with 212 additions and 223 deletions

View file

@ -1,4 +1,5 @@
import { Effect } from "effect"
import { Service } from "@opencode-ai/client/effect"
import path from "node:path"
import { Standalone } from "../../src/services/standalone"
@ -7,9 +8,11 @@ process.argv[1] = path.join(import.meta.dir, "../../src/index.ts")
await Effect.runPromise(
Effect.scoped(
Effect.gen(function* () {
const transport = yield* Standalone.transport()
const response = yield* Effect.promise(() => fetch(new URL("/api/health", transport.url), { headers: transport.headers }))
console.log(`${transport.pid} ${transport.url} ${response.status}`)
const endpoint = yield* Standalone.start()
const response = yield* Effect.promise(() =>
fetch(new URL("/api/health", endpoint.url), { headers: Service.headers(endpoint) }),
)
console.log(`${endpoint.pid} ${endpoint.url} ${response.status}`)
return yield* Effect.never
}),
),