|
|
@@ -6,11 +6,12 @@ import { fileURLToPath } from "url"
|
|
|
import { UI } from "@/cli/ui"
|
|
|
import { errorMessage } from "@opencode-ai/tui/util/error"
|
|
|
import { withTimeout } from "@/util/timeout"
|
|
|
-import { withNetworkOptions, resolveNetworkOptionsNoConfig } from "@/cli/network"
|
|
|
+import { withNetworkOptions, resolveNetworkOptionsNoConfig, hasArg } from "@/cli/network"
|
|
|
import { Filesystem } from "@/util/filesystem"
|
|
|
import type { GlobalEvent } from "@opencode-ai/sdk/v2"
|
|
|
import type { EventSource } from "@opencode-ai/tui/context/sdk"
|
|
|
import { writeHeapSnapshot } from "v8"
|
|
|
+import { ServerAuth } from "@/server/auth"
|
|
|
import { validateSession } from "../tui/validate-session"
|
|
|
import { win32InstallCtrlCGuard } from "@opencode-ai/tui/terminal-win32"
|
|
|
|
|
|
@@ -211,19 +212,16 @@ export const TuiThreadCommand = cmd({
|
|
|
const config = await TuiConfig.get()
|
|
|
|
|
|
const network = resolveNetworkOptionsNoConfig(args)
|
|
|
- const external =
|
|
|
- process.argv.includes("--port") ||
|
|
|
- process.argv.includes("--hostname") ||
|
|
|
- process.argv.includes("--mdns") ||
|
|
|
- network.mdns ||
|
|
|
- network.port !== 0 ||
|
|
|
- network.hostname !== "127.0.0.1"
|
|
|
+ const external = hasArg("--port") || hasArg("--hostname") || network.mdns === true
|
|
|
+
|
|
|
+ const headers = external ? ServerAuth.headers() : undefined
|
|
|
|
|
|
const transport = external
|
|
|
? {
|
|
|
url: (await client.call("server", network)).url,
|
|
|
fetch: undefined,
|
|
|
events: undefined,
|
|
|
+ headers,
|
|
|
}
|
|
|
: {
|
|
|
url: "http://opencode.internal",
|
|
|
@@ -237,6 +235,7 @@ export const TuiThreadCommand = cmd({
|
|
|
sessionID: args.session,
|
|
|
directory: cwd,
|
|
|
fetch: transport.fetch,
|
|
|
+ headers,
|
|
|
})
|
|
|
} catch (error) {
|
|
|
UI.error(errorMessage(error))
|
|
|
@@ -264,6 +263,7 @@ export const TuiThreadCommand = cmd({
|
|
|
pluginHost: createLegacyTuiPluginHost(),
|
|
|
directory: cwd,
|
|
|
fetch: transport.fetch,
|
|
|
+ headers: transport.headers,
|
|
|
events: transport.events,
|
|
|
args: {
|
|
|
continue: args.continue,
|