mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-01 16:51:53 +03:00
feat(cli): add native TypeScript terminal UI
Rebuild the terminal client on OpenTUI while keeping the Python gateway as the single agent, session, tool, and memory runtime. Preserve a classic prompt fallback and publish version-matched native sidecars for supported platforms. Co-authored-by: Bingxi Zhao <150592536+pancacake@users.noreply.github.com> Co-authored-by: chengyongru <2755839590@qq.com>
This commit is contained in:
co-authored by
Bingxi Zhao
chengyongru
parent
c27b1f14c3
commit
ce070c832d
@@ -0,0 +1,34 @@
|
||||
import { chmod, mkdir } from "node:fs/promises"
|
||||
import { basename, join } from "node:path"
|
||||
|
||||
const target = process.argv[2] || `${process.platform}-${process.arch}`
|
||||
const [platform, arch] = target.split("-")
|
||||
|
||||
if (!platform || !arch || !["darwin", "linux", "win32"].includes(platform)) {
|
||||
throw new Error(`unsupported target: ${target}`)
|
||||
}
|
||||
|
||||
const bunPlatform = platform === "win32" ? "windows" : platform
|
||||
const extension = platform === "win32" ? ".exe" : ""
|
||||
const outputDir = join(import.meta.dir, "..", "dist")
|
||||
const output = join(outputDir, `nanobot-tui-${platform}-${arch}${extension}`)
|
||||
|
||||
await mkdir(outputDir, { recursive: true })
|
||||
const result = await Bun.build({
|
||||
entrypoints: [join(import.meta.dir, "..", "src", "index.ts")],
|
||||
compile: {
|
||||
target: `bun-${bunPlatform}-${arch}` as Bun.Build.CompileTarget,
|
||||
outfile: output,
|
||||
},
|
||||
})
|
||||
|
||||
if (!result.success) {
|
||||
for (const log of result.logs) console.error(log)
|
||||
process.exit(1)
|
||||
}
|
||||
if (platform !== "win32") await chmod(output, 0o755)
|
||||
const digest = new Bun.CryptoHasher("sha256")
|
||||
.update(await Bun.file(output).arrayBuffer())
|
||||
.digest("hex")
|
||||
await Bun.write(`${output}.sha256`, `${digest} ${basename(output)}\n`)
|
||||
console.log(output)
|
||||
Reference in New Issue
Block a user