Skip to content

[Bug]: opencode-pty still fails under OpenCode Node plugin runtime after PR #38: bun-pty resolves to TypeScript source under node_modules #43

Description

opencode-pty still fails under OpenCode Node plugin runtime after PR #38: bun-pty resolves to TypeScript source under node_modules

Summary

I am trying to use opencode-pty with OpenCode running as a systemd service on Ubuntu. The plugin appears to install / show in OpenCode status, but the PTY slash commands and tools do not appear in opencode attach.

After testing both the published npm package and the current GitHub main build, it looks like there are still Node-runtime compatibility problems.

The original npm package failed because it still imported Bun-specific modules such as bun. After building current main, that part appears improved, but the plugin still fails under Node because bun-pty resolves to a .ts entry inside node_modules, which Node refuses to type-strip.

Environment

OS: Ubuntu 24.04
OpenCode: 1.17.9
Node: v22.23.0
Previous Node: v18.19.1
Bun: 1.3.14
GLIBC: 2.39
Service user: root
OpenCode service command:
  /root/.opencode/bin/opencode serve --hostname 0.0.0.0 --port 4096 --print-logs

My systemd service includes:

[Service]
Type=simple
User=root
WorkingDirectory=/root/projects
ExecStart=/root/.opencode/bin/opencode serve --hostname 0.0.0.0 --port 4096 --print-logs
Restart=always
RestartSec=5
Environment=HOME=/root
Environment=PATH=/root/.bun/bin:/root/.opencode/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Config used

Global config:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "oh-my-opencode-slim",
    "opencode-pty"
  ]
}

I also tested with project-level config including opencode-pty.

Behavior

Expected:

  • opencode-pty should load normally.
  • Slash commands such as /pty-show-server-url should be available.
  • PTY tools such as pty_spawn, pty_read, pty_write, pty_list, etc. should be available.

Actual:

  • The plugin appears installed or visible in status.
  • The slash commands/tools do not show up in opencode attach.
  • The plugin does not seem to fully load.

Published npm package test

Installed package:

/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty

Package version:

{
  "name": "opencode-pty",
  "version": "0.3.4",
  "main": "dist/index.js",
  "type": "module"
}

I checked the built output:

PKG=/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty

grep -RInE "from ['\"]bun['\"]|bun:semver|from ['\"]bun-pty|bun-pty/package.json" "$PKG/dist" | head -50

Output:

/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/dist/src/plugin/pty/session-lifecycle.js:1:import { spawn } from 'bun-pty';
/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/dist/src/plugin/pty/manager.js:1:import { semver } from 'bun';
/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/dist/src/plugin/pty/manager.js:2:import { Terminal } from 'bun-pty';
/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/dist/src/plugin/pty/manager.js:3:import { version as bunPtyVersion } from 'bun-pty/package.json';

Node import test:

node -e "import('file:///root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/dist/index.js').then(()=>console.log('NODE OK')).catch(e=>console.error('NODE FAIL:', e.message))"

Output:

NODE FAIL: Cannot find package 'bun' imported from /root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/dist/src/plugin/pty/manager.js

So npm 0.3.4 still appears to contain the old Bun-specific import.

Testing current GitHub main

I then cloned and built from source:

mkdir -p /root/src
rm -rf /root/src/opencode-pty
git clone https://github.com/shekohex/opencode-pty.git /root/src/opencode-pty

cd /root/src/opencode-pty
bun install
bun run build:prod

Initially this failed on Node 18 because Vite requires newer Node:

You are using Node.js 18.19.1. Vite requires Node.js version 20.19+ or 22.12+.
error during build:
[vite:build-html] crypto.hash is not a function

After upgrading Node, the build succeeded:

vite v7.3.1 building client environment for production...
✓ 40 modules transformed.
✓ built in 1.22s

Then I tested the built plugin under Node:

node -e "import('file:///root/src/opencode-pty/dist/index.js').then(()=>console.log('NODE OK')).catch(e=>console.error('NODE FAIL:', e.message))"

Output:

NODE FAIL: Stripping types is currently unsupported for files under node_modules, for "file:///root/src/opencode-pty/node_modules/bun-pty/src/index.ts"

So current main no longer fails at import { semver } from 'bun', but still fails because bun-pty resolves to a TypeScript source entry inside node_modules.

bun-pty package details

Inside:

/root/src/opencode-pty/node_modules/bun-pty

The package.json shows:

{
  "name": "bun-pty",
  "version": "0.4.8",
  "main": "./src/index.ts",
  "types": "./dist/index.d.ts",
  "type": "module",
  "engines": {
    "bun": ">=1.0.0"
  }
}

There is no compiled JS entry in dist, only declarations:

dist:
index.d.ts
index.d.ts.map
interfaces.d.ts
interfaces.d.ts.map
terminal.d.ts
terminal.d.ts.map

I tried building bun-pty:

cd /root/src/opencode-pty/node_modules/bun-pty
bun run build || true

but it failed because cargo was missing:

$ cd rust-pty && cargo build --release
/usr/bin/bash: line 1: cargo: command not found
error: script "build:rust" exited with code 127

However, even if Rust/cargo is installed, the package’s JS entry still points to ./src/index.ts, which Node does not support inside node_modules.

I also tried temporarily patching bun-pty’s package.json to point to ./dist/index.js, but that failed because no such JS file exists:

NODE FAIL: Error: Cannot find package '/root/src/opencode-pty/node_modules/bun-pty/dist/index.js' imported from /root/src/opencode-pty/dist/src/plugin/pty/manager.js

Related logs from OpenCode

OpenCode also repeatedly logged dependency install problems inside the project config directory:

message="background dependency install failed" dir=/root/projects/Raindropticon/.opencode error="Cause([Fail(NpmInstallFailedError (cause: RangeError: Invalid Date))])"

I am not sure if that is directly caused by this plugin, but the plugin’s direct Node import failure is reproducible independently with the commands above.

What seems to be happening

It looks like there are two separate compatibility layers:

  1. npm opencode-pty@0.3.4 still contains old Bun-specific imports:

    • import { semver } from 'bun'
    • import { Terminal } from 'bun-pty'
  2. GitHub main appears to fix the direct bun import issue, but bun-pty itself still resolves to:

    • bun-pty/src/index.ts

Node then fails with:

Stripping types is currently unsupported for files under node_modules

Since OpenCode’s plugin host appears to load plugins through Node ESM, opencode-pty still cannot fully load unless bun-pty becomes Node-compatible or the plugin switches to a Node-compatible PTY dependency.

Request

Could you confirm whether opencode-pty is expected to work under OpenCode’s current Node-based plugin runtime?

If yes, would it be possible to either:

  • publish a new npm release after PR bun-pty pull 37 is merged #38,
  • replace bun-pty with a Node-compatible PTY package,
  • bundle/compile the plugin so Node does not need to import bun-pty/src/index.ts directly,
  • or document that the plugin currently requires a Bun-based plugin runtime and will not work under OpenCode’s Node plugin loader?

Reproduction commands

opencode --version
node --version
bun --version
ldd --version | head -1
PKG=/root/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty

grep -RInE "from ['\"]bun['\"]|bun:semver|from ['\"]bun-pty|bun-pty/package.json" "$PKG/dist" | head -50

node -e "import('file://$PKG/dist/index.js').then(()=>console.log('NODE OK')).catch(e=>console.error('NODE FAIL:', e.message))"

For GitHub main:

mkdir -p /root/src
rm -rf /root/src/opencode-pty
git clone https://github.com/shekohex/opencode-pty.git /root/src/opencode-pty

cd /root/src/opencode-pty
bun install
bun run build:prod

node -e "import('file:///root/src/opencode-pty/dist/index.js').then(()=>console.log('NODE OK')).catch(e=>console.error('NODE FAIL:', e.message))"

Current result from GitHub main:

NODE FAIL: Stripping types is currently unsupported for files under node_modules, for "file:///root/src/opencode-pty/node_modules/bun-pty/src/index.ts"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions