opencode/packages/client/src/service.ts
opencode-agent[bot] 60ce33cde8
fix(cli): simplify service registration lease (#37576)
Co-authored-by: Dax Raad <826656+thdxr@users.noreply.github.com>
2026-07-17 19:47:17 -04:00

53 lines
1.8 KiB
TypeScript

/** Connection details for a local OpenCode service. */
export type Endpoint = {
/** Base URL of the service. */
readonly url: string
/** Authentication required by the service, when configured. */
readonly auth?: {
/** HTTP authentication scheme. */
readonly type: "basic"
/** Basic authentication username. */
readonly username: string
/** Basic authentication password. */
readonly password: string
}
}
/** Options used to discover the local OpenCode service. */
export type DiscoverOptions = {
/** Absolute registration file path. Defaults to the XDG state directory. */
readonly file?: string
/** Required service version. */
readonly version?: string
}
/** Reason ensuring the service requires a new process. */
export type EnsureReason = "missing" | "version-mismatch"
/** Options used to ensure the local OpenCode service is running. */
export type EnsureOptions = DiscoverOptions & {
/** Service command and arguments. Defaults to `opencode serve --service`. */
readonly command?: ReadonlyArray<string>
/** Called once before spawning a new service process. */
readonly onStart?: (reason: EnsureReason, previousVersion?: string) => void
}
/** Options used to stop the local OpenCode service. */
export type StopOptions = {
/** Absolute registration file path. Defaults to the XDG state directory. */
readonly file?: string
}
/** Contents of the local service registration file. */
export type Info = {
/** Unique service instance identifier. */
readonly id?: string
/** OpenCode version served by the process. */
readonly version?: string
/** Base URL advertised by the service. */
readonly url: string
/** Operating system process identifier. */
readonly pid: number
/** Private service password, when authentication is enabled. */
readonly password?: string
}