Skip to content

feat(js): expose in-process Terminal in the NAPI package - #2523

Merged
chaliy merged 4 commits into
mainfrom
claude/project-thread-vu3h37
Oct 7, 2026
Merged

chaliy merged 4 commits into
mainfrom
claude/project-thread-vu3h37

Conversation

@chaliy

@chaliy chaliy commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What changed

@everruns/bashkit (Node, Bun, Deno) exports Terminal, matching the Rust and Python terminal: send, runUntilIdle, screenText, historyText, takeTranscript, activity, file access, plus agent-style call(input, waitMs) with Vim key notation and toolDefinition() / systemPrompt() from TerminalTool. runUntilIdle and call are async and yield between short slices, so sync methods (send, screenText, …) work while a command runs.

Why

Follow-up to #2517, #2518 and #2521: completes the terminal across Rust, Python and JS.

Before / After

Before: no terminal in JS.

After:

import { Terminal } from "@everruns/bashkit";
const term = new Terminal({ rows: 24, cols: 80, cwd: "/tmp" });
await term.call("vi notes.txt<Enter>");
const out = await term.call("ihello<Esc>:wq<Enter>");
out.commands[0].exit_code; // 0
(await term.readFile("/tmp/notes.txt")).toString(); // "hello\n"

Local: full JS suite 591 passed (includes new terminal.spec.ts), tsc + prettier clean, clippy clean, capability parity check passes.

Note: Ctrl-C while a command is running (e.g. sleep) stops the line at the next command boundary, not mid-command; same as the Rust terminal. Tests assert it.

Risk

  • Low. Additive; enables the terminal feature in the JS crate only.

Checklist

  • Tests added or updated (__test__/terminal.spec.ts)
  • Backward compatibility considered: additive; docs, knowledge and capability parity updated

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit be78c4f Commit Preview URL

Branch Preview URL
Oct 06 2026, 11:44 PM

Comment thread crates/bashkit-js/src/terminal.rs Dismissed

chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

CodeQL rust/access-invalid-pointer (alert #49) is a false positive in code generated by #[napi], not in this PR's code. I ran CodeQL 2.27.1 locally on crates/bashkit-js with the same query. The flow is wrapped_val = ptr::null_mut() → napi_unwrap(env, val, &mut wrapped_val) → &*wrapped_val, which is napi-derive-backend 6.1.5 codegen/struct.rs:173-202 expanded at the struct ident. The identical flow is reported on main for every #[napi] class: Bash (lib.rs:1776), BashTool (lib.rs:2541) and ScriptedTool (lib.rs:3352). It only shows as "new" here because Terminal is a new class. No code change on our side can clear it. It needs a dismissal as "false positive" in code scanning (I lack permission: 403).

The earlier pushes (cloning the Arc before locking, and spawning async work via Env::spawn_future on a cloned Arc instead of async fn(&self)) stay as robustness fixes; all other 34 checks are green.


Generated by Claude Code

@chaliy
chaliy merged commit 8eefea1 into main Oct 7, 2026
35 checks passed
@chaliy
chaliy deleted the claude/project-thread-vu3h37 branch October 7, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants