summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-12-04 23:47:46 -0500
committerDax Raad <[email protected]>2025-12-04 23:47:57 -0500
commit856e1e2948ae74d61c0ba83c53bef4018a2964a1 (patch)
tree8d4bfe24779923f2e00f83ac12e494ffaacfa686
parentbef4fdfc4bc22f6d84e2350bffe5da5c41543b3a (diff)
downloadopencode-856e1e2948ae74d61c0ba83c53bef4018a2964a1.tar.gz
opencode-856e1e2948ae74d61c0ba83c53bef4018a2964a1.zip
fix pty builds
-rw-r--r--packages/opencode/src/pty/index.ts27
1 files changed, 26 insertions, 1 deletions
diff --git a/packages/opencode/src/pty/index.ts b/packages/opencode/src/pty/index.ts
index efb519ff2..93f264788 100644
--- a/packages/opencode/src/pty/index.ts
+++ b/packages/opencode/src/pty/index.ts
@@ -1,4 +1,4 @@
-import { spawn, type IPty } from "bun-pty"
+import { type IPty } from "bun-pty"
import z from "zod"
import { Identifier } from "../id/id"
import { Log } from "../util/log"
@@ -6,10 +6,34 @@ import { Bus } from "../bus"
import type { WSContext } from "hono/ws"
import { Instance } from "../project/instance"
import { shell } from "@opencode-ai/util/shell"
+import { lazy } from "@opencode-ai/util/lazy"
+import {} from "process"
export namespace Pty {
const log = Log.create({ service: "pty" })
+ const pty = lazy(async () => {
+ const path = require(
+ `bun-pty/rust-pty/target/release/${
+ process.platform === "win32"
+ ? "rust_pty.dll"
+ : process.platform === "linux" && process.arch === "x64"
+ ? "librust_pty.so"
+ : process.platform === "darwin" && process.arch === "x64"
+ ? "librust_pty.dylib"
+ : process.platform === "darwin" && process.arch === "arm64"
+ ? "librust_pty_arm64.dylib"
+ : process.platform === "linux" && process.arch === "arm64"
+ ? "librust_pty_arm64.so"
+ : ""
+ }`,
+ )
+ console.log(path)
+ process.env.BUN_PTY_LIB = path
+ const { spawn } = await import("bun-pty")
+ return spawn
+ })
+
export const Info = z
.object({
id: Identifier.schema("pty"),
@@ -91,6 +115,7 @@ export namespace Pty {
const env = { ...process.env, ...input.env } as Record<string, string>
log.info("creating session", { id, cmd: command, args, cwd })
+ const spawn = await pty()
const ptyProcess = spawn(command, args, {
name: "xterm-256color",
cwd,