1- export * as ServerDiscovery from "./discovery"
1+ export * as ServerDiscovery from "./server- discovery"
22
3- import { ServerAuth } from "@/server/auth"
43import { makeRuntime } from "@/effect/run-service"
4+ import { ServerAuth } from "@/server/auth"
55import { AppFileSystem } from "@opencode-ai/core/filesystem"
66import { Global } from "@opencode-ai/core/global"
77import { Context , Effect , Layer , Option , Schema } from "effect"
8- import path from "path"
98import { readFileSync , unlinkSync } from "fs"
9+ import path from "path"
1010
1111export const file = path . join ( Global . Path . state , "server.json" )
1212
@@ -23,36 +23,36 @@ export interface Interface {
2323 readonly find : ( ) => Effect . Effect < string | undefined >
2424}
2525
26- export class Service extends Context . Service < Service , Interface > ( ) ( "@opencode/ServerDiscovery " ) { }
26+ export class Service extends Context . Service < Service , Interface > ( ) ( "@opencode/CliServerDiscovery " ) { }
2727
2828export const layer = Layer . effect (
2929 Service ,
3030 Effect . gen ( function * ( ) {
3131 const fs = yield * AppFileSystem . Service
3232
33- const read = Effect . fn ( "ServerDiscovery .read" ) ( function * ( ) {
33+ const read = Effect . fn ( "CliServerDiscovery .read" ) ( function * ( ) {
3434 const entry = yield * fs . readJson ( file ) . pipe ( Effect . catch ( ( ) => Effect . succeed ( undefined ) ) )
3535 return Option . getOrUndefined ( decodeEntry ( entry ) )
3636 } )
3737
38- const remove = Effect . fn ( "ServerDiscovery .remove" ) ( function * ( ) {
38+ const remove = Effect . fn ( "CliServerDiscovery .remove" ) ( function * ( ) {
3939 const entry = yield * read ( )
4040 if ( entry ?. pid !== process . pid ) return
4141 yield * fs . remove ( file ) . pipe ( Effect . ignore )
4242 } )
4343
44- const removeStale = Effect . fn ( "ServerDiscovery .removeStale" ) ( function * ( entry : Entry ) {
44+ const removeStale = Effect . fn ( "CliServerDiscovery .removeStale" ) ( function * ( entry : Entry ) {
4545 const current = yield * read ( )
4646 if ( current ?. pid !== entry . pid || current . url !== entry . url ) return
4747 yield * fs . remove ( file ) . pipe ( Effect . ignore )
4848 } )
4949
5050 return Service . of ( {
51- write : Effect . fn ( "ServerDiscovery .write" ) ( function * ( url ) {
51+ write : Effect . fn ( "CliServerDiscovery .write" ) ( function * ( url ) {
5252 yield * fs . writeJson ( file , { url : localURL ( url ) . toString ( ) , pid : process . pid } , 0o600 ) . pipe ( Effect . orDie )
5353 } ) ,
5454 remove,
55- find : Effect . fn ( "ServerDiscovery .find" ) ( function * ( ) {
55+ find : Effect . fn ( "CliServerDiscovery .find" ) ( function * ( ) {
5656 const entry = yield * read ( )
5757 if ( ! entry ) return undefined
5858 const url = yield * healthy ( entry . url )
0 commit comments