feat(server): report the machine's hostname in /api/info (#59090)

Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
Luke Parker
2026-10-26 09:15:22 +10:00
committed by GitHub
Unverified
parent 14d8b1d621
commit 79469efc98
6 changed files with 17 additions and 0 deletions
+1
View File
@@ -431,6 +431,7 @@ test("concurrent service processes elect one server", async () => {
).toEqual({
version: info.version,
pid: info.pid,
hostname: os.hostname(),
urls: [info.url],
// The server reports the canonical tmp directory; Windows os.tmpdir() can be an 8.3 short name.
paths: { tmp: await fs.realpath(path.join(os.tmpdir(), "opencode")) },
+1
View File
@@ -46,6 +46,7 @@ import type { Config } from "@opencode/schema/config"
export type ServerInfoOutput = {
readonly version: string
readonly pid: number
readonly hostname?: string | undefined
readonly urls: ReadonlyArray<string>
readonly paths: { readonly tmp: string }
readonly capabilities?: { readonly persistentPty?: boolean | undefined } | undefined
+1
View File
@@ -3,6 +3,7 @@ export type JsonValue = null | boolean | number | string | Array<JsonValue> | {
export type ServerInfo = {
version: string
pid: number
hostname?: string | undefined
urls: Array<string>
paths: { tmp: string }
capabilities?: { persistentPty?: boolean | undefined } | undefined
+10
View File
@@ -19138,6 +19138,16 @@
"type": "integer",
"minimum": 0
},
"hostname": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"urls": {
"type": "array",
"items": {
+2
View File
@@ -6,6 +6,8 @@ export const ServerInfo = Schema.Struct({
version: Schema.String,
// 0 means the runtime has no OS process identity (e.g. workerd).
pid: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
// The machine's name, absent where the runtime has none (e.g. workerd).
hostname: Schema.optional(Schema.String),
urls: Schema.Array(Schema.String),
paths: Schema.Struct({
tmp: Schema.String,
+2
View File
@@ -1,3 +1,4 @@
import { hostname } from "node:os"
import { Duration, Effect } from "effect"
import { HttpServerRequest, HttpServerResponse } from "effect/http"
import { HttpApiBuilder } from "effect/http-api"
@@ -20,6 +21,7 @@ export const ServerHandler = HttpApiBuilder.group(Api, "server.server", (handler
return {
version: info.app.version ?? "unknown",
pid: process.pid ?? 0,
hostname: hostname() || undefined,
urls: info.urls(),
paths: info.paths,
capabilities: { persistentPty: PersistentPty.available },