mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 22:32:28 +00:00
39 lines
1004 B
TypeScript
39 lines
1004 B
TypeScript
import { Server } from "../../server/server"
|
|
import { UI } from "../ui"
|
|
import { cmd } from "./cmd"
|
|
import open from "open"
|
|
|
|
export const WebCommand = cmd({
|
|
command: "web",
|
|
builder: (yargs) =>
|
|
yargs
|
|
.option("port", {
|
|
alias: ["p"],
|
|
type: "number",
|
|
describe: "port to listen on",
|
|
default: 0,
|
|
})
|
|
.option("hostname", {
|
|
type: "string",
|
|
describe: "hostname to listen on",
|
|
default: "127.0.0.1",
|
|
}),
|
|
describe: "starts a headless opencode server",
|
|
handler: async (args) => {
|
|
const hostname = args.hostname
|
|
const port = args.port
|
|
const server = Server.listen({
|
|
port,
|
|
hostname,
|
|
})
|
|
const url = `https://desktop.dev.opencode.ai?url=${server.url}`
|
|
UI.empty()
|
|
UI.println(UI.logo(" "))
|
|
UI.empty()
|
|
UI.println(UI.Style.TEXT_INFO_BOLD + " Web interface: ", UI.Style.TEXT_NORMAL, url)
|
|
open(url).catch(() => {})
|
|
await new Promise(() => {})
|
|
await server.stop()
|
|
},
|
|
})
|