|
|
@@ -4,7 +4,7 @@ import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
|
|
|
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
|
|
import { PermissionSaved } from "@opencode-ai/core/permission/saved"
|
|
|
import { Global } from "@opencode-ai/core/global"
|
|
|
-import { Context, FileSystem, Layer, Option, Schedule, Schema } from "effect"
|
|
|
+import { Context, FileSystem, Layer, Option, Redacted, Schedule, Schema } from "effect"
|
|
|
import * as Effect from "effect/Effect"
|
|
|
import { HttpRouter, HttpServer } from "effect/unstable/http"
|
|
|
import { createServer } from "node:http"
|
|
|
@@ -15,6 +15,7 @@ import { createOpencodeClient } from "@opencode-ai/sdk/v2/client"
|
|
|
import { Commands } from "../commands"
|
|
|
import { Runtime } from "../../framework/runtime"
|
|
|
import { Service } from "@opencode-ai/client/effect"
|
|
|
+import { Env } from "../../env"
|
|
|
import { ServiceConfig } from "../../services/service-config"
|
|
|
import { Updater } from "../../services/updater"
|
|
|
import { randomBytes, randomUUID } from "crypto"
|
|
|
@@ -26,12 +27,16 @@ export default Runtime.handler(
|
|
|
if (input.service) yield* Effect.sync(() => process.chdir(Global.Path.home))
|
|
|
return yield* Effect.scoped(
|
|
|
Effect.gen(function* () {
|
|
|
- const standalonePassword = process.env.OPENCODE_SERVER_PASSWORD
|
|
|
+ const standalonePassword = Option.getOrUndefined(yield* Env.serverPassword)
|
|
|
+ // Keep the lease credential out of the environment inherited by any
|
|
|
+ // process this server spawns.
|
|
|
if (input.stdio) delete process.env.OPENCODE_SERVER_PASSWORD
|
|
|
const config = input.service ? yield* ServiceConfig.read() : {}
|
|
|
const password = input.service
|
|
|
? yield* ServiceConfig.password()
|
|
|
- : standalonePassword || randomBytes(32).toString("base64url")
|
|
|
+ : standalonePassword
|
|
|
+ ? Redacted.value(standalonePassword)
|
|
|
+ : randomBytes(32).toString("base64url")
|
|
|
if (!password) return yield* Effect.fail(new Error("Missing server password"))
|
|
|
const hostname = Option.getOrUndefined(input.hostname) ?? config.hostname ?? "127.0.0.1"
|
|
|
const port = Option.isSome(input.port)
|