mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 23:02:26 +00:00
feat(core): optional mdns service (#6192)
Co-authored-by: Github Action <action@github.com>
This commit is contained in:
@@ -1,33 +1,23 @@
|
||||
import { cmd } from "@/cli/cmd/cmd"
|
||||
import { Config } from "@/config/config"
|
||||
import { Instance } from "@/project/instance"
|
||||
import path from "path"
|
||||
import { Server } from "@/server/server"
|
||||
import { upgrade } from "@/cli/upgrade"
|
||||
import { withNetworkOptions, resolveNetworkOptions } from "@/cli/network"
|
||||
|
||||
export const TuiSpawnCommand = cmd({
|
||||
command: "spawn [project]",
|
||||
builder: (yargs) =>
|
||||
yargs
|
||||
.positional("project", {
|
||||
type: "string",
|
||||
describe: "path to start opencode in",
|
||||
})
|
||||
.option("port", {
|
||||
type: "number",
|
||||
describe: "port to listen on",
|
||||
default: 0,
|
||||
})
|
||||
.option("hostname", {
|
||||
type: "string",
|
||||
describe: "hostname to listen on",
|
||||
default: "127.0.0.1",
|
||||
}),
|
||||
withNetworkOptions(yargs).positional("project", {
|
||||
type: "string",
|
||||
describe: "path to start opencode in",
|
||||
}),
|
||||
handler: async (args) => {
|
||||
upgrade()
|
||||
const server = Server.listen({
|
||||
port: args.port,
|
||||
hostname: "127.0.0.1",
|
||||
})
|
||||
const config = await Config.get()
|
||||
const opts = resolveNetworkOptions(args, config)
|
||||
const server = Server.listen(opts)
|
||||
const bin = process.execPath
|
||||
const cmd = []
|
||||
let cwd = process.cwd()
|
||||
|
||||
@@ -6,6 +6,8 @@ import path from "path"
|
||||
import { UI } from "@/cli/ui"
|
||||
import { iife } from "@/util/iife"
|
||||
import { Log } from "@/util/log"
|
||||
import { withNetworkOptions, resolveNetworkOptions } from "@/cli/network"
|
||||
import { Config } from "@/config/config"
|
||||
|
||||
declare global {
|
||||
const OPENCODE_WORKER_PATH: string
|
||||
@@ -15,7 +17,7 @@ export const TuiThreadCommand = cmd({
|
||||
command: "$0 [project]",
|
||||
describe: "start opencode tui",
|
||||
builder: (yargs) =>
|
||||
yargs
|
||||
withNetworkOptions(yargs)
|
||||
.positional("project", {
|
||||
type: "string",
|
||||
describe: "path to start opencode in",
|
||||
@@ -36,23 +38,12 @@ export const TuiThreadCommand = cmd({
|
||||
describe: "session id to continue",
|
||||
})
|
||||
.option("prompt", {
|
||||
alias: ["p"],
|
||||
type: "string",
|
||||
describe: "prompt to use",
|
||||
})
|
||||
.option("agent", {
|
||||
type: "string",
|
||||
describe: "agent to use",
|
||||
})
|
||||
.option("port", {
|
||||
type: "number",
|
||||
describe: "port to listen on",
|
||||
default: 0,
|
||||
})
|
||||
.option("hostname", {
|
||||
type: "string",
|
||||
describe: "hostname to listen on",
|
||||
default: "127.0.0.1",
|
||||
}),
|
||||
handler: async (args) => {
|
||||
// Resolve relative paths against PWD to preserve behavior when using --cwd flag
|
||||
@@ -87,10 +78,9 @@ export const TuiThreadCommand = cmd({
|
||||
process.on("unhandledRejection", (e) => {
|
||||
Log.Default.error(e)
|
||||
})
|
||||
const server = await client.call("server", {
|
||||
port: args.port,
|
||||
hostname: args.hostname,
|
||||
})
|
||||
const config = await Config.get()
|
||||
const networkOpts = resolveNetworkOptions(args, config)
|
||||
const server = await client.call("server", networkOpts)
|
||||
const prompt = await iife(async () => {
|
||||
const piped = !process.stdin.isTTY ? await Bun.stdin.text() : undefined
|
||||
if (!args.prompt) return piped
|
||||
|
||||
@@ -30,7 +30,7 @@ process.on("uncaughtException", (e) => {
|
||||
|
||||
let server: Bun.Server<BunWebSocketData>
|
||||
export const rpc = {
|
||||
async server(input: { port: number; hostname: string }) {
|
||||
async server(input: { port: number; hostname: string; mdns?: boolean }) {
|
||||
if (server) await server.stop(true)
|
||||
try {
|
||||
server = Server.listen(input)
|
||||
|
||||
Reference in New Issue
Block a user