Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add method for sending pty input

Tomas Valentaa447a19bc647
diff --git a/packages/js-sdk/src/sandbox/pty.ts b/packages/js-sdk/src/sandbox/pty.ts
index 882862792..5297d4dc5 100644
--- a/packages/js-sdk/src/sandbox/pty.ts
+++ b/packages/js-sdk/src/sandbox/pty.ts
@@ -82,6 +82,29 @@ export class Pty {
)
}
+ async sendInput(pid: number, data: Uint8Array, opts?: Pick<ConnectionOpts, 'requestTimeoutMs'>): Promise<void> {
+ try {
+ await this.rpc.sendInput({
+ input: {
+ input: {
+ case: 'pty',
+ value: data,
+ },
+ },
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ },
+ },
+ }, {
+ signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
+ })
+ } catch (err) {
+ throw handleRpcError(err)
+ }
+ }
+
async streamInput(pid: number, opts?: Pick<ConnectionOpts, 'requestTimeoutMs'> & { timeout?: number }) {
const requestTimeoutMs = opts?.requestTimeoutMs ?? this.connectionConfig.requestTimeoutMs