Skip to content

feat(cli): stream terminal input over a single StreamInput RPC - #2005

Merged
mishushakov merged 2 commits into
mainfrom
devin/1792509319-cli-stream-input
Oct 20, 2026
Merged

mishushakov merged 2 commits into
mainfrom
devin/1792509319-cli-stream-input

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

e2b sandbox connect / create now send terminal input over one long-lived sandbox.pty.streamInput(pid, { timeoutMs: 0 }) stream instead of the BatchedQueue that polled every 10ms and issued one pty.sendInput request per batch.

let input = sandbox.pty.streamInput(pid, { timeoutMs: 0 })
process.stdin.on('data', (d) => sendInput(d))
// sendInput: on send() rejection reopen the stream (once per failed handle) and resend the chunk once;
// report an error only if the resend fails too (once until a send succeeds again)
// finally: closed = true, off listeners, await input.close().catch(() => {}) (PTY already gone)

The stream is recoverable: a failed stream (network blip, proxy reset) doesn't drop all later keystrokes; only input already queued on the failed stream is lost, like a single lost sendInput batch before. StreamInput exists in every versioned envd (since June 2024), so there's no fallback to sendInput.

Also fixes cleanup: the old code called .destroy() on the return value of process.stdout.on(...) / process.stdin.on(...) (the streams themselves); listeners are now removed with .off().

Benchmark

Same sandbox, stty raw -echo; exec cat in a PTY, 3 interleaved rounds per mode, old = exact copy of the previous BatchedQueue + sendInput path, new = streamInput (JS SDK, HTTP/2, from the Devin VM):

old (sendInput, 10ms batch) new (streamInput)
keystroke echo p50 / p90 / p99 63.3 / 66.7 / 74.8 ms 53.5 / 56.1 / 64.7 ms
1000-key burst (1 key/ms), tail after last key 86.6 ms 51.7 ms
64KB paste 117 ms 101 ms
ordering preserved yes yes

~10ms (~15%) lower per-keystroke latency (the 10ms poll + per-request overhead); the new path sits at roughly one network round trip.

Unit tests in packages/cli/tests/terminal.test.ts (ordering, reopen/resend, single error report, cleanup). Smoke-tested live: built CLI in a real PTY, sbx create, typed a command, output echoed, exit returned 0 with no errors.

Link to Devin session: https://app.devin.ai/sessions/b4127fd7a10a4ff49794bf096af5ef7c
Open in Devin Desktop: https://app.devin.ai/desktop/session/b4127fd7a10a4ff49794bf096af5ef7c?variant=devin
Requested by: @mishushakov

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@cla-bot cla-bot Bot added the cla-signed label Oct 20, 2026
@changeset-bot

changeset-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9314a93

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@e2b/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Package Artifacts

Built from 0001f07. Download artifacts from this workflow run.

JS SDK (e2b@2.57.1-devin-1792509319-cli-stream-input.0, with @e2b/dockerfile-utils@0.1.2-devin-1792509319-cli-stream-input.0):

npm install ./e2b-dockerfile-utils-0.1.2-devin-1792509319-cli-stream-input.0.tgz ./e2b-2.57.1-devin-1792509319-cli-stream-input.0.tgz

CLI (@e2b/cli@2.22.3-devin-1792509319-cli-stream-input.0):

npm install ./e2b-cli-2.22.3-devin-1792509319-cli-stream-input.0.tgz

Code Interpreter JS SDK (@e2b/code-interpreter@2.9.1-devin-1792509319-cli-stream-input.0):

npm install ./e2b-code-interpreter-2.9.1-devin-1792509319-cli-stream-input.0.tgz

Desktop JS SDK (@e2b/desktop@2.5.1-devin-1792509319-cli-stream-input.0):

npm install ./e2b-desktop-2.5.1-devin-1792509319-cli-stream-input.0.tgz

Python SDK (e2b==2.57.0+devin.1792509319.cli.stream.input, with e2b-dockerfile-utils==0.1.1+devin.1792509319.cli.stream.input):

pip install ./e2b_dockerfile_utils-0.1.1+devin.1792509319.cli.stream.input-py3-none-any.whl ./e2b-2.57.0+devin.1792509319.cli.stream.input-py3-none-any.whl

Code Interpreter Python SDK (e2b-code-interpreter==2.11.1+devin.1792509319.cli.stream.input):

pip install ./e2b_code_interpreter-2.11.1+devin.1792509319.cli.stream.input-py3-none-any.whl

Desktop Python SDK (e2b-desktop==2.7.0+devin.1792509319.cli.stream.input):

pip install ./e2b_desktop-2.7.0+devin.1792509319.cli.stream.input-py3-none-any.whl

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TASTE.md review: complies, 0 violations. The diff only changes CLI internals (packages/cli/src/terminal.ts) plus a changeset, and uses the SDK's pty.streamInput handle the way it was designed; I checked it against the parity, API-shape, streaming/handle, timeout (T-44 to T-48) and error rules. The streamInput/close() surface comes from the base PR (#1997), so I didn't judge it here.

Written by Devin

@mishushakov
mishushakov added this pull request to stack #2006 October 20, 2026 16:52
@mishushakov
mishushakov force-pushed the devin/1792509319-cli-stream-input branch from d4c35ac to 5732cc7 Compare October 20, 2026 17:15
@mishushakov
mishushakov marked this pull request as ready for review October 20, 2026 17:15
@mishushakov
mishushakov self-requested a review as a code owner October 20, 2026 17:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T17:18:50.472870Z 5732cc7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment thread packages/cli/src/terminal.ts Resolved
Comment thread packages/cli/src/terminal.ts Resolved
Comment thread packages/cli/src/terminal.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5732cc7fe6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/terminal.ts Resolved
claude[bot]

This comment was marked as resolved.

Base automatically changed from devin/1792417976-stream-input to main October 20, 2026 17:24
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
@mishushakov
mishushakov force-pushed the devin/1792509319-cli-stream-input branch from 5732cc7 to 382d6bd Compare October 20, 2026 17:24
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
@mishushakov
mishushakov merged commit a398b08 into main Oct 20, 2026
34 checks passed
@mishushakov
mishushakov deleted the devin/1792509319-cli-stream-input branch October 20, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant