[Bug]: `opencode-pty` still fails under OpenCode Node plugin runtime after PR #38: `bun-pty` resolves to TypeScript source under `node_modules`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- node.js, typescript
Research direction
Start with dist/src/plugin/pty/manager.js and dist/src/plugin/pty/session-lifecycle.js, then inspect node_modules/bun-pty/package.json and its src/index.ts entry. Rebuild with bun run build:prod and rerun the documented Node import test; done means the built plugin imports under Node without the node_modules type-stripping error and its PTY commands and tools appear in opencode attach.
Written by the indexing model from the issue text.
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-ptyshould load normally.- Slash commands such as
/pty-show-server-urlshould 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:
-
npm
opencode-pty@0.3.4still contains old Bun-specific imports:import { semver } from 'bun'import { Terminal } from 'bun-pty'
-
GitHub
mainappears to fix the directbunimport issue, butbun-ptyitself 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 #38,
- replace
bun-ptywith a Node-compatible PTY package, - bundle/compile the plugin so Node does not need to import
bun-pty/src/index.tsdirectly, - 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"
- Dominant language
- TypeScript
- Stars
- 582
- Forks
- 59
- Avg merge
- 13h 20m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from shekohex/opencode-pty
-
[Bug]: exit notification delivery failures are silently swallowed — agent never wakes, no diagnostic Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
shekohex/opencode-pty#54 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
shekohex/opencode-pty#48 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
shekohex/opencode-pty#60 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
shekohex/opencode-pty#57 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
shekohex/opencode-pty#47 ·
All issues in shekohex/opencode-pty
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·