Skip to content

Commit 941d4d4

Browse files
rekram1-nodetriklozoid
authored andcommitted
Revert "feat(core): optional mdns service (anomalyco#6192)"
This reverts commit 26e7043.
1 parent 5181602 commit 941d4d4

16 files changed

Lines changed: 115 additions & 237 deletions

File tree

bun.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"@standard-schema/spec": "1.0.0",
8989
"@zip.js/zip.js": "2.7.62",
9090
"ai": "catalog:",
91-
"bonjour-service": "1.3.0",
9291
"bun-pty": "0.4.2",
9392
"chokidar": "4.0.3",
9493
"clipboardy": "4.0.0",

packages/opencode/src/cli/cmd/acp.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import { bootstrap } from "../bootstrap"
33
import { cmd } from "./cmd"
44
import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk"
55
import { ACP } from "@/acp/agent"
6-
import { Config } from "@/config/config"
76
import { Server } from "@/server/server"
87
import { createOpencodeClient } from "@opencode-ai/sdk/v2"
9-
import { withNetworkOptions, resolveNetworkOptions } from "../network"
108

119
const log = Log.create({ service: "acp-command" })
1210

@@ -21,17 +19,29 @@ export const AcpCommand = cmd({
2119
command: "acp",
2220
describe: "start ACP (Agent Client Protocol) server",
2321
builder: (yargs) => {
24-
return withNetworkOptions(yargs).option("cwd", {
25-
describe: "working directory",
26-
type: "string",
27-
default: process.cwd(),
28-
})
22+
return yargs
23+
.option("cwd", {
24+
describe: "working directory",
25+
type: "string",
26+
default: process.cwd(),
27+
})
28+
.option("port", {
29+
type: "number",
30+
describe: "port to listen on",
31+
default: 0,
32+
})
33+
.option("hostname", {
34+
type: "string",
35+
describe: "hostname to listen on",
36+
default: "127.0.0.1",
37+
})
2938
},
3039
handler: async (args) => {
3140
await bootstrap(process.cwd(), async () => {
32-
const config = await Config.get()
33-
const opts = resolveNetworkOptions(args, config)
34-
const server = Server.listen(opts)
41+
const server = Server.listen({
42+
port: args.port,
43+
hostname: args.hostname,
44+
})
3545

3646
const sdk = createOpencodeClient({
3747
baseUrl: `http://${server.hostname}:${server.port}`,

packages/opencode/src/cli/cmd/serve.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
import { Config } from "../../config/config"
21
import { Server } from "../../server/server"
32
import { cmd } from "./cmd"
4-
import { withNetworkOptions, resolveNetworkOptions } from "../network"
53

64
export const ServeCommand = cmd({
75
command: "serve",
8-
builder: (yargs) => withNetworkOptions(yargs),
6+
builder: (yargs) =>
7+
yargs
8+
.option("port", {
9+
alias: ["p"],
10+
type: "number",
11+
describe: "port to listen on",
12+
default: 0,
13+
})
14+
.option("hostname", {
15+
type: "string",
16+
describe: "hostname to listen on",
17+
default: "127.0.0.1",
18+
}),
919
describe: "starts a headless opencode server",
1020
handler: async (args) => {
11-
const config = await Config.get()
12-
const opts = resolveNetworkOptions(args, config)
13-
const server = Server.listen(opts)
21+
const hostname = args.hostname
22+
const port = args.port
23+
const server = Server.listen({
24+
port,
25+
hostname,
26+
})
1427
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
1528
await new Promise(() => {})
1629
await server.stop()

packages/opencode/src/cli/cmd/tui/spawn.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
import { cmd } from "@/cli/cmd/cmd"
2-
import { Config } from "@/config/config"
32
import { Instance } from "@/project/instance"
43
import path from "path"
54
import { Server } from "@/server/server"
65
import { upgrade } from "@/cli/upgrade"
7-
import { withNetworkOptions, resolveNetworkOptions } from "@/cli/network"
86

97
export const TuiSpawnCommand = cmd({
108
command: "spawn [project]",
119
builder: (yargs) =>
12-
withNetworkOptions(yargs).positional("project", {
13-
type: "string",
14-
describe: "path to start opencode in",
15-
}),
10+
yargs
11+
.positional("project", {
12+
type: "string",
13+
describe: "path to start opencode in",
14+
})
15+
.option("port", {
16+
type: "number",
17+
describe: "port to listen on",
18+
default: 0,
19+
})
20+
.option("hostname", {
21+
type: "string",
22+
describe: "hostname to listen on",
23+
default: "127.0.0.1",
24+
}),
1625
handler: async (args) => {
1726
upgrade()
18-
const config = await Config.get()
19-
const opts = resolveNetworkOptions(args, config)
20-
const server = Server.listen(opts)
27+
const server = Server.listen({
28+
port: args.port,
29+
hostname: "127.0.0.1",
30+
})
2131
const bin = process.execPath
2232
const cmd = []
2333
let cwd = process.cwd()

packages/opencode/src/cli/cmd/tui/thread.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import path from "path"
66
import { UI } from "@/cli/ui"
77
import { iife } from "@/util/iife"
88
import { Log } from "@/util/log"
9-
import { withNetworkOptions, resolveNetworkOptions } from "@/cli/network"
10-
import { Config } from "@/config/config"
119

1210
declare global {
1311
const OPENCODE_WORKER_PATH: string
@@ -17,7 +15,7 @@ export const TuiThreadCommand = cmd({
1715
command: "$0 [project]",
1816
describe: "start opencode tui",
1917
builder: (yargs) =>
20-
withNetworkOptions(yargs)
18+
yargs
2119
.positional("project", {
2220
type: "string",
2321
describe: "path to start opencode in",
@@ -38,12 +36,23 @@ export const TuiThreadCommand = cmd({
3836
describe: "session id to continue",
3937
})
4038
.option("prompt", {
39+
alias: ["p"],
4140
type: "string",
4241
describe: "prompt to use",
4342
})
4443
.option("agent", {
4544
type: "string",
4645
describe: "agent to use",
46+
})
47+
.option("port", {
48+
type: "number",
49+
describe: "port to listen on",
50+
default: 0,
51+
})
52+
.option("hostname", {
53+
type: "string",
54+
describe: "hostname to listen on",
55+
default: "127.0.0.1",
4756
}),
4857
handler: async (args) => {
4958
// Resolve relative paths against PWD to preserve behavior when using --cwd flag
@@ -78,9 +87,10 @@ export const TuiThreadCommand = cmd({
7887
process.on("unhandledRejection", (e) => {
7988
Log.Default.error(e)
8089
})
81-
const config = await Config.get()
82-
const networkOpts = resolveNetworkOptions(args, config)
83-
const server = await client.call("server", networkOpts)
90+
const server = await client.call("server", {
91+
port: args.port,
92+
hostname: args.hostname,
93+
})
8494
const prompt = await iife(async () => {
8595
const piped = !process.stdin.isTTY ? await Bun.stdin.text() : undefined
8696
if (!args.prompt) return piped

packages/opencode/src/cli/cmd/tui/worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ process.on("uncaughtException", (e) => {
3030

3131
let server: Bun.Server<BunWebSocketData>
3232
export const rpc = {
33-
async server(input: { port: number; hostname: string; mdns?: boolean }) {
33+
async server(input: { port: number; hostname: string }) {
3434
if (server) await server.stop(true)
3535
try {
3636
server = Server.listen(input)

packages/opencode/src/cli/cmd/web.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { Config } from "../../config/config"
21
import { Server } from "../../server/server"
32
import { UI } from "../ui"
43
import { cmd } from "./cmd"
5-
import { withNetworkOptions, resolveNetworkOptions } from "../network"
64
import open from "open"
75
import { networkInterfaces } from "os"
86

@@ -30,17 +28,32 @@ function getNetworkIPs() {
3028

3129
export const WebCommand = cmd({
3230
command: "web",
33-
builder: (yargs) => withNetworkOptions(yargs),
31+
builder: (yargs) =>
32+
yargs
33+
.option("port", {
34+
alias: ["p"],
35+
type: "number",
36+
describe: "port to listen on",
37+
default: 0,
38+
})
39+
.option("hostname", {
40+
type: "string",
41+
describe: "hostname to listen on",
42+
default: "127.0.0.1",
43+
}),
3444
describe: "starts a headless opencode server",
3545
handler: async (args) => {
36-
const config = await Config.get()
37-
const opts = resolveNetworkOptions(args, config)
38-
const server = Server.listen(opts)
46+
const hostname = args.hostname
47+
const port = args.port
48+
const server = Server.listen({
49+
port,
50+
hostname,
51+
})
3952
UI.empty()
4053
UI.println(UI.logo(" "))
4154
UI.empty()
4255

43-
if (opts.hostname === "0.0.0.0") {
56+
if (hostname === "0.0.0.0") {
4457
// Show localhost for local access
4558
const localhostUrl = `http://localhost:${server.port}`
4659
UI.println(UI.Style.TEXT_INFO_BOLD + " Local access: ", UI.Style.TEXT_NORMAL, localhostUrl)
@@ -57,10 +70,6 @@ export const WebCommand = cmd({
5770
}
5871
}
5972

60-
if (opts.mdns) {
61-
UI.println(UI.Style.TEXT_INFO_BOLD + " mDNS: ", UI.Style.TEXT_NORMAL, "opencode.local")
62-
}
63-
6473
// Open localhost in browser
6574
open(localhostUrl.toString()).catch(() => {})
6675
} else {

packages/opencode/src/cli/network.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)