Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Export types in TS SDK; [WIP] Python SDK process handling

Tomas Valenta69744145fd1b
diff --git a/packages/js-sdk/src/envd/process/v1/process_pb.ts b/packages/js-sdk/src/envd/process/v1/process_pb.ts
index a6181cee4..c4ffcfd32 100644
--- a/packages/js-sdk/src/envd/process/v1/process_pb.ts
+++ b/packages/js-sdk/src/envd/process/v1/process_pb.ts
@@ -514,6 +514,12 @@ export class ProcessEvent_DataEvent extends Message<ProcessEvent_DataEvent> {
*/
value: Uint8Array;
case: "stderr";
+ } | {
+ /**
+ * @generated from field: bytes pty = 3;
+ */
+ value: Uint8Array;
+ case: "pty";
} | { case: undefined; value?: undefined } = { case: undefined };
constructor(data?: PartialMessage<ProcessEvent_DataEvent>) {
@@ -526,6 +532,7 @@ export class ProcessEvent_DataEvent extends Message<ProcessEvent_DataEvent> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "stdout", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "output" },
{ no: 2, name: "stderr", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "output" },
+ { no: 3, name: "pty", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "output" },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ProcessEvent_DataEvent {
@@ -763,10 +770,10 @@ export class ProcessInput extends Message<ProcessInput> {
case: "stdin";
} | {
/**
- * @generated from field: bytes tty = 2;
+ * @generated from field: bytes pty = 2;
*/
value: Uint8Array;
- case: "tty";
+ case: "pty";
} | { case: undefined; value?: undefined } = { case: undefined };
constructor(data?: PartialMessage<ProcessInput>) {
@@ -778,7 +785,7 @@ export class ProcessInput extends Message<ProcessInput> {
static readonly typeName = "envd.process.v1.ProcessInput";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "stdin", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "input" },
- { no: 2, name: "tty", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "input" },
+ { no: 2, name: "pty", kind: "scalar", T: 12 /* ScalarType.BYTES */, oneof: "input" },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ProcessInput {
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.ts
index 936c3e00a..f639c8bc4 100644
--- a/packages/js-sdk/src/index.ts
+++ b/packages/js-sdk/src/index.ts
@@ -6,6 +6,14 @@ export type { ConnectionOpts } from './connectionConfig'
export { AuthenticationError, SandboxError } from './sandbox/errors'
+export type { FilesystemEvent, EntryInfo, WatchHandle } from './sandbox/filesystem'
+export {
+ EventType,
+ FileType,
+} from './envd/filesystem/v1/filesystem_pb'
+
+export type { ProcessHandle, ProcessResult, ProcessConfig } from './sandbox/process'
+
import { Sandbox } from './sandbox'
export { Sandbox }
diff --git a/packages/js-sdk/src/sandbox/filesystem.ts b/packages/js-sdk/src/sandbox/filesystem.ts
index c7e8fde2b..80697472f 100644
--- a/packages/js-sdk/src/sandbox/filesystem.ts
+++ b/packages/js-sdk/src/sandbox/filesystem.ts
@@ -1,45 +1,85 @@
-import path from 'path-browserify'
-
-import { Logger } from './logger'
-
-export const resolvePath = (
- inputPath: string,
- cwd: string | undefined,
- logger: Logger,
-): string => {
- let result: string
- if (inputPath.startsWith('./')) {
- result = path.posix.join(cwd || '/home/user', inputPath)
- if (!cwd) {
- logger.warn?.(
- `Path starts with './' and cwd isn't set. The path '${inputPath}' will evaluate to '${result}', which may not be what you want.`,
- )
+import { PlainMessage } from '@bufbuild/protobuf'
+import {
+ createPromiseClient,
+ Transport,
+ PromiseClient,
+} from '@connectrpc/connect'
+
+import { FilesystemService } from '../envd/filesystem/v1/filesystem_connect'
+import {
+ FilesystemEvent as FsFilesystemEvent,
+ RemoveRequest,
+ StatRequest,
+ WatchRequest,
+ ListRequest,
+ EntryInfo as FsEntryInfo,
+} from '../envd/filesystem/v1/filesystem_pb'
+
+export type FilesystemEvent = PlainMessage<FsFilesystemEvent>
+export type EntryInfo = PlainMessage<FsEntryInfo>
+
+export interface WatchHandle {
+ stop: () => void
+}
+
+// TODO: Resolve cwd and provide sane defaults
+export class Filesystem {
+ private readonly service: PromiseClient<typeof FilesystemService> = createPromiseClient(FilesystemService, this.transport)
+
+ constructor(private readonly transport: Transport) { }
+
+ async list(path: string): Promise<EntryInfo[]> {
+ const params: PlainMessage<ListRequest> = {
+ path,
}
- return result
+
+ const res = await this.service.list(params)
+ return res.entries
}
- if (inputPath.startsWith('../')) {
- result = path.posix.join(cwd || '/home/user', inputPath)
- if (!cwd) {
- logger.warn?.(
- `Path starts with '../' and cwd isn't set. The path '${inputPath}' will evaluate to '${result}', which may not be what you want.`,
- )
+ async remove(path: string): Promise<void> {
+ const params: PlainMessage<RemoveRequest> = {
+ path,
}
- return result
+
+ await this.service.remove(params)
}
- if (inputPath.startsWith('~/')) {
- result = path.posix.join(cwd || '/home/user', inputPath.substring(2))
- if (!cwd) {
- logger.warn?.(
- `Path starts with '~/' and cwd isn't set. The path '${inputPath}' will evaluate to '${result}', which may not be what you want.`,
- )
+
+ async exists(path: string): Promise<EntryInfo> {
+ const params: PlainMessage<StatRequest> = {
+ path,
}
- return result
- }
- if (!inputPath.startsWith('/') && cwd) {
- return path.posix.join(cwd, inputPath)
+ const res = await this.service.stat(params)
+ return res.entry!
}
- return inputPath
+ async watch(
+ path: string,
+ onEvent: (event: WatchEvent) => any,
+ ): Promise<WatchHandle> {
+ const params: PlainMessage<WatchRequest> = {
+ path,
+ }
+
+ const controller = new AbortController()
+
+ const req = this.service.watch(params, {
+ signal: controller.signal,
+ })
+
+ async function processStream() {
+ for await (const event of req) {
+ if (event.event) {
+ onEvent?.(event.event)
+ }
+ }
+ }
+
+ processStream()
+
+ return {
+ stop: () => controller.abort(),
+ }
+ }
}
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index ace3d5aa1..f687e7ef1 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -1,8 +1,10 @@
import { SandboxApi } from './sandboxApi'
-import { SandboxRpc } from './rpc'
import { Logger } from './logger'
import { SandboxFiles } from './sandboxFiles'
import { ConnectionOpts, ConnectionConfig } from '../connectionConfig'
+import { createConnectTransport } from '@connectrpc/connect-web'
+import { Filesystem } from './filesystem'
+import { Process } from './process'
export interface SandboxOpts extends ConnectionOpts {
/**
@@ -20,9 +22,10 @@ const SANDBOX_SERVER_PORT = 49982
export class Sandbox extends SandboxApi {
protected static readonly defaultTemplate = 'base'
- private readonly connectionConfig: ConnectionConfig
+ readonly filesystem: Filesystem
+ readonly process: Process
- private readonly rpc: SandboxRpc
+ private readonly connectionConfig: ConnectionConfig
private readonly files: SandboxFiles
constructor(readonly sandboxID: string, opts: Omit<SandboxOpts, 'timeout' | 'metadata'> = {}) {
@@ -32,16 +35,11 @@ export class Sandbox extends SandboxApi {
const sandboxServerUrl = `${this.connectionConfig.debug ? 'http' : 'https'}://${this.getHostname(SANDBOX_SERVER_PORT)}`
- this.rpc = new SandboxRpc(sandboxServerUrl)
this.files = new SandboxFiles(sandboxServerUrl)
- }
-
- get filesystem() {
- return this.rpc.filesystem
- }
- get process() {
- return this.rpc.process
+ const rpcTransport = createConnectTransport({ baseUrl: sandboxServerUrl })
+ this.filesystem = new Filesystem(rpcTransport)
+ this.process = new Process(rpcTransport)
}
/**
diff --git a/packages/js-sdk/src/sandbox/path.ts b/packages/js-sdk/src/sandbox/path.ts
new file mode 100644
index 000000000..c7e8fde2b
--- /dev/null
+++ b/packages/js-sdk/src/sandbox/path.ts
@@ -0,0 +1,45 @@
+import path from 'path-browserify'
+
+import { Logger } from './logger'
+
+export const resolvePath = (
+ inputPath: string,
+ cwd: string | undefined,
+ logger: Logger,
+): string => {
+ let result: string
+ if (inputPath.startsWith('./')) {
+ result = path.posix.join(cwd || '/home/user', inputPath)
+ if (!cwd) {
+ logger.warn?.(
+ `Path starts with './' and cwd isn't set. The path '${inputPath}' will evaluate to '${result}', which may not be what you want.`,
+ )
+ }
+ return result
+ }
+
+ if (inputPath.startsWith('../')) {
+ result = path.posix.join(cwd || '/home/user', inputPath)
+ if (!cwd) {
+ logger.warn?.(
+ `Path starts with '../' and cwd isn't set. The path '${inputPath}' will evaluate to '${result}', which may not be what you want.`,
+ )
+ }
+ return result
+ }
+ if (inputPath.startsWith('~/')) {
+ result = path.posix.join(cwd || '/home/user', inputPath.substring(2))
+ if (!cwd) {
+ logger.warn?.(
+ `Path starts with '~/' and cwd isn't set. The path '${inputPath}' will evaluate to '${result}', which may not be what you want.`,
+ )
+ }
+ return result
+ }
+
+ if (!inputPath.startsWith('/') && cwd) {
+ return path.posix.join(cwd, inputPath)
+ }
+
+ return inputPath
+}
diff --git a/packages/js-sdk/src/sandbox/process.ts b/packages/js-sdk/src/sandbox/process.ts
index 0f8c495bc..cdc4a441c 100644
--- a/packages/js-sdk/src/sandbox/process.ts
+++ b/packages/js-sdk/src/sandbox/process.ts
@@ -1,198 +1,353 @@
-import { EnvVars } from './envVars'
-import { CallOpts, SandboxConnection } from './sandboxConnection'
-import { withTimeout } from './promise'
-
-export const processService = 'process'
-
-/**
- * A message from a process.
- */
-export class ProcessMessage {
- constructor(
- public readonly line: string,
- /**
- * Unix epoch in nanoseconds
- */
- public readonly timestamp: number,
- public readonly error: boolean,
- ) {
- }
+import { PlainMessage } from '@bufbuild/protobuf'
+import {
+ createPromiseClient,
+ PromiseClient,
+ Transport,
+} from '@connectrpc/connect'
- public toString() {
- return this.line
- }
+import { ProcessService } from '../envd/process/v1/process_connect'
+import {
+ ProcessConfig as PsProcessConfig,
+ ProcessEvent_EndEvent,
+ ProcessEvent_StartEvent,
+ ConnectResponse,
+ ConnectRequest,
+ SendInputRequest,
+ StreamInputRequest,
+ Signal,
+ StartRequest,
+ StartResponse,
+ UpdateRequest,
+} from '../envd/process/v1/process_pb'
+import { concatUint8Arrays } from './array'
+import { createDeferredPromise } from './promise'
+
+export interface ProcessHandle {
+ pid: number
+ disconnect: () => void
+ wait: () => Promise<ProcessResult>
+ kill: () => Promise<void>
}
-/**
- * Output from a process.
- */
-export class ProcessOutput {
- private readonly delimiter = '\n'
- private readonly messages: ProcessMessage[] = []
- private _finished = false
+export interface ProcessResult {
+ stdout: string
+ stderr: string
+ exitCode: number
+ error?: string
+}
+
+export type ProcessConfig = PlainMessage<PsProcessConfig>
- private _error = false
+// TODO: Sane defaults
+// TODO: Add timeout to wait
+// TODO: How to handle start + wait
+// TODO: Move cwd resolution to envd?
+// TODO: Should cwd be calculated in envd?
+// TODO: More optional fields?
+// TODO: Add req timeout
+export class Process {
+ private readonly service: PromiseClient<typeof ProcessService> = createPromiseClient(ProcessService, this.transport)
- private _exitCode?: number
+ constructor(private readonly transport: Transport) { }
- /**
- * Whether the process has errored.
- */
- get error(): boolean {
- return this._error
+ async list(): Promise<ProcessConfig[]> {
+ const res = await this.service.list({})
+ return res.processes
}
+ async start(
+ cmd: string,
+ {
+ cwd,
+ user,
+ envs,
+ onStderr,
+ onStdout,
+ }: {
+ cwd?: string,
+ user?: string,
+ envs?: Record<string, string>,
+ onStdout?: (data: string) => any,
+ onStderr?: (data: string) => any,
+ }
+ ): Promise<ProcessHandle> {
+ const params: PlainMessage<StartRequest> = {
+ owner: {
+ credential: {
+ case: 'username',
+ value: user || 'user',
+ },
+ },
+ process: {
+ cmd: '/bin/bash',
+ cwd: cwd || '/',
+ envs: envs || {},
+ args: ['-c', '-l', cmd],
+ },
+ }
+
+ const controller = new AbortController()
+
+ const events = this.service.start(params, {
+ signal: controller.signal,
+ })
+
+ const {
+ start,
+ wait,
+ } = await this.handleProcessEvents(events, {
+ onStdout,
+ onStderr,
+ })
+
+ const startEvent = await start
- /**
- * The exit code of the process.
- */
- get exitCode(): number | undefined {
- if (!this._finished) {
- throw new Error('Process has not finished yet')
+ return {
+ pid: startEvent.pid,
+ disconnect: () => controller.abort(),
+ wait,
+ kill: () => this.kill(startEvent.pid),
}
- return this._exitCode
}
- /**
- * The stdout from the process.
- */
- get stdout(): string {
- return this.messages
- .filter((out) => !out.error)
- .map((out) => out.line)
- .join(this.delimiter)
- }
+ async connect(
+ pid: number,
+ {
+ onStderr,
+ onStdout,
+ }: {
+ onStdout?: (data: string) => any,
+ onStderr?: (data: string) => any,
+ }
+ ): Promise<ProcessHandle> {
+ const params: PlainMessage<ConnectRequest> = {
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ }
+ },
+ }
+ const controller = new AbortController()
- /**
- * The stderr from the process.
- */
- get stderr(): string {
- return this.messages
- .filter((out) => out.error)
- .map((out) => out.line)
- .join(this.delimiter)
- }
+ const events = this.service.connect(params, {
+ signal: controller.signal,
+ })
- addStdout(message: ProcessMessage) {
- this.insertByTimestamp(message)
- }
+ const {
+ wait,
+ } = await this.handleProcessEvents(events, {
+ onStdout,
+ onStderr,
+ })
- addStderr(message: ProcessMessage) {
- this._error = true
- this.insertByTimestamp(message)
+ return {
+ pid,
+ disconnect: () => controller.abort(),
+ wait,
+ kill: () => this.kill(pid),
+ }
}
- setExitCode(exitCode: number) {
- this._exitCode = exitCode
- this._finished = true
+ async kill(pid: number): Promise<void> {
+ await this.service.sendSignal({
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ }
+ },
+ signal: Signal.SIGKILL,
+ })
}
- private insertByTimestamp(message: ProcessMessage) {
- let i = this.messages.length - 1
- while (i >= 0 && this.messages[i].timestamp > message.timestamp) {
- i -= 1
+ async sendStdin(pid: number, data: Uint8Array): Promise<void> {
+ const params: PlainMessage<SendInputRequest> = {
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ }
+ },
+ input: {
+ input: {
+ case: 'stdin',
+ value: data,
+ },
+ },
}
- this.messages.splice(i + 1, 0, message)
- }
-}
-/**
- * A process running in the sandbox.
- */
-export class Process {
- /**
- * @deprecated use .wait() instead
- */
- readonly finished: Promise<ProcessOutput>
-
- constructor(
- readonly processID: string,
- private readonly sandbox: SandboxConnection,
- private readonly triggerExit: () => void,
- finished: Promise<ProcessOutput>,
- readonly output: ProcessOutput,
- ) {
- this.finished = finished
+ await this.service.sendInput(params)
}
- /**
- * Kills the process.
- */
- async kill(): Promise<void> {
- try {
- await this.sandbox._call(processService, 'kill', [this.processID])
- } finally {
- this.triggerExit()
- await this.finished
+ async startTerminal({ cols, rows, onData }: {
+ cols: number,
+ rows: number,
+ onData: (data: Uint8Array) => any,
+ }): Promise<void> {
+ const params: PlainMessage<StartRequest> = {
+ owner: {
+ credential: {
+ case: 'username',
+ value: 'user',
+ },
+ },
+ process: {
+ cmd: '/bin/bash',
+ cwd: '/',
+ envs: {},
+ args: ['-l'],
+ },
+ pty: {
+ size: {
+ cols,
+ rows,
+ },
+ },
}
+
+ const start = createDeferredPromise<ProcessEvent_StartEvent>()
+ const end = createDeferredPromise<ProcessEvent_EndEvent>()
+
+ const stream = this.service.start(params)
+
+ async function processStream() {
+ try {
+ for await (const event of stream) {
+ switch (event.event?.event.case) {
+ case 'start':
+ start.resolve(event.event.event.value)
+ break
+ case 'data':
+ switch (event.event.event.value.output.case) {
+ case 'pty':
+ onData(event.event.event.value.output.value)
+ break
+ }
+ break
+ case 'end':
+ end.resolve(event.event.event.value)
+ break
+ }
+
+ }
+ } catch (error) {
+ start.reject(error)
+ end.reject(error)
+ }
+ }
+
+ processStream()
+
+ const startEvent = await start.promise
+
+
+ return
+
}
- /**
- * Waits for the process to finish.
- *
- * @param timeout Timeout for the process to finish in milliseconds
- */
- async wait(timeout?: number): Promise<ProcessOutput> {
- return await withTimeout(() => this.finished, timeout)()
+ private async resizeTerminal(pid: number, size: {
+ cols: number,
+ rows: number,
+ }): Promise<void> {
+ const params: PlainMessage<UpdateRequest> = {
+ process: {
+ selector: {
+ case: 'pid',
+ value: pid,
+ }
+ },
+ pty: {
+ size,
+ },
+ }
+
+ await this.service.update(params)
}
- /**
- * Sends data to the process stdin.
- *
- * @param data Data to send
- * @param opts Call options
- * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)
- */
- async sendStdin(data: string, opts?: CallOpts): Promise<void> {
- await this.sandbox._call(
- processService,
- 'stdin',
- [this.processID, data],
- opts,
- )
+ private async streamTerminalInput(params: AsyncIterable<PlainMessage<StreamInputRequest>>) {
+ const controller = new AbortController()
+
+ this.service.streamInput(params, {
+ signal: controller.signal,
+ })
+
+ return {
+ stop: () => controller.abort(),
+ }
}
-}
-export interface ProcessOpts {
- cmd: string;
- onStdout?: (out: ProcessMessage) => Promise<void> | void;
- onStderr?: (out: ProcessMessage) => Promise<void> | void;
- onExit?: (() => Promise<void> | void) | ((exitCode: number) => Promise<void> | void);
- envVars?: EnvVars;
- cwd?: string;
- /** @deprecated Use cwd instead */
- rootDir?: string;
- processID?: string;
- /** Timeout for the process to start in milliseconds */
- timeout?: number;
-}
+ private async handleProcessEvents(
+ events: AsyncIterable<StartResponse | ConnectResponse>,
+ {
+ onStderr,
+ onStdout,
+ }: {
+ onStdout?: (data: string) => any,
+ onStderr?: (data: string) => any,
+ }
+ ) {
+ const start = createDeferredPromise<ProcessEvent_StartEvent>()
+ const end = createDeferredPromise<{
+ exit: ProcessEvent_EndEvent,
+ stdout: Uint8Array[],
+ stderr: Uint8Array[],
+ }>()
+
+ async function processStream() {
+ const stdout: Uint8Array[] = []
+ const stderr: Uint8Array[] = []
-/**
- * Manager for starting and interacting with processes in the sandbox.
- */
-export interface ProcessManager {
- /**
- * Starts a new process.
- * @param cmd Command to execute
- * @returns New process
- */
- start(cmd: string): Promise<Process>;
- /**
- * Starts a new process.
- * @param opts Process options
- * @returns New process
- */
- start(opts: ProcessOpts): Promise<Process>;
- /**
- * Starts a new process and wait until it finishes.
- * @param cmd Command to execute
- * @returns New process
- */
- startAndWait(cmd: string): Promise<ProcessOutput>;
- /**
- * Starts a new process and wait until it finishes.
- * @param opts Process options
- * @returns New process
- */
- startAndWait(opts: ProcessOpts): Promise<ProcessOutput>;
+ try {
+ for await (const event of events) {
+ switch (event.event?.event.case) {
+ case 'start':
+ start.resolve(event.event.event.value)
+ break
+ case 'data':
+ switch (event.event.event.value.output.case) {
+ case 'stdout':
+ stdout.push(event.event.event.value.output.value)
+ onStdout?.(event.event.event.value.output.value.toString())
+ break
+ case 'stderr':
+ stderr.push(event.event.event.value.output.value)
+ onStderr?.(event.event.event.value.output.value.toString())
+ break
+ }
+ break
+ case 'end':
+ end.resolve({
+ exit: event.event.event.value,
+ stdout,
+ stderr,
+ })
+ break
+ }
+
+ }
+ } catch (error) {
+ start.reject(error)
+ end.reject(error)
+ }
+ }
+
+ processStream()
+
+ return {
+ start: start.promise,
+ wait: async () => {
+ const { exit, stdout, stderr } = await end.promise
+ return {
+ ...exit,
+ get stdout() {
+ return concatUint8Arrays(stdout).toString()
+ },
+ get stderr() {
+ return concatUint8Arrays(stderr).toString()
+ },
+ }
+ },
+ }
+ }
}
diff --git a/packages/js-sdk/src/sandbox/rpc/filesystem.ts b/packages/js-sdk/src/sandbox/rpc/filesystem.ts
deleted file mode 100644
index 246614c50..000000000
--- a/packages/js-sdk/src/sandbox/rpc/filesystem.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { PlainMessage } from '@bufbuild/protobuf'
-import {
- createPromiseClient,
- Transport,
- PromiseClient,
-} from '@connectrpc/connect'
-
-import { FilesystemService } from '../../envd/filesystem/v1/filesystem_connect'
-import {
- FilesystemEvent,
- RemoveRequest,
- StatRequest,
- StatResponse,
- ListRequest,
- ListResponse,
- WatchRequest,
-} from '../../envd/filesystem/v1/filesystem_pb'
-
-// TODO: Resolve cwd and provide sane defaults
-export class Filesystem {
- private readonly service: PromiseClient<typeof FilesystemService> = createPromiseClient(FilesystemService, this.transport)
-
- constructor(private readonly transport: Transport) { }
-
- async list(params: PlainMessage<ListRequest>): Promise<ListResponse['entries']> {
- const res = await this.service.list(params)
- return res.entries
- }
-
- async remove(params: PlainMessage<RemoveRequest>): Promise<void> {
- await this.service.remove(params)
- }
-
- async exists(params: PlainMessage<StatRequest>): Promise<StatResponse['entry']> {
- const res = await this.service.stat(params)
- return res.entry
- }
-
- async watch(
- params: PlainMessage<WatchRequest>,
- {
- onEvent,
- }: {
- onEvent?: (event: PlainMessage<FilesystemEvent>) => any,
- }
- ): Promise<{ stop: () => void }> {
- const controller = new AbortController()
-
- const req = this.service.watch(params, {
- signal: controller.signal,
- })
-
- async function processStream() {
- for await (const event of req) {
- if (event.event) {
- onEvent?.(event.event)
- }
- }
- }
-
- processStream()
-
- return {
- stop: () => controller.abort(),
- }
- }
-}
diff --git a/packages/js-sdk/src/sandbox/rpc/index.ts b/packages/js-sdk/src/sandbox/rpc/index.ts
deleted file mode 100644
index 70707d34c..000000000
--- a/packages/js-sdk/src/sandbox/rpc/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Transport } from '@connectrpc/connect'
-import { createConnectTransport } from '@connectrpc/connect-web'
-
-import { Filesystem } from './filesystem'
-import { Process } from './process'
-
-export class SandboxRpc {
- readonly filesystem: Filesystem
- readonly process: Process
-
- private readonly transport: Transport
-
- constructor(baseUrl: string) {
- this.transport = createConnectTransport({
- baseUrl,
- })
-
- this.filesystem = new Filesystem(this.transport)
- this.process = new Process(this.transport)
- }
-}
diff --git a/packages/js-sdk/src/sandbox/rpc/process.ts b/packages/js-sdk/src/sandbox/rpc/process.ts
deleted file mode 100644
index 7101f459f..000000000
--- a/packages/js-sdk/src/sandbox/rpc/process.ts
+++ /dev/null
@@ -1,218 +0,0 @@
-import { PlainMessage } from '@bufbuild/protobuf'
-import {
- createPromiseClient,
- PromiseClient,
- Transport,
-} from '@connectrpc/connect'
-
-import { ProcessService } from '../../envd/process/v1/process_connect'
-import {
- ListRequest,
- ListResponse,
- ProcessEvent_EndEvent,
- ProcessEvent_StartEvent,
- ConnectRequest,
- ConnectResponse,
- SendInputRequest,
- StreamInputRequest,
- SendSignalRequest,
- Signal,
- StartRequest,
- StartResponse,
- UpdateRequest,
-} from '../../envd/process/v1/process_pb'
-import { concatUint8Arrays } from '../array'
-import { createDeferredPromise } from '../promise'
-
-// TODO: Sane defaults
-// TODO: Reconnect vs connect
-// TODO: Add timeout to wait
-// TODO: How to handle start + wait
-// TODO: Move cwd resolution to envd?
-export class Process {
- private readonly service: PromiseClient<typeof ProcessService> = createPromiseClient(ProcessService, this.transport)
-
- constructor(private readonly transport: Transport) { }
-
- async list(params: PlainMessage<ListRequest>): Promise<ListResponse['processes']> {
- const res = await this.service.list(params)
- return res.processes
- }
-
- async start(
- params: PlainMessage<StartRequest>,
- {
- onStderr,
- onStdout,
- }: {
- onStdout?: (data: string) => any,
- onStderr?: (data: string) => any,
- }
- ) {
- const controller = new AbortController()
-
- const res = this.service.start(params, {
- signal: controller.signal,
- })
-
- const {
- start,
- wait,
- } = await this.handleProcessStream(res, {
- onStdout,
- onStderr,
- })
-
- const startEvent = await start
-
- return {
- pid: startEvent.pid,
- disconnect: () => controller.abort(),
- wait,
- kill: () => this.sendSignal({
- process: {
- selector: {
- case: 'pid',
- value: startEvent.pid,
- }
- },
- signal: Signal.SIGKILL,
- }),
- }
- }
-
- private async handleProcessStream(
- stream: AsyncIterable<StartResponse | ConnectResponse>,
- {
- onStderr,
- onStdout,
- }: {
- onStdout?: (data: string) => any,
- onStderr?: (data: string) => any,
- }
- ) {
- const start = createDeferredPromise<ProcessEvent_StartEvent>()
- const exit = createDeferredPromise<ProcessEvent_EndEvent>()
-
- const stdout: Uint8Array[] = []
- const stderr: Uint8Array[] = []
-
- async function processStream() {
- try {
- for await (const event of stream) {
- switch (event.event?.event.case) {
- case 'start':
- start.resolve(event.event.event.value)
- break
- case 'data':
- switch (event.event.event.value.output.case) {
- case 'stdout':
- stdout.push(event.event.event.value.output.value)
- onStdout?.(event.event.event.value.output.value.toString())
- break
- case 'stderr':
- stderr.push(event.event.event.value.output.value)
- onStderr?.(event.event.event.value.output.value.toString())
- break
- }
- break
- case 'end':
- exit.resolve(event.event.event.value)
- break
- }
-
- }
- } catch (error) {
- start.reject(error)
- exit.reject(error)
- }
- }
-
- processStream()
-
- return {
- start: start.promise,
- wait: async () => {
- const result = await exit.promise
- return {
- ...result,
- get stdout() {
- return concatUint8Arrays(stdout).toString()
- },
- get stderr() {
- return concatUint8Arrays(stderr).toString()
- },
- }
- },
- }
- }
-
- private async connect(
- params: PlainMessage<ConnectRequest>,
- {
- onStderr,
- onStdout,
- }: {
- onStdout?: (data: string) => any,
- onStderr?: (data: string) => any,
- }
- ) {
- const pid = params.process?.selector.case === 'pid' ? params.process?.selector.value : undefined
-
- if (pid === undefined) {
- throw new Error('Invalid process PID')
- }
-
- const controller = new AbortController()
-
- const res = this.service.connect(params, {
- signal: controller.signal,
- })
-
- const {
- wait,
- } = await this.handleProcessStream(res, {
- onStdout,
- onStderr,
- })
-
- return {
- pid,
- disconnect: () => controller.abort(),
- wait,
- kill: () => this.sendSignal({
- process: {
- selector: {
- case: 'pid',
- value: pid,
- }
- },
- signal: Signal.SIGKILL,
- }),
- }
- }
-
- private async sendSignal(params: PlainMessage<SendSignalRequest>): Promise<void> {
- await this.service.sendSignal(params)
- }
-
- private async sendInput(params: PlainMessage<SendInputRequest>): Promise<void> {
- await this.service.sendInput(params)
- }
-
- private async update(params: PlainMessage<UpdateRequest>): Promise<void> {
- await this.service.update(params)
- }
-
- private async streamInput(params: AsyncIterable<PlainMessage<StreamInputRequest>>) {
- const controller = new AbortController()
-
- this.service.streamInput(params, {
- signal: controller.signal,
- })
-
- return {
- stop: () => controller.abort(),
- }
- }
-}
diff --git a/packages/js-sdk/src/sandbox/terminal.ts b/packages/js-sdk/src/sandbox/terminal.ts
deleted file mode 100644
index a800ec5eb..000000000
--- a/packages/js-sdk/src/sandbox/terminal.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-import { EnvVars } from './envVars'
-import { SandboxConnection } from './sandboxConnection'
-
-export const terminalService = 'terminal'
-
-export class TerminalOutput {
- private _data = ''
-
- get data() {
- return this._data
- }
-
- addData(data: string) {
- this._data += data
- }
-}
-
-/**
- * A terminal session running in the sandbox.
- *
- */
-export class Terminal {
- /**
- * @deprecated use .wait() instead
- */
- readonly finished: Promise<TerminalOutput>
-
- constructor(
- readonly terminalID: string,
- private readonly sandbox: SandboxConnection,
- private readonly triggerExit: () => void,
- finished: Promise<TerminalOutput>,
- readonly output: TerminalOutput,
- ) {
- this.finished = finished
- }
-
- get data() {
- return this.output.data
- }
-
- /**
- * Kills the terminal session.
- */
- async kill(): Promise<void> {
- try {
- // TODO: Change the "destroy" to "kill" in devbookd
- await this.sandbox._call(terminalService, 'destroy', [this.terminalID])
- } finally {
- this.triggerExit()
- await this.finished
- }
- }
-
- /**
- * Waits for the terminal to finish.
- */
- async wait(): Promise<TerminalOutput> {
- return this.finished
- }
-
- /**
- * Sends data to the terminal standard input.
- *
- * @param data Data to send
- */
- async sendData(data: string): Promise<void> {
- await this.sandbox._call(terminalService, 'data', [this.terminalID, data])
- }
-
- /**
- * Resizes the terminal tty.
- *
- * @param cols Number of columns
- * @param rows Number of rows
- */
- async resize({ cols, rows }: { cols: number; rows: number }): Promise<void> {
- await this.sandbox._call(terminalService, 'resize', [
- this.terminalID,
- cols,
- rows,
- ])
- }
-}
-
-export type TerminalOpts = {
- onData: (data: string) => Promise<void> | void;
- onExit?: () => Promise<void> | void;
- size: { cols: number; rows: number };
- terminalID?: string;
- /**
- * If the `cmd` parameter is defined it will be executed as a command
- * and this terminal session will exit when the command exits.
- */
- cmd?: string;
- /**
- * Working directory where will the terminal start.
- */
- cwd?: string;
- /**
- * @deprecated use cwd instead
- */
- rootDir?: string;
- /**
- * Environment variables that will be accessible inside of the terminal.
- */
- envVars?: EnvVars;
- /**
- * Timeout for terminal start in milliseconds (default is 60 seconds)
- */
- timeout?: number;
-}
-
-/**
- * Manager for starting and interacting with terminal sessions in the sandbox.
- */
-export interface TerminalManager {
- start(opts: TerminalOpts): Promise<Terminal>;
-}
diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.py
index 3bed12e77..6d28c8052 100644
--- a/packages/python-sdk/e2b/__init__.py
+++ b/packages/python-sdk/e2b/__init__.py
@@ -9,12 +9,12 @@ environments. In these environments, large language models can use the same
tools as humans do.
"""
+from envd.filesystem.v1.filesystem_pb2 import FilesystemEvent, FileType, EntryInfo
from .api import (
E2BApiClient,
client,
)
from .connection_config import ConnectionConfig
-from .sandbox import (
- Sandbox,
-)
+from .sandbox.main import Sandbox
from .sandbox.exceptions import SandboxException, AuthenticationException
+from .sandbox.process import ProcessHandle, ProcessOutput, ProcessResult
diff --git a/packages/python-sdk/e2b/sandbox/__init__.py b/packages/python-sdk/e2b/sandbox/__init__.py
deleted file mode 100644
index 919f42e3f..000000000
--- a/packages/python-sdk/e2b/sandbox/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from .main import Sandbox
diff --git a/packages/python-sdk/e2b/sandbox/_process.py b/packages/python-sdk/e2b/sandbox/_process.py
new file mode 100644
index 000000000..43ef71b16
--- /dev/null
+++ b/packages/python-sdk/e2b/sandbox/_process.py
@@ -0,0 +1,429 @@
+# from __future__ import annotations
+
+# import logging
+# import re
+# import inspect
+# import threading
+# import time
+# from concurrent.futures import Future
+# from typing import (
+# Any,
+# Callable,
+# ClassVar,
+# Dict,
+# List,
+# Optional,
+# Union,
+# )
+# from pydantic import BaseModel
+
+# from e2b.constants import TIMEOUT
+# from e2b.sandbox.env_vars import EnvVars
+# from e2b.exceptions import (
+# MultipleExceptions,
+# ProcessException,
+# RpcException,
+# CurrentWorkingDirectoryDoesntExistException,
+# TimeoutException,
+# )
+# from e2b.sandbox.out import OutStderrResponse, OutStdoutResponse
+# from e2b.sandbox.sandbox_connection import SandboxConnection, SubscriptionArgs
+# from e2b.utils.id import create_id
+
+# logger = logging.getLogger(__name__)
+
+
+# class ProcessMessage(BaseModel):
+# """
+# A message from a process.
+# """
+
+# line: str
+# error: bool = False
+# timestamp: int
+# """
+# Unix epoch in nanoseconds
+# """
+
+# def __str__(self):
+# return self.line
+
+
+# class ProcessOutput(BaseModel):
+# """
+# Output from a process.
+# """
+
+# delimiter: ClassVar[str] = "\n"
+# messages: List[ProcessMessage] = []
+
+# error: bool = False
+# exit_code: Optional[int] = None
+
+# @property
+# def stdout(self) -> str:
+# """
+# The stdout from the process.
+# """
+# return self.delimiter.join(out.line for out in self.messages if not out.error)
+
+# @property
+# def stderr(self) -> str:
+# """
+# The stderr from the process.
+# """
+# return self.delimiter.join(out.line for out in self.messages if out.error)
+
+# def _insert_by_timestamp(self, message: ProcessMessage):
+# """Insert an out based on its timestamp using insertion sort."""
+# i = len(self.messages) - 1
+# while i >= 0 and self.messages[i].timestamp > message.timestamp:
+# i -= 1
+# self.messages.insert(i + 1, message)
+
+# def _add_stdout(self, message: ProcessMessage):
+# self._insert_by_timestamp(message)
+
+# def _add_stderr(self, message: ProcessMessage):
+# self.error = True
+# self._insert_by_timestamp(message)
+
+
+# class Process:
+# """
+# A process running in the sandbox.
+# """
+
+# def __init__(
+# self,
+# process_id: str,
+# sandbox: SandboxConnection,
+# trigger_exit: Callable[[], Any],
+# finished: Future[ProcessOutput],
+# output: ProcessOutput,
+# ):
+# self._process_id = process_id
+# self._sandbox = sandbox
+# self._trigger_exit = trigger_exit
+# self._finished = finished
+# self._output = output
+
+# @property
+# def exit_code(self) -> Optional[int]:
+# """
+# The exit code of the last process started by this manager.
+# """
+# if not self.finished:
+# raise ProcessException("Process has not finished yet")
+# return self.output.exit_code
+
+# @property
+# def output(self) -> ProcessOutput:
+# """
+# The output from the process.
+# """
+# return self._output
+
+# @property
+# def stdout(self) -> str:
+# """
+# The stdout from the process.
+# """
+# return self._output.stdout
+
+# @property
+# def stderr(self) -> str:
+# """
+# The stderr from the process.
+# """
+# return self._output.stderr
+
+# @property
+# def error(self) -> bool:
+# """
+# True if the process has written to stderr.
+# """
+# return self._output.error
+
+# @property
+# def output_messages(self) -> List[ProcessMessage]:
+# """
+# The output messages from the process.
+# """
+# return self._output.messages
+
+# @property
+# def finished(self):
+# """
+# A future that is resolved when the process exits.
+# """
+# return self._finished
+
+# @property
+# def process_id(self) -> str:
+# """
+# The process id used to identify the process in the sandbox.
+# This is not the system process id of the process running in the sandbox.
+# """
+# return self._process_id
+
+# def wait(self, timeout: Optional[float] = None) -> ProcessOutput:
+# """
+# Wait for the process to exit.
+
+# :param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out. If set to None, the method will continue to wait until it completes, regardless of time
+# """
+# start_time = time.time()
+# while timeout is None or time.time() - start_time < timeout:
+# if self._finished.done():
+# return self._finished.result()
+# time.sleep(0.1)
+# if not self._sandbox.is_open:
+# break
+
+# raise TimeoutException(f"Process did not finish within {timeout} seconds")
+
+# def send_stdin(self, data: str, timeout: Optional[float] = TIMEOUT) -> None:
+# """
+# Send data to the process stdin.
+
+# :param data: Data to send
+# :param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time
+# """
+# try:
+# self._sandbox._call(
+# ProcessManager._service_name,
+# "stdin",
+# [self.process_id, data],
+# timeout=timeout,
+# )
+# except RpcException as e:
+# raise ProcessException(e.message) from e
+
+# def kill(self, timeout: Optional[float] = TIMEOUT) -> None:
+# """
+# Kill the process.
+
+# :param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time
+# """
+# try:
+# self._sandbox._call(
+# ProcessManager._service_name, "kill", [self.process_id], timeout=timeout
+# )
+# except RpcException as e:
+# raise ProcessException(e.message) from e
+# self._trigger_exit()
+
+
+# class ProcessManager:
+# """
+# Manager for starting and interacting with processes in the sandbox.
+# """
+
+# _service_name = "process"
+
+# def __init__(
+# self,
+# sandbox: SandboxConnection,
+# on_stdout: Optional[Callable[[ProcessMessage], Any]] = None,
+# on_stderr: Optional[Callable[[ProcessMessage], Any]] = None,
+# on_exit: Optional[Union[Callable[[int], Any], Callable[[], Any]]] = None,
+# ):
+# self._sandbox = sandbox
+# self._process_cleanup: List[Callable[[], Any]] = []
+# self._on_stdout = on_stdout
+# self._on_stderr = on_stderr
+# self._on_exit = on_exit
+
+# def start(
+# self,
+# cmd: str,
+# on_stdout: Optional[Callable[[ProcessMessage], Any]] = None,
+# on_stderr: Optional[Callable[[ProcessMessage], Any]] = None,
+# on_exit: Optional[Union[Callable[[int], Any], Callable[[], Any]]] = None,
+# env_vars: Optional[EnvVars] = None,
+# cwd: str = "",
+# rootdir: str = "", # DEPRECATED
+# process_id: Optional[str] = None,
+# timeout: Optional[float] = TIMEOUT,
+# ) -> Process:
+# logger.info(f"Starting process: {cmd}")
+# env_vars = env_vars or {}
+# env_vars = {**self._sandbox.env_vars, **env_vars}
+
+# on_stdout = on_stdout or self._on_stdout
+# on_stderr = on_stderr or self._on_stderr
+# on_exit = on_exit or self._on_exit
+
+# future_exit = Future()
+# process_id = process_id or create_id(12)
+
+# unsub_all: Optional[Callable] = None
+
+# output = ProcessOutput()
+
+# def handle_exit(exit_code: int):
+# output.exit_code = exit_code
+# logger.info(f"Process {process_id} exited with exit code {exit_code}")
+# if not future_exit.done():
+# future_exit.set_result(True)
+
+# def handle_stdout(data: Dict[Any, Any]):
+# out = OutStdoutResponse(**data)
+
+# message = ProcessMessage(
+# line=out.line,
+# timestamp=out.timestamp,
+# error=False,
+# )
+
+# output._add_stdout(message)
+# if on_stdout:
+# try:
+# on_stdout(message)
+# except TypeError as error:
+# logger.exception(f"Error in on_stdout callback: {error}")
+
+# def handle_stderr(data: Dict[Any, Any]):
+# out = OutStderrResponse(**data)
+
+# message = ProcessMessage(
+# line=out.line,
+# timestamp=out.timestamp,
+# error=True,
+# )
+
+# output._add_stderr(message)
+# if on_stderr:
+# try:
+# on_stderr(message)
+# except TypeError as error:
+# logger.exception(f"Error in on_stdout callback: {error}")
+
+# try:
+# subscription_args = [
+# SubscriptionArgs(
+# service=self._service_name,
+# handler=handle_exit,
+# method="onExit",
+# params=[process_id],
+# ),
+# SubscriptionArgs(
+# service=self._service_name,
+# handler=handle_stdout,
+# method="onStdout",
+# params=[process_id],
+# ),
+# SubscriptionArgs(
+# service=self._service_name,
+# handler=handle_stderr,
+# method="onStderr",
+# params=[process_id],
+# ),
+# ]
+# unsub_all = self._sandbox._handle_subscriptions(*subscription_args)
+
+# except (RpcException, MultipleExceptions) as e:
+# future_exit.cancel()
+
+# if isinstance(e, RpcException):
+# raise ProcessException(e.message) from e
+# elif isinstance(e, MultipleExceptions):
+# raise ProcessException(
+# "Failed to subscribe to RPC services necessary for starting process"
+# ) from e
+
+# future_exit_handler_finish: Future[ProcessOutput] = Future()
+
+# def exit_handler():
+# future_exit.result()
+# logger.info(f"Handling process exit (id: {process_id})")
+# if unsub_all:
+# unsub_all()
+# if on_exit:
+# sig = inspect.signature(on_exit)
+# params = sig.parameters.values()
+# try:
+# if len(params) == 0:
+# on_exit()
+# else:
+# on_exit(output.exit_code or 0)
+# except TypeError as error:
+# logger.exception(f"Error in on_exit callback: {error}")
+# future_exit_handler_finish.set_result(output)
+
+# threading.Thread(
+# name="e2b-process-exit-handler", daemon=True, target=exit_handler
+# ).start()
+
+# def trigger_exit():
+# logger.info(f"Exiting the process (id: {process_id})")
+# if not future_exit.done():
+# future_exit.set_result(None)
+
+# future_exit_handler_finish.result()
+# logger.debug(f"Exited the process (id: {process_id})")
+
+# try:
+# if not cwd and rootdir:
+# cwd = rootdir
+# logger.warning("The rootdir parameter is deprecated, use cwd instead.")
+
+# if not cwd and self._sandbox.cwd:
+# cwd = self._sandbox.cwd
+
+# self._sandbox._call(
+# self._service_name,
+# "start",
+# [
+# process_id,
+# cmd,
+# env_vars,
+# cwd,
+# ],
+# timeout=timeout,
+# )
+# logger.info(f"Started process (id: {process_id})")
+# return Process(
+# output=output,
+# sandbox=self._sandbox,
+# process_id=process_id,
+# trigger_exit=trigger_exit,
+# finished=future_exit_handler_finish,
+# )
+# except RpcException as e:
+# trigger_exit()
+# if re.match(
+# r"error starting process '\w+': fork/exec /bin/bash: no such file or directory",
+# e.message,
+# ):
+# raise CurrentWorkingDirectoryDoesntExistException(
+# "Failed to start the process. You are trying set `cwd` to a directory that does not exist."
+# ) from e
+# raise ProcessException(e.message) from e
+# except TimeoutError as e:
+# logger.error(f"Timeout error during starting the process: {cmd}")
+# trigger_exit()
+# raise e
+
+# def start_and_wait(
+# self,
+# cmd: str,
+# on_stdout: Optional[Callable[[ProcessMessage], Any]] = None,
+# on_stderr: Optional[Callable[[ProcessMessage], Any]] = None,
+# on_exit: Optional[Callable[[int], Any]] = None,
+# env_vars: Optional[EnvVars] = None,
+# cwd: str = "",
+# process_id: Optional[str] = None,
+# timeout: Optional[float] = TIMEOUT,
+# ) -> ProcessOutput:
+# return self.start(
+# cmd,
+# on_stdout=on_stdout,
+# on_stderr=on_stderr,
+# on_exit=on_exit,
+# env_vars=env_vars,
+# cwd=cwd,
+# process_id=process_id,
+# timeout=timeout,
+# ).wait()
diff --git a/packages/python-sdk/e2b/sandbox/filesystem.py b/packages/python-sdk/e2b/sandbox/filesystem.py
index b301e565e..dd115920f 100644
--- a/packages/python-sdk/e2b/sandbox/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox/filesystem.py
@@ -1,29 +1,47 @@
-import warnings
+import logging
+import connect
-from pathlib import PurePosixPath
-from typing import Optional
+from typing import List
+from envd.filesystem.v1 import filesystem_connect, filesystem_pb2
-def resolve_path(path: str, cwd: Optional[str] = None) -> str:
- warning = f"Path starts with {{0}} and cwd isn't set. The path {path} will evaluate to `{{1}}`, which may not be what you want."
- if path.startswith("./"):
- result = PurePosixPath(cwd or "/home/user", path).as_posix()
- if not cwd:
- warnings.warn(warning.format("./", result))
- return result
+logger = logging.getLogger(__name__)
- if path.startswith("../"):
- result = PurePosixPath(cwd or "/home/user", path).as_posix()
- if not cwd:
- warnings.warn(warning.format("../", result))
- return result
- if path.startswith("~/"):
- result = PurePosixPath("/home/user", path[2:]).as_posix()
- warnings.warn(warning.format("~/", result))
- return result
+# TODO: Provide a way to cancel requests (watch)
+class Filesystem:
+ def __init__(self, base_url: str) -> None:
+ self.base_url = base_url
- if not path.startswith("/") and cwd:
- return PurePosixPath(cwd, path).as_posix()
+ self._service = filesystem_connect.FilesystemServiceClient(
+ self.base_url,
+ compressor=connect.GzipCompressor,
+ )
- return path
+ def list(self, path: str) -> List[filesystem_pb2.EntryInfo]:
+ params = filesystem_pb2.ListRequest(path=path)
+
+ res = self._service.list(params)
+ return [entry for entry in res.entries]
+
+ def stat(self, path: str) -> filesystem_pb2.EntryInfo:
+ params = filesystem_pb2.StatRequest(path=path)
+
+ res = self._service.stat(params)
+ return res.entry
+
+ def remove(self, path: str) -> None:
+ params = filesystem_pb2.RemoveRequest(path=path)
+
+ self._service.remove(params)
+
+ def watch(self, path: str):
+ params = filesystem_pb2.WatchRequest(path=path)
+
+ events = self._service.watch(params)
+
+ def stream():
+ for event in events:
+ yield event.event
+
+ return stream()
diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.py
index 5123933ce..b36d641aa 100644
--- a/packages/python-sdk/e2b/sandbox/main.py
+++ b/packages/python-sdk/e2b/sandbox/main.py
@@ -1,8 +1,9 @@
import logging
from typing import Optional, Dict
+from e2b.sandbox.filesystem import Filesystem
+from e2b.sandbox.process import Process
-from e2b.sandbox.rpc.main import SandboxRpc
from e2b.sandbox.sandbox_api import SandboxApi
from e2b.sandbox.sandbox_files import SandboxFiles
from e2b.connection_config import ConnectionConfig
@@ -47,16 +48,10 @@ class Sandbox(SandboxApi):
f"{'http' if debug else 'https'}://{self.get_hostname(SANDBOX_SERVER_PORT)}"
)
- self._rpc = SandboxRpc(url=sandbox_server_url)
- self._files = SandboxFiles(sandbox_server_url)
-
- @property
- def filesystem(self):
- return self._rpc.filesystem
+ self.filesystem = Filesystem(sandbox_server_url)
+ self.process = Process(sandbox_server_url)
- @property
- def process(self):
- return self._rpc.process
+ self._files = SandboxFiles(sandbox_server_url)
def get_hostname(self, port: int) -> str:
if self._connection_config.debug:
diff --git a/packages/python-sdk/e2b/sandbox/path.py b/packages/python-sdk/e2b/sandbox/path.py
new file mode 100644
index 000000000..b301e565e
--- /dev/null
+++ b/packages/python-sdk/e2b/sandbox/path.py
@@ -0,0 +1,29 @@
+import warnings
+
+from pathlib import PurePosixPath
+from typing import Optional
+
+
+def resolve_path(path: str, cwd: Optional[str] = None) -> str:
+ warning = f"Path starts with {{0}} and cwd isn't set. The path {path} will evaluate to `{{1}}`, which may not be what you want."
+ if path.startswith("./"):
+ result = PurePosixPath(cwd or "/home/user", path).as_posix()
+ if not cwd:
+ warnings.warn(warning.format("./", result))
+ return result
+
+ if path.startswith("../"):
+ result = PurePosixPath(cwd or "/home/user", path).as_posix()
+ if not cwd:
+ warnings.warn(warning.format("../", result))
+ return result
+
+ if path.startswith("~/"):
+ result = PurePosixPath("/home/user", path[2:]).as_posix()
+ warnings.warn(warning.format("~/", result))
+ return result
+
+ if not path.startswith("/") and cwd:
+ return PurePosixPath(cwd, path).as_posix()
+
+ return path
diff --git a/packages/python-sdk/e2b/sandbox/process.py b/packages/python-sdk/e2b/sandbox/process.py
index 43ef71b16..df81273da 100644
--- a/packages/python-sdk/e2b/sandbox/process.py
+++ b/packages/python-sdk/e2b/sandbox/process.py
@@ -1,429 +1,150 @@
-# from __future__ import annotations
-
-# import logging
-# import re
-# import inspect
-# import threading
-# import time
-# from concurrent.futures import Future
-# from typing import (
-# Any,
-# Callable,
-# ClassVar,
-# Dict,
-# List,
-# Optional,
-# Union,
-# )
-# from pydantic import BaseModel
-
-# from e2b.constants import TIMEOUT
-# from e2b.sandbox.env_vars import EnvVars
-# from e2b.exceptions import (
-# MultipleExceptions,
-# ProcessException,
-# RpcException,
-# CurrentWorkingDirectoryDoesntExistException,
-# TimeoutException,
-# )
-# from e2b.sandbox.out import OutStderrResponse, OutStdoutResponse
-# from e2b.sandbox.sandbox_connection import SandboxConnection, SubscriptionArgs
-# from e2b.utils.id import create_id
-
-# logger = logging.getLogger(__name__)
-
-
-# class ProcessMessage(BaseModel):
-# """
-# A message from a process.
-# """
-
-# line: str
-# error: bool = False
-# timestamp: int
-# """
-# Unix epoch in nanoseconds
-# """
-
-# def __str__(self):
-# return self.line
-
-
-# class ProcessOutput(BaseModel):
-# """
-# Output from a process.
-# """
-
-# delimiter: ClassVar[str] = "\n"
-# messages: List[ProcessMessage] = []
-
-# error: bool = False
-# exit_code: Optional[int] = None
-
-# @property
-# def stdout(self) -> str:
-# """
-# The stdout from the process.
-# """
-# return self.delimiter.join(out.line for out in self.messages if not out.error)
-
-# @property
-# def stderr(self) -> str:
-# """
-# The stderr from the process.
-# """
-# return self.delimiter.join(out.line for out in self.messages if out.error)
-
-# def _insert_by_timestamp(self, message: ProcessMessage):
-# """Insert an out based on its timestamp using insertion sort."""
-# i = len(self.messages) - 1
-# while i >= 0 and self.messages[i].timestamp > message.timestamp:
-# i -= 1
-# self.messages.insert(i + 1, message)
-
-# def _add_stdout(self, message: ProcessMessage):
-# self._insert_by_timestamp(message)
-
-# def _add_stderr(self, message: ProcessMessage):
-# self.error = True
-# self._insert_by_timestamp(message)
-
-
-# class Process:
-# """
-# A process running in the sandbox.
-# """
-
-# def __init__(
-# self,
-# process_id: str,
-# sandbox: SandboxConnection,
-# trigger_exit: Callable[[], Any],
-# finished: Future[ProcessOutput],
-# output: ProcessOutput,
-# ):
-# self._process_id = process_id
-# self._sandbox = sandbox
-# self._trigger_exit = trigger_exit
-# self._finished = finished
-# self._output = output
-
-# @property
-# def exit_code(self) -> Optional[int]:
-# """
-# The exit code of the last process started by this manager.
-# """
-# if not self.finished:
-# raise ProcessException("Process has not finished yet")
-# return self.output.exit_code
-
-# @property
-# def output(self) -> ProcessOutput:
-# """
-# The output from the process.
-# """
-# return self._output
-
-# @property
-# def stdout(self) -> str:
-# """
-# The stdout from the process.
-# """
-# return self._output.stdout
-
-# @property
-# def stderr(self) -> str:
-# """
-# The stderr from the process.
-# """
-# return self._output.stderr
-
-# @property
-# def error(self) -> bool:
-# """
-# True if the process has written to stderr.
-# """
-# return self._output.error
-
-# @property
-# def output_messages(self) -> List[ProcessMessage]:
-# """
-# The output messages from the process.
-# """
-# return self._output.messages
-
-# @property
-# def finished(self):
-# """
-# A future that is resolved when the process exits.
-# """
-# return self._finished
-
-# @property
-# def process_id(self) -> str:
-# """
-# The process id used to identify the process in the sandbox.
-# This is not the system process id of the process running in the sandbox.
-# """
-# return self._process_id
-
-# def wait(self, timeout: Optional[float] = None) -> ProcessOutput:
-# """
-# Wait for the process to exit.
-
-# :param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out. If set to None, the method will continue to wait until it completes, regardless of time
-# """
-# start_time = time.time()
-# while timeout is None or time.time() - start_time < timeout:
-# if self._finished.done():
-# return self._finished.result()
-# time.sleep(0.1)
-# if not self._sandbox.is_open:
-# break
-
-# raise TimeoutException(f"Process did not finish within {timeout} seconds")
-
-# def send_stdin(self, data: str, timeout: Optional[float] = TIMEOUT) -> None:
-# """
-# Send data to the process stdin.
-
-# :param data: Data to send
-# :param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time
-# """
-# try:
-# self._sandbox._call(
-# ProcessManager._service_name,
-# "stdin",
-# [self.process_id, data],
-# timeout=timeout,
-# )
-# except RpcException as e:
-# raise ProcessException(e.message) from e
-
-# def kill(self, timeout: Optional[float] = TIMEOUT) -> None:
-# """
-# Kill the process.
-
-# :param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time
-# """
-# try:
-# self._sandbox._call(
-# ProcessManager._service_name, "kill", [self.process_id], timeout=timeout
-# )
-# except RpcException as e:
-# raise ProcessException(e.message) from e
-# self._trigger_exit()
-
-
-# class ProcessManager:
-# """
-# Manager for starting and interacting with processes in the sandbox.
-# """
-
-# _service_name = "process"
-
-# def __init__(
-# self,
-# sandbox: SandboxConnection,
-# on_stdout: Optional[Callable[[ProcessMessage], Any]] = None,
-# on_stderr: Optional[Callable[[ProcessMessage], Any]] = None,
-# on_exit: Optional[Union[Callable[[int], Any], Callable[[], Any]]] = None,
-# ):
-# self._sandbox = sandbox
-# self._process_cleanup: List[Callable[[], Any]] = []
-# self._on_stdout = on_stdout
-# self._on_stderr = on_stderr
-# self._on_exit = on_exit
-
-# def start(
-# self,
-# cmd: str,
-# on_stdout: Optional[Callable[[ProcessMessage], Any]] = None,
-# on_stderr: Optional[Callable[[ProcessMessage], Any]] = None,
-# on_exit: Optional[Union[Callable[[int], Any], Callable[[], Any]]] = None,
-# env_vars: Optional[EnvVars] = None,
-# cwd: str = "",
-# rootdir: str = "", # DEPRECATED
-# process_id: Optional[str] = None,
-# timeout: Optional[float] = TIMEOUT,
-# ) -> Process:
-# logger.info(f"Starting process: {cmd}")
-# env_vars = env_vars or {}
-# env_vars = {**self._sandbox.env_vars, **env_vars}
-
-# on_stdout = on_stdout or self._on_stdout
-# on_stderr = on_stderr or self._on_stderr
-# on_exit = on_exit or self._on_exit
-
-# future_exit = Future()
-# process_id = process_id or create_id(12)
-
-# unsub_all: Optional[Callable] = None
-
-# output = ProcessOutput()
-
-# def handle_exit(exit_code: int):
-# output.exit_code = exit_code
-# logger.info(f"Process {process_id} exited with exit code {exit_code}")
-# if not future_exit.done():
-# future_exit.set_result(True)
-
-# def handle_stdout(data: Dict[Any, Any]):
-# out = OutStdoutResponse(**data)
-
-# message = ProcessMessage(
-# line=out.line,
-# timestamp=out.timestamp,
-# error=False,
-# )
-
-# output._add_stdout(message)
-# if on_stdout:
-# try:
-# on_stdout(message)
-# except TypeError as error:
-# logger.exception(f"Error in on_stdout callback: {error}")
-
-# def handle_stderr(data: Dict[Any, Any]):
-# out = OutStderrResponse(**data)
-
-# message = ProcessMessage(
-# line=out.line,
-# timestamp=out.timestamp,
-# error=True,
-# )
-
-# output._add_stderr(message)
-# if on_stderr:
-# try:
-# on_stderr(message)
-# except TypeError as error:
-# logger.exception(f"Error in on_stdout callback: {error}")
-
-# try:
-# subscription_args = [
-# SubscriptionArgs(
-# service=self._service_name,
-# handler=handle_exit,
-# method="onExit",
-# params=[process_id],
-# ),
-# SubscriptionArgs(
-# service=self._service_name,
-# handler=handle_stdout,
-# method="onStdout",
-# params=[process_id],
-# ),
-# SubscriptionArgs(
-# service=self._service_name,
-# handler=handle_stderr,
-# method="onStderr",
-# params=[process_id],
-# ),
-# ]
-# unsub_all = self._sandbox._handle_subscriptions(*subscription_args)
-
-# except (RpcException, MultipleExceptions) as e:
-# future_exit.cancel()
-
-# if isinstance(e, RpcException):
-# raise ProcessException(e.message) from e
-# elif isinstance(e, MultipleExceptions):
-# raise ProcessException(
-# "Failed to subscribe to RPC services necessary for starting process"
-# ) from e
-
-# future_exit_handler_finish: Future[ProcessOutput] = Future()
-
-# def exit_handler():
-# future_exit.result()
-# logger.info(f"Handling process exit (id: {process_id})")
-# if unsub_all:
-# unsub_all()
-# if on_exit:
-# sig = inspect.signature(on_exit)
-# params = sig.parameters.values()
-# try:
-# if len(params) == 0:
-# on_exit()
-# else:
-# on_exit(output.exit_code or 0)
-# except TypeError as error:
-# logger.exception(f"Error in on_exit callback: {error}")
-# future_exit_handler_finish.set_result(output)
-
-# threading.Thread(
-# name="e2b-process-exit-handler", daemon=True, target=exit_handler
-# ).start()
-
-# def trigger_exit():
-# logger.info(f"Exiting the process (id: {process_id})")
-# if not future_exit.done():
-# future_exit.set_result(None)
-
-# future_exit_handler_finish.result()
-# logger.debug(f"Exited the process (id: {process_id})")
-
-# try:
-# if not cwd and rootdir:
-# cwd = rootdir
-# logger.warning("The rootdir parameter is deprecated, use cwd instead.")
-
-# if not cwd and self._sandbox.cwd:
-# cwd = self._sandbox.cwd
-
-# self._sandbox._call(
-# self._service_name,
-# "start",
-# [
-# process_id,
-# cmd,
-# env_vars,
-# cwd,
-# ],
-# timeout=timeout,
-# )
-# logger.info(f"Started process (id: {process_id})")
-# return Process(
-# output=output,
-# sandbox=self._sandbox,
-# process_id=process_id,
-# trigger_exit=trigger_exit,
-# finished=future_exit_handler_finish,
-# )
-# except RpcException as e:
-# trigger_exit()
-# if re.match(
-# r"error starting process '\w+': fork/exec /bin/bash: no such file or directory",
-# e.message,
-# ):
-# raise CurrentWorkingDirectoryDoesntExistException(
-# "Failed to start the process. You are trying set `cwd` to a directory that does not exist."
-# ) from e
-# raise ProcessException(e.message) from e
-# except TimeoutError as e:
-# logger.error(f"Timeout error during starting the process: {cmd}")
-# trigger_exit()
-# raise e
-
-# def start_and_wait(
-# self,
-# cmd: str,
-# on_stdout: Optional[Callable[[ProcessMessage], Any]] = None,
-# on_stderr: Optional[Callable[[ProcessMessage], Any]] = None,
-# on_exit: Optional[Callable[[int], Any]] = None,
-# env_vars: Optional[EnvVars] = None,
-# cwd: str = "",
-# process_id: Optional[str] = None,
-# timeout: Optional[float] = TIMEOUT,
-# ) -> ProcessOutput:
-# return self.start(
-# cmd,
-# on_stdout=on_stdout,
-# on_stderr=on_stderr,
-# on_exit=on_exit,
-# env_vars=env_vars,
-# cwd=cwd,
-# process_id=process_id,
-# timeout=timeout,
-# ).wait()
+import logging
+import connect
+
+from typing import Dict, Optional, Callable, Any, Generator, Union
+
+from envd.process.v1 import process_connect, process_pb2
+
+logger = logging.getLogger(__name__)
+
+
+class ProcessOutput:
+ def __init__(self, stdout: Optional[bytes], stderr: Optional[bytes]) -> None:
+ self.stdout = str(stdout) if stdout else None
+ self.stderr = str(stderr) if stderr else None
+
+
+class ProcessHandle:
+ def __init__(
+ self,
+ pid: int,
+ kill: Callable[[], None],
+ events: Generator[
+ Union[process_pb2.StartResponse, process_pb2.ConnectResponse], Any, None
+ ],
+ ):
+ self.pid = pid
+ self.kill = kill
+ self._events = events
+
+ self._stdout: bytes = b""
+ self._stderr: bytes = b""
+
+ self._end_event: Union[process_pb2.ProcessEvent.EndEvent, None] = None
+
+ def __next__(self):
+ event = next(self._events)
+
+ if event.HasField("data"):
+ if event.event.data.stdout:
+ self._stdout += event.event.data.stdout
+ return ProcessOutput(self._stdout, None)
+ if event.event.data.stderr:
+ self._stderr += event.event.data.stderr
+ return ProcessOutput(None, self._stderr)
+ if event.HasField("end"):
+ self._end_event = event.event.end
+
+ raise StopIteration
+
+ def __iter__(self):
+ return self
+
+ def wait(self):
+ for _ in self:
+ pass
+
+ if self._end_event is None:
+ raise RuntimeError("Process has not ended")
+
+ return ProcessResult(
+ stdout=self._stdout,
+ stderr=self._stderr,
+ exit_code=self._end_event.exit_code,
+ error=self._end_event.error,
+ )
+
+
+class ProcessResult(ProcessOutput):
+ def __init__(
+ self,
+ stdout: bytes,
+ stderr: bytes,
+ exit_code: int,
+ error: Optional[str] = None,
+ ) -> None:
+ super().__init__(stdout, stderr)
+ self.exit_code = exit_code
+ self.error = error
+
+
+# TODO: Add disconnect for process handle
+class Process:
+ def __init__(self, base_url: str) -> None:
+ self.base_url = base_url
+
+ self._service = process_connect.ProcessServiceClient(
+ self.base_url,
+ compressor=connect.GzipCompressor,
+ )
+
+ def list(self):
+ params = process_pb2.ListRequest()
+
+ res = self._service.list(params)
+ return [p for p in res.processes]
+
+ def kill(self, pid: int):
+ params = process_pb2.SendSignalRequest(
+ process=process_pb2.ProcessSelector(pid=pid),
+ signal=process_pb2.Signal.SIGNAL_SIGKILL,
+ )
+
+ self._service.send_signal(params)
+
+ def sendStdin(self, pid: int, data: bytes):
+ params = process_pb2.SendInputRequest(
+ process=process_pb2.ProcessSelector(pid=pid),
+ input=process_pb2.ProcessInput(stdin=data),
+ )
+
+ self._service.send_input(params)
+
+ def start(
+ self,
+ cmd: str,
+ envs: Optional[Dict[str, str]] = {},
+ user: str = "user",
+ cwd: Optional[str] = None,
+ ):
+ params = process_pb2.StartRequest(
+ owner=process_pb2.Credential(username=user),
+ process=process_pb2.ProcessConfig(
+ cmd=cmd,
+ envs=envs,
+ cwd=cwd,
+ ),
+ )
+
+ events = self._service.start(params)
+
+ start_event = next(events)
+
+ return ProcessHandle(
+ pid=start_event.event.start.pid,
+ kill=lambda: self.kill(start_event.event.start.pid),
+ events=events,
+ )
+
+ def connect(self, pid: int):
+ params = process_pb2.ConnectRequest(
+ process=process_pb2.ProcessSelector(pid=pid),
+ )
+
+ events = self._service.connect(params)
+
+ return ProcessHandle(
+ pid=pid,
+ kill=lambda: self.kill(pid),
+ events=events,
+ )
diff --git a/packages/python-sdk/e2b/sandbox/rpc/__init__.py b/packages/python-sdk/e2b/sandbox/rpc/__init__.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/python-sdk/e2b/sandbox/rpc/filesystem.py b/packages/python-sdk/e2b/sandbox/rpc/filesystem.py
deleted file mode 100644
index a81f6f5bf..000000000
--- a/packages/python-sdk/e2b/sandbox/rpc/filesystem.py
+++ /dev/null
@@ -1,8 +0,0 @@
-import logging
-
-logger = logging.getLogger(__name__)
-
-
-class Filesystem:
- def __init__(self) -> None:
- pass
diff --git a/packages/python-sdk/e2b/sandbox/rpc/main.py b/packages/python-sdk/e2b/sandbox/rpc/main.py
deleted file mode 100644
index 7b28a3b53..000000000
--- a/packages/python-sdk/e2b/sandbox/rpc/main.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from e2b.sandbox.rpc.filesystem import Filesystem
-from e2b.sandbox.rpc.process import Process
-
-
-class SandboxRpc:
- def __init__(self, url: str):
-
- self.filesystem = Filesystem()
- self.process = Process()
diff --git a/packages/python-sdk/e2b/sandbox/rpc/process.py b/packages/python-sdk/e2b/sandbox/rpc/process.py
deleted file mode 100644
index 84971fd79..000000000
--- a/packages/python-sdk/e2b/sandbox/rpc/process.py
+++ /dev/null
@@ -1,8 +0,0 @@
-import logging
-
-logger = logging.getLogger(__name__)
-
-
-class Process:
- def __init__(self) -> None:
- pass
diff --git a/packages/python-sdk/envd/filesystem/v1/filesystem_connect.py b/packages/python-sdk/envd/filesystem/v1/filesystem_connect.py
index 99432fc4c..84e87c888 100644
--- a/packages/python-sdk/envd/filesystem/v1/filesystem_connect.py
+++ b/packages/python-sdk/envd/filesystem/v1/filesystem_connect.py
@@ -3,7 +3,9 @@ from typing import Any, Generator
import connect
-from envd.filesystem.v1 import filesystem_pb2 as envd_dot_filesystem_dot_v1_dot_filesystem__pb2
+from envd.filesystem.v1 import (
+ filesystem_pb2 as envd_dot_filesystem_dot_v1_dot_filesystem__pb2,
+)
FilesystemServiceName = "envd.filesystem.v1.FilesystemService"
@@ -16,7 +18,7 @@ class FilesystemServiceClient:
response_type=envd_dot_filesystem_dot_v1_dot_filesystem__pb2.StatResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._list = connect.Client(
pool=pool,
@@ -24,7 +26,7 @@ class FilesystemServiceClient:
response_type=envd_dot_filesystem_dot_v1_dot_filesystem__pb2.ListResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._watch = connect.Client(
pool=pool,
@@ -32,7 +34,7 @@ class FilesystemServiceClient:
response_type=envd_dot_filesystem_dot_v1_dot_filesystem__pb2.WatchResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._remove = connect.Client(
pool=pool,
@@ -40,17 +42,27 @@ class FilesystemServiceClient:
response_type=envd_dot_filesystem_dot_v1_dot_filesystem__pb2.RemoveResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
- def stat(self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.StatRequest, **opts) -> envd_dot_filesystem_dot_v1_dot_filesystem__pb2.StatResponse:
+ def stat(
+ self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.StatRequest, **opts
+ ) -> envd_dot_filesystem_dot_v1_dot_filesystem__pb2.StatResponse:
return self._stat.call_unary(req, **opts)
- def list(self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.ListRequest, **opts) -> envd_dot_filesystem_dot_v1_dot_filesystem__pb2.ListResponse:
+ def list(
+ self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.ListRequest, **opts
+ ) -> envd_dot_filesystem_dot_v1_dot_filesystem__pb2.ListResponse:
return self._list.call_unary(req, **opts)
- def watch(self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.WatchRequest , **opts) -> Generator[envd_dot_filesystem_dot_v1_dot_filesystem__pb2.WatchResponse, Any, None]:
+ def watch(
+ self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.WatchRequest, **opts
+ ) -> Generator[
+ envd_dot_filesystem_dot_v1_dot_filesystem__pb2.WatchResponse, Any, None
+ ]:
return self._watch.call_server_stream(req, **opts)
- def remove(self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.RemoveRequest, **opts) -> envd_dot_filesystem_dot_v1_dot_filesystem__pb2.RemoveResponse:
+ def remove(
+ self, req: envd_dot_filesystem_dot_v1_dot_filesystem__pb2.RemoveRequest, **opts
+ ) -> envd_dot_filesystem_dot_v1_dot_filesystem__pb2.RemoveResponse:
return self._remove.call_unary(req, **opts)
diff --git a/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.py b/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.py
index 021cd200a..dbf76b845 100644
--- a/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.py
+++ b/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.py
@@ -7,45 +7,50 @@ from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
+
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
-
-
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n#envd/filesystem/v1/filesystem.proto\x12\x12\x65nvd.filesystem.v1\"#\n\rRemoveRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\"\x10\n\x0eRemoveResponse\"!\n\x0bStatRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\"C\n\x0cStatResponse\x12\x33\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x1d.envd.filesystem.v1.EntryInfoR\x05\x65ntry\"Q\n\tEntryInfo\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12\x30\n\x04type\x18\x02 \x01(\x0e\x32\x1c.envd.filesystem.v1.FileTypeR\x04type\"!\n\x0bListRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\"G\n\x0cListResponse\x12\x37\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x1d.envd.filesystem.v1.EntryInfoR\x07\x65ntries\"\"\n\x0cWatchRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\"J\n\rWatchResponse\x12\x39\n\x05\x65vent\x18\x01 \x01(\x0b\x32#.envd.filesystem.v1.FilesystemEventR\x05\x65vent\"X\n\x0f\x46ilesystemEvent\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32\x1d.envd.filesystem.v1.EventTypeR\x04type*R\n\x08\x46ileType\x12\x19\n\x15\x46ILE_TYPE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x46ILE_TYPE_FILE\x10\x01\x12\x17\n\x13\x46ILE_TYPE_DIRECTORY\x10\x02*\x98\x01\n\tEventType\x12\x1a\n\x16\x45VENT_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x45VENT_TYPE_CREATE\x10\x01\x12\x14\n\x10\x45VENT_TYPE_WRITE\x10\x02\x12\x15\n\x11\x45VENT_TYPE_REMOVE\x10\x03\x12\x15\n\x11\x45VENT_TYPE_RENAME\x10\x04\x12\x14\n\x10\x45VENT_TYPE_CHMOD\x10\x05\x32\xca\x02\n\x11\x46ilesystemService\x12I\n\x04Stat\x12\x1f.envd.filesystem.v1.StatRequest\x1a .envd.filesystem.v1.StatResponse\x12I\n\x04List\x12\x1f.envd.filesystem.v1.ListRequest\x1a .envd.filesystem.v1.ListResponse\x12N\n\x05Watch\x12 .envd.filesystem.v1.WatchRequest\x1a!.envd.filesystem.v1.WatchResponse0\x01\x12O\n\x06Remove\x12!.envd.filesystem.v1.RemoveRequest\x1a\".envd.filesystem.v1.RemoveResponseB\x93\x01\n\x16\x63om.envd.filesystem.v1B\x0f\x46ilesystemProtoP\x01\xa2\x02\x03\x45\x46X\xaa\x02\x12\x45nvd.Filesystem.V1\xca\x02\x12\x45nvd\\Filesystem\\V1\xe2\x02\x1e\x45nvd\\Filesystem\\V1\\GPBMetadata\xea\x02\x14\x45nvd::Filesystem::V1b\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
+ b'\n#envd/filesystem/v1/filesystem.proto\x12\x12\x65nvd.filesystem.v1"#\n\rRemoveRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"\x10\n\x0eRemoveResponse"!\n\x0bStatRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"C\n\x0cStatResponse\x12\x33\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x1d.envd.filesystem.v1.EntryInfoR\x05\x65ntry"Q\n\tEntryInfo\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12\x30\n\x04type\x18\x02 \x01(\x0e\x32\x1c.envd.filesystem.v1.FileTypeR\x04type"!\n\x0bListRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"G\n\x0cListResponse\x12\x37\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x1d.envd.filesystem.v1.EntryInfoR\x07\x65ntries""\n\x0cWatchRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"J\n\rWatchResponse\x12\x39\n\x05\x65vent\x18\x01 \x01(\x0b\x32#.envd.filesystem.v1.FilesystemEventR\x05\x65vent"X\n\x0f\x46ilesystemEvent\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path\x12\x31\n\x04type\x18\x02 \x01(\x0e\x32\x1d.envd.filesystem.v1.EventTypeR\x04type*R\n\x08\x46ileType\x12\x19\n\x15\x46ILE_TYPE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x46ILE_TYPE_FILE\x10\x01\x12\x17\n\x13\x46ILE_TYPE_DIRECTORY\x10\x02*\x98\x01\n\tEventType\x12\x1a\n\x16\x45VENT_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x45VENT_TYPE_CREATE\x10\x01\x12\x14\n\x10\x45VENT_TYPE_WRITE\x10\x02\x12\x15\n\x11\x45VENT_TYPE_REMOVE\x10\x03\x12\x15\n\x11\x45VENT_TYPE_RENAME\x10\x04\x12\x14\n\x10\x45VENT_TYPE_CHMOD\x10\x05\x32\xca\x02\n\x11\x46ilesystemService\x12I\n\x04Stat\x12\x1f.envd.filesystem.v1.StatRequest\x1a .envd.filesystem.v1.StatResponse\x12I\n\x04List\x12\x1f.envd.filesystem.v1.ListRequest\x1a .envd.filesystem.v1.ListResponse\x12N\n\x05Watch\x12 .envd.filesystem.v1.WatchRequest\x1a!.envd.filesystem.v1.WatchResponse0\x01\x12O\n\x06Remove\x12!.envd.filesystem.v1.RemoveRequest\x1a".envd.filesystem.v1.RemoveResponseB\x93\x01\n\x16\x63om.envd.filesystem.v1B\x0f\x46ilesystemProtoP\x01\xa2\x02\x03\x45\x46X\xaa\x02\x12\x45nvd.Filesystem.V1\xca\x02\x12\x45nvd\\Filesystem\\V1\xe2\x02\x1e\x45nvd\\Filesystem\\V1\\GPBMetadata\xea\x02\x14\x45nvd::Filesystem::V1b\x06proto3'
+)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
-_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'envd.filesystem.v1.filesystem_pb2', _globals)
+_builder.BuildTopDescriptorsAndMessages(
+ DESCRIPTOR, "envd.filesystem.v1.filesystem_pb2", _globals
+)
if not _descriptor._USE_C_DESCRIPTORS:
- _globals['DESCRIPTOR']._loaded_options = None
- _globals['DESCRIPTOR']._serialized_options = b'\n\026com.envd.filesystem.v1B\017FilesystemProtoP\001\242\002\003EFX\252\002\022Envd.Filesystem.V1\312\002\022Envd\\Filesystem\\V1\342\002\036Envd\\Filesystem\\V1\\GPBMetadata\352\002\024Envd::Filesystem::V1'
- _globals['_FILETYPE']._serialized_start=611
- _globals['_FILETYPE']._serialized_end=693
- _globals['_EVENTTYPE']._serialized_start=696
- _globals['_EVENTTYPE']._serialized_end=848
- _globals['_REMOVEREQUEST']._serialized_start=59
- _globals['_REMOVEREQUEST']._serialized_end=94
- _globals['_REMOVERESPONSE']._serialized_start=96
- _globals['_REMOVERESPONSE']._serialized_end=112
- _globals['_STATREQUEST']._serialized_start=114
- _globals['_STATREQUEST']._serialized_end=147
- _globals['_STATRESPONSE']._serialized_start=149
- _globals['_STATRESPONSE']._serialized_end=216
- _globals['_ENTRYINFO']._serialized_start=218
- _globals['_ENTRYINFO']._serialized_end=299
- _globals['_LISTREQUEST']._serialized_start=301
- _globals['_LISTREQUEST']._serialized_end=334
- _globals['_LISTRESPONSE']._serialized_start=336
- _globals['_LISTRESPONSE']._serialized_end=407
- _globals['_WATCHREQUEST']._serialized_start=409
- _globals['_WATCHREQUEST']._serialized_end=443
- _globals['_WATCHRESPONSE']._serialized_start=445
- _globals['_WATCHRESPONSE']._serialized_end=519
- _globals['_FILESYSTEMEVENT']._serialized_start=521
- _globals['_FILESYSTEMEVENT']._serialized_end=609
- _globals['_FILESYSTEMSERVICE']._serialized_start=851
- _globals['_FILESYSTEMSERVICE']._serialized_end=1181
+ _globals["DESCRIPTOR"]._loaded_options = None
+ _globals[
+ "DESCRIPTOR"
+ ]._serialized_options = b"\n\026com.envd.filesystem.v1B\017FilesystemProtoP\001\242\002\003EFX\252\002\022Envd.Filesystem.V1\312\002\022Envd\\Filesystem\\V1\342\002\036Envd\\Filesystem\\V1\\GPBMetadata\352\002\024Envd::Filesystem::V1"
+ _globals["_FILETYPE"]._serialized_start = 611
+ _globals["_FILETYPE"]._serialized_end = 693
+ _globals["_EVENTTYPE"]._serialized_start = 696
+ _globals["_EVENTTYPE"]._serialized_end = 848
+ _globals["_REMOVEREQUEST"]._serialized_start = 59
+ _globals["_REMOVEREQUEST"]._serialized_end = 94
+ _globals["_REMOVERESPONSE"]._serialized_start = 96
+ _globals["_REMOVERESPONSE"]._serialized_end = 112
+ _globals["_STATREQUEST"]._serialized_start = 114
+ _globals["_STATREQUEST"]._serialized_end = 147
+ _globals["_STATRESPONSE"]._serialized_start = 149
+ _globals["_STATRESPONSE"]._serialized_end = 216
+ _globals["_ENTRYINFO"]._serialized_start = 218
+ _globals["_ENTRYINFO"]._serialized_end = 299
+ _globals["_LISTREQUEST"]._serialized_start = 301
+ _globals["_LISTREQUEST"]._serialized_end = 334
+ _globals["_LISTRESPONSE"]._serialized_start = 336
+ _globals["_LISTRESPONSE"]._serialized_end = 407
+ _globals["_WATCHREQUEST"]._serialized_start = 409
+ _globals["_WATCHREQUEST"]._serialized_end = 443
+ _globals["_WATCHRESPONSE"]._serialized_start = 445
+ _globals["_WATCHRESPONSE"]._serialized_end = 519
+ _globals["_FILESYSTEMEVENT"]._serialized_start = 521
+ _globals["_FILESYSTEMEVENT"]._serialized_end = 609
+ _globals["_FILESYSTEMSERVICE"]._serialized_start = 851
+ _globals["_FILESYSTEMSERVICE"]._serialized_end = 1181
# @@protoc_insertion_point(module_scope)
diff --git a/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.pyi b/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.pyi
index c5068c5f1..2332d36cc 100644
--- a/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.pyi
+++ b/packages/python-sdk/envd/filesystem/v1/filesystem_pb2.pyi
@@ -2,7 +2,13 @@ from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
-from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
+from typing import (
+ ClassVar as _ClassVar,
+ Iterable as _Iterable,
+ Mapping as _Mapping,
+ Optional as _Optional,
+ Union as _Union,
+)
DESCRIPTOR: _descriptor.FileDescriptor
@@ -20,6 +26,7 @@ class EventType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
EVENT_TYPE_REMOVE: _ClassVar[EventType]
EVENT_TYPE_RENAME: _ClassVar[EventType]
EVENT_TYPE_CHMOD: _ClassVar[EventType]
+
FILE_TYPE_UNSPECIFIED: FileType
FILE_TYPE_FILE: FileType
FILE_TYPE_DIRECTORY: FileType
@@ -58,7 +65,9 @@ class EntryInfo(_message.Message):
TYPE_FIELD_NUMBER: _ClassVar[int]
name: str
type: FileType
- def __init__(self, name: _Optional[str] = ..., type: _Optional[_Union[FileType, str]] = ...) -> None: ...
+ def __init__(
+ self, name: _Optional[str] = ..., type: _Optional[_Union[FileType, str]] = ...
+ ) -> None: ...
class ListRequest(_message.Message):
__slots__ = ("path",)
@@ -70,7 +79,9 @@ class ListResponse(_message.Message):
__slots__ = ("entries",)
ENTRIES_FIELD_NUMBER: _ClassVar[int]
entries: _containers.RepeatedCompositeFieldContainer[EntryInfo]
- def __init__(self, entries: _Optional[_Iterable[_Union[EntryInfo, _Mapping]]] = ...) -> None: ...
+ def __init__(
+ self, entries: _Optional[_Iterable[_Union[EntryInfo, _Mapping]]] = ...
+ ) -> None: ...
class WatchRequest(_message.Message):
__slots__ = ("path",)
@@ -82,7 +93,9 @@ class WatchResponse(_message.Message):
__slots__ = ("event",)
EVENT_FIELD_NUMBER: _ClassVar[int]
event: FilesystemEvent
- def __init__(self, event: _Optional[_Union[FilesystemEvent, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self, event: _Optional[_Union[FilesystemEvent, _Mapping]] = ...
+ ) -> None: ...
class FilesystemEvent(_message.Message):
__slots__ = ("path", "type")
@@ -90,4 +103,6 @@ class FilesystemEvent(_message.Message):
TYPE_FIELD_NUMBER: _ClassVar[int]
path: str
type: EventType
- def __init__(self, path: _Optional[str] = ..., type: _Optional[_Union[EventType, str]] = ...) -> None: ...
+ def __init__(
+ self, path: _Optional[str] = ..., type: _Optional[_Union[EventType, str]] = ...
+ ) -> None: ...
diff --git a/packages/python-sdk/envd/process/v1/process_connect.py b/packages/python-sdk/envd/process/v1/process_connect.py
index 0bec00c57..cd99291bf 100644
--- a/packages/python-sdk/envd/process/v1/process_connect.py
+++ b/packages/python-sdk/envd/process/v1/process_connect.py
@@ -16,7 +16,7 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.ListResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._connect = connect.Client(
pool=pool,
@@ -24,7 +24,7 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.ConnectResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._start = connect.Client(
pool=pool,
@@ -32,7 +32,7 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.StartResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._update = connect.Client(
pool=pool,
@@ -40,7 +40,7 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.UpdateResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._stream_input = connect.Client(
pool=pool,
@@ -48,7 +48,7 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.StreamInputResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._send_input = connect.Client(
pool=pool,
@@ -56,7 +56,7 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.SendInputResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
self._send_signal = connect.Client(
pool=pool,
@@ -64,26 +64,40 @@ class ProcessServiceClient:
response_type=envd_dot_process_dot_v1_dot_process__pb2.SendSignalResponse,
compressor=compressor,
json=json,
- **opts
+ **opts,
)
- def list(self, req: envd_dot_process_dot_v1_dot_process__pb2.ListRequest, **opts) -> envd_dot_process_dot_v1_dot_process__pb2.ListResponse:
+ def list(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.ListRequest, **opts
+ ) -> envd_dot_process_dot_v1_dot_process__pb2.ListResponse:
return self._list.call_unary(req, **opts)
- def connect(self, req: envd_dot_process_dot_v1_dot_process__pb2.ConnectRequest , **opts) -> Generator[envd_dot_process_dot_v1_dot_process__pb2.ConnectResponse, Any, None]:
+ def connect(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.ConnectRequest, **opts
+ ) -> Generator[envd_dot_process_dot_v1_dot_process__pb2.ConnectResponse, Any, None]:
return self._connect.call_server_stream(req, **opts)
- def start(self, req: envd_dot_process_dot_v1_dot_process__pb2.StartRequest , **opts) -> Generator[envd_dot_process_dot_v1_dot_process__pb2.StartResponse, Any, None]:
+ def start(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.StartRequest, **opts
+ ) -> Generator[envd_dot_process_dot_v1_dot_process__pb2.StartResponse, Any, None]:
return self._start.call_server_stream(req, **opts)
- def update(self, req: envd_dot_process_dot_v1_dot_process__pb2.UpdateRequest, **opts) -> envd_dot_process_dot_v1_dot_process__pb2.UpdateResponse:
+ def update(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.UpdateRequest, **opts
+ ) -> envd_dot_process_dot_v1_dot_process__pb2.UpdateResponse:
return self._update.call_unary(req, **opts)
- def stream_input(self, req: envd_dot_process_dot_v1_dot_process__pb2.StreamInputRequest, **opts) -> envd_dot_process_dot_v1_dot_process__pb2.StreamInputResponse:
+ def stream_input(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.StreamInputRequest, **opts
+ ) -> envd_dot_process_dot_v1_dot_process__pb2.StreamInputResponse:
return self._stream_input.call_client_stream(req, **opts)
- def send_input(self, req: envd_dot_process_dot_v1_dot_process__pb2.SendInputRequest, **opts) -> envd_dot_process_dot_v1_dot_process__pb2.SendInputResponse:
+ def send_input(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.SendInputRequest, **opts
+ ) -> envd_dot_process_dot_v1_dot_process__pb2.SendInputResponse:
return self._send_input.call_unary(req, **opts)
- def send_signal(self, req: envd_dot_process_dot_v1_dot_process__pb2.SendSignalRequest, **opts) -> envd_dot_process_dot_v1_dot_process__pb2.SendSignalResponse:
+ def send_signal(
+ self, req: envd_dot_process_dot_v1_dot_process__pb2.SendSignalRequest, **opts
+ ) -> envd_dot_process_dot_v1_dot_process__pb2.SendSignalResponse:
return self._send_signal.call_unary(req, **opts)
diff --git a/packages/python-sdk/envd/process/v1/process_pb2.py b/packages/python-sdk/envd/process/v1/process_pb2.py
index e9631f037..38271cbb8 100644
--- a/packages/python-sdk/envd/process/v1/process_pb2.py
+++ b/packages/python-sdk/envd/process/v1/process_pb2.py
@@ -7,79 +7,84 @@ from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
+
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
-
-
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1d\x65nvd/process/v1/process.proto\x12\x0f\x65nvd.process.v1\"d\n\x03PTY\x12-\n\x04size\x18\x01 \x01(\x0b\x32\x19.envd.process.v1.PTY.SizeR\x04size\x1a.\n\x04Size\x12\x12\n\x04\x63ols\x18\x01 \x01(\rR\x04\x63ols\x12\x12\n\x04rows\x18\x02 \x01(\rR\x04rows\"\xbe\x01\n\rProcessConfig\x12\x10\n\x03\x63md\x18\x01 \x01(\tR\x03\x63md\x12\x12\n\x04\x61rgs\x18\x02 \x03(\tR\x04\x61rgs\x12<\n\x04\x65nvs\x18\x03 \x03(\x0b\x32(.envd.process.v1.ProcessConfig.EnvsEntryR\x04\x65nvs\x12\x10\n\x03\x63wd\x18\x04 \x01(\tR\x03\x63wd\x1a\x37\n\tEnvsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\r\n\x0bListRequest\"L\n\x0cListResponse\x12<\n\tprocesses\x18\x01 \x03(\x0b\x32\x1e.envd.process.v1.ProcessConfigR\tprocesses\"8\n\nCredential\x12\x1c\n\x08username\x18\x01 \x01(\tH\x00R\x08usernameB\x0c\n\ncredential\"\xb0\x01\n\x0cStartRequest\x12\x38\n\x07process\x18\x01 \x01(\x0b\x32\x1e.envd.process.v1.ProcessConfigR\x07process\x12+\n\x03pty\x18\x02 \x01(\x0b\x32\x14.envd.process.v1.PTYH\x00R\x03pty\x88\x01\x01\x12\x31\n\x05owner\x18\x03 \x01(\x0b\x32\x1b.envd.process.v1.CredentialR\x05ownerB\x06\n\x04_pty\"\x80\x01\n\rUpdateRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x12+\n\x03pty\x18\x02 \x01(\x0b\x32\x14.envd.process.v1.PTYH\x00R\x03pty\x88\x01\x01\x42\x06\n\x04_pty\"\x10\n\x0eUpdateResponse\"\xc6\x03\n\x0cProcessEvent\x12@\n\x05start\x18\x01 \x01(\x0b\x32(.envd.process.v1.ProcessEvent.StartEventH\x00R\x05start\x12=\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\'.envd.process.v1.ProcessEvent.DataEventH\x00R\x04\x64\x61ta\x12:\n\x03\x65nd\x18\x03 \x01(\x0b\x32&.envd.process.v1.ProcessEvent.EndEventH\x00R\x03\x65nd\x1a\x1e\n\nStartEvent\x12\x10\n\x03pid\x18\x01 \x01(\rR\x03pid\x1aI\n\tDataEvent\x12\x18\n\x06stdout\x18\x01 \x01(\x0cH\x00R\x06stdout\x12\x18\n\x06stderr\x18\x02 \x01(\x0cH\x00R\x06stderrB\x08\n\x06output\x1a\x84\x01\n\x08\x45ndEvent\x12\x1b\n\texit_code\x18\x01 \x01(\x11R\x08\x65xitCode\x12\x1e\n\nterminated\x18\x02 \x01(\x08R\nterminated\x12\x16\n\x06status\x18\x03 \x01(\tR\x06status\x12\x19\n\x05\x65rror\x18\x04 \x01(\tH\x00R\x05\x65rror\x88\x01\x01\x42\x08\n\x06_errorB\x07\n\x05\x65vent\"D\n\rStartResponse\x12\x33\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x1d.envd.process.v1.ProcessEventR\x05\x65vent\"F\n\x0f\x43onnectResponse\x12\x33\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x1d.envd.process.v1.ProcessEventR\x05\x65vent\"\x83\x01\n\x10SendInputRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x12\x33\n\x05input\x18\x02 \x01(\x0b\x32\x1d.envd.process.v1.ProcessInputR\x05input\"\x13\n\x11SendInputResponse\"C\n\x0cProcessInput\x12\x16\n\x05stdin\x18\x01 \x01(\x0cH\x00R\x05stdin\x12\x12\n\x03tty\x18\x02 \x01(\x0cH\x00R\x03ttyB\x07\n\x05input\"\xb6\x02\n\x12StreamInputRequest\x12\x46\n\x05start\x18\x01 \x01(\x0b\x32..envd.process.v1.StreamInputRequest.StartEventH\x00R\x05start\x12\x43\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32-.envd.process.v1.StreamInputRequest.DataEventH\x00R\x04\x64\x61ta\x1aH\n\nStartEvent\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x1a@\n\tDataEvent\x12\x33\n\x05input\x18\x02 \x01(\x0b\x32\x1d.envd.process.v1.ProcessInputR\x05inputB\x07\n\x05\x65vent\"\x15\n\x13StreamInputResponse\"\x80\x01\n\x11SendSignalRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x12/\n\x06signal\x18\x02 \x01(\x0e\x32\x17.envd.process.v1.SignalR\x06signal\"\x14\n\x12SendSignalResponse\"L\n\x0e\x43onnectRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\"1\n\x0fProcessSelector\x12\x12\n\x03pid\x18\x01 \x01(\rH\x00R\x03pidB\n\n\x08selector*H\n\x06Signal\x12\x16\n\x12SIGNAL_UNSPECIFIED\x10\x00\x12\x12\n\x0eSIGNAL_SIGTERM\x10\x0f\x12\x12\n\x0eSIGNAL_SIGKILL\x10\t2\xc1\x04\n\x0eProcessService\x12\x43\n\x04List\x12\x1c.envd.process.v1.ListRequest\x1a\x1d.envd.process.v1.ListResponse\x12N\n\x07\x43onnect\x12\x1f.envd.process.v1.ConnectRequest\x1a .envd.process.v1.ConnectResponse0\x01\x12H\n\x05Start\x12\x1d.envd.process.v1.StartRequest\x1a\x1e.envd.process.v1.StartResponse0\x01\x12I\n\x06Update\x12\x1e.envd.process.v1.UpdateRequest\x1a\x1f.envd.process.v1.UpdateResponse\x12Z\n\x0bStreamInput\x12#.envd.process.v1.StreamInputRequest\x1a$.envd.process.v1.StreamInputResponse(\x01\x12R\n\tSendInput\x12!.envd.process.v1.SendInputRequest\x1a\".envd.process.v1.SendInputResponse\x12U\n\nSendSignal\x12\".envd.process.v1.SendSignalRequest\x1a#.envd.process.v1.SendSignalResponseB\x81\x01\n\x13\x63om.envd.process.v1B\x0cProcessProtoP\x01\xa2\x02\x03\x45PX\xaa\x02\x0f\x45nvd.Process.V1\xca\x02\x0f\x45nvd\\Process\\V1\xe2\x02\x1b\x45nvd\\Process\\V1\\GPBMetadata\xea\x02\x11\x45nvd::Process::V1b\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
+ b'\n\x1d\x65nvd/process/v1/process.proto\x12\x0f\x65nvd.process.v1"d\n\x03PTY\x12-\n\x04size\x18\x01 \x01(\x0b\x32\x19.envd.process.v1.PTY.SizeR\x04size\x1a.\n\x04Size\x12\x12\n\x04\x63ols\x18\x01 \x01(\rR\x04\x63ols\x12\x12\n\x04rows\x18\x02 \x01(\rR\x04rows"\xbe\x01\n\rProcessConfig\x12\x10\n\x03\x63md\x18\x01 \x01(\tR\x03\x63md\x12\x12\n\x04\x61rgs\x18\x02 \x03(\tR\x04\x61rgs\x12<\n\x04\x65nvs\x18\x03 \x03(\x0b\x32(.envd.process.v1.ProcessConfig.EnvsEntryR\x04\x65nvs\x12\x10\n\x03\x63wd\x18\x04 \x01(\tR\x03\x63wd\x1a\x37\n\tEnvsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01"\r\n\x0bListRequest"L\n\x0cListResponse\x12<\n\tprocesses\x18\x01 \x03(\x0b\x32\x1e.envd.process.v1.ProcessConfigR\tprocesses"8\n\nCredential\x12\x1c\n\x08username\x18\x01 \x01(\tH\x00R\x08usernameB\x0c\n\ncredential"\xb0\x01\n\x0cStartRequest\x12\x38\n\x07process\x18\x01 \x01(\x0b\x32\x1e.envd.process.v1.ProcessConfigR\x07process\x12+\n\x03pty\x18\x02 \x01(\x0b\x32\x14.envd.process.v1.PTYH\x00R\x03pty\x88\x01\x01\x12\x31\n\x05owner\x18\x03 \x01(\x0b\x32\x1b.envd.process.v1.CredentialR\x05ownerB\x06\n\x04_pty"\x80\x01\n\rUpdateRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x12+\n\x03pty\x18\x02 \x01(\x0b\x32\x14.envd.process.v1.PTYH\x00R\x03pty\x88\x01\x01\x42\x06\n\x04_pty"\x10\n\x0eUpdateResponse"\xda\x03\n\x0cProcessEvent\x12@\n\x05start\x18\x01 \x01(\x0b\x32(.envd.process.v1.ProcessEvent.StartEventH\x00R\x05start\x12=\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\'.envd.process.v1.ProcessEvent.DataEventH\x00R\x04\x64\x61ta\x12:\n\x03\x65nd\x18\x03 \x01(\x0b\x32&.envd.process.v1.ProcessEvent.EndEventH\x00R\x03\x65nd\x1a\x1e\n\nStartEvent\x12\x10\n\x03pid\x18\x01 \x01(\rR\x03pid\x1a]\n\tDataEvent\x12\x18\n\x06stdout\x18\x01 \x01(\x0cH\x00R\x06stdout\x12\x18\n\x06stderr\x18\x02 \x01(\x0cH\x00R\x06stderr\x12\x12\n\x03pty\x18\x03 \x01(\x0cH\x00R\x03ptyB\x08\n\x06output\x1a\x84\x01\n\x08\x45ndEvent\x12\x1b\n\texit_code\x18\x01 \x01(\x11R\x08\x65xitCode\x12\x1e\n\nterminated\x18\x02 \x01(\x08R\nterminated\x12\x16\n\x06status\x18\x03 \x01(\tR\x06status\x12\x19\n\x05\x65rror\x18\x04 \x01(\tH\x00R\x05\x65rror\x88\x01\x01\x42\x08\n\x06_errorB\x07\n\x05\x65vent"D\n\rStartResponse\x12\x33\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x1d.envd.process.v1.ProcessEventR\x05\x65vent"F\n\x0f\x43onnectResponse\x12\x33\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x1d.envd.process.v1.ProcessEventR\x05\x65vent"\x83\x01\n\x10SendInputRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x12\x33\n\x05input\x18\x02 \x01(\x0b\x32\x1d.envd.process.v1.ProcessInputR\x05input"\x13\n\x11SendInputResponse"C\n\x0cProcessInput\x12\x16\n\x05stdin\x18\x01 \x01(\x0cH\x00R\x05stdin\x12\x12\n\x03pty\x18\x02 \x01(\x0cH\x00R\x03ptyB\x07\n\x05input"\xb6\x02\n\x12StreamInputRequest\x12\x46\n\x05start\x18\x01 \x01(\x0b\x32..envd.process.v1.StreamInputRequest.StartEventH\x00R\x05start\x12\x43\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32-.envd.process.v1.StreamInputRequest.DataEventH\x00R\x04\x64\x61ta\x1aH\n\nStartEvent\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x1a@\n\tDataEvent\x12\x33\n\x05input\x18\x02 \x01(\x0b\x32\x1d.envd.process.v1.ProcessInputR\x05inputB\x07\n\x05\x65vent"\x15\n\x13StreamInputResponse"\x80\x01\n\x11SendSignalRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process\x12/\n\x06signal\x18\x02 \x01(\x0e\x32\x17.envd.process.v1.SignalR\x06signal"\x14\n\x12SendSignalResponse"L\n\x0e\x43onnectRequest\x12:\n\x07process\x18\x01 \x01(\x0b\x32 .envd.process.v1.ProcessSelectorR\x07process"1\n\x0fProcessSelector\x12\x12\n\x03pid\x18\x01 \x01(\rH\x00R\x03pidB\n\n\x08selector*H\n\x06Signal\x12\x16\n\x12SIGNAL_UNSPECIFIED\x10\x00\x12\x12\n\x0eSIGNAL_SIGTERM\x10\x0f\x12\x12\n\x0eSIGNAL_SIGKILL\x10\t2\xc1\x04\n\x0eProcessService\x12\x43\n\x04List\x12\x1c.envd.process.v1.ListRequest\x1a\x1d.envd.process.v1.ListResponse\x12N\n\x07\x43onnect\x12\x1f.envd.process.v1.ConnectRequest\x1a .envd.process.v1.ConnectResponse0\x01\x12H\n\x05Start\x12\x1d.envd.process.v1.StartRequest\x1a\x1e.envd.process.v1.StartResponse0\x01\x12I\n\x06Update\x12\x1e.envd.process.v1.UpdateRequest\x1a\x1f.envd.process.v1.UpdateResponse\x12Z\n\x0bStreamInput\x12#.envd.process.v1.StreamInputRequest\x1a$.envd.process.v1.StreamInputResponse(\x01\x12R\n\tSendInput\x12!.envd.process.v1.SendInputRequest\x1a".envd.process.v1.SendInputResponse\x12U\n\nSendSignal\x12".envd.process.v1.SendSignalRequest\x1a#.envd.process.v1.SendSignalResponseB\x81\x01\n\x13\x63om.envd.process.v1B\x0cProcessProtoP\x01\xa2\x02\x03\x45PX\xaa\x02\x0f\x45nvd.Process.V1\xca\x02\x0f\x45nvd\\Process\\V1\xe2\x02\x1b\x45nvd\\Process\\V1\\GPBMetadata\xea\x02\x11\x45nvd::Process::V1b\x06proto3'
+)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
-_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'envd.process.v1.process_pb2', _globals)
+_builder.BuildTopDescriptorsAndMessages(
+ DESCRIPTOR, "envd.process.v1.process_pb2", _globals
+)
if not _descriptor._USE_C_DESCRIPTORS:
- _globals['DESCRIPTOR']._loaded_options = None
- _globals['DESCRIPTOR']._serialized_options = b'\n\023com.envd.process.v1B\014ProcessProtoP\001\242\002\003EPX\252\002\017Envd.Process.V1\312\002\017Envd\\Process\\V1\342\002\033Envd\\Process\\V1\\GPBMetadata\352\002\021Envd::Process::V1'
- _globals['_PROCESSCONFIG_ENVSENTRY']._loaded_options = None
- _globals['_PROCESSCONFIG_ENVSENTRY']._serialized_options = b'8\001'
- _globals['_SIGNAL']._serialized_start=2265
- _globals['_SIGNAL']._serialized_end=2337
- _globals['_PTY']._serialized_start=50
- _globals['_PTY']._serialized_end=150
- _globals['_PTY_SIZE']._serialized_start=104
- _globals['_PTY_SIZE']._serialized_end=150
- _globals['_PROCESSCONFIG']._serialized_start=153
- _globals['_PROCESSCONFIG']._serialized_end=343
- _globals['_PROCESSCONFIG_ENVSENTRY']._serialized_start=288
- _globals['_PROCESSCONFIG_ENVSENTRY']._serialized_end=343
- _globals['_LISTREQUEST']._serialized_start=345
- _globals['_LISTREQUEST']._serialized_end=358
- _globals['_LISTRESPONSE']._serialized_start=360
- _globals['_LISTRESPONSE']._serialized_end=436
- _globals['_CREDENTIAL']._serialized_start=438
- _globals['_CREDENTIAL']._serialized_end=494
- _globals['_STARTREQUEST']._serialized_start=497
- _globals['_STARTREQUEST']._serialized_end=673
- _globals['_UPDATEREQUEST']._serialized_start=676
- _globals['_UPDATEREQUEST']._serialized_end=804
- _globals['_UPDATERESPONSE']._serialized_start=806
- _globals['_UPDATERESPONSE']._serialized_end=822
- _globals['_PROCESSEVENT']._serialized_start=825
- _globals['_PROCESSEVENT']._serialized_end=1279
- _globals['_PROCESSEVENT_STARTEVENT']._serialized_start=1030
- _globals['_PROCESSEVENT_STARTEVENT']._serialized_end=1060
- _globals['_PROCESSEVENT_DATAEVENT']._serialized_start=1062
- _globals['_PROCESSEVENT_DATAEVENT']._serialized_end=1135
- _globals['_PROCESSEVENT_ENDEVENT']._serialized_start=1138
- _globals['_PROCESSEVENT_ENDEVENT']._serialized_end=1270
- _globals['_STARTRESPONSE']._serialized_start=1281
- _globals['_STARTRESPONSE']._serialized_end=1349
- _globals['_CONNECTRESPONSE']._serialized_start=1351
- _globals['_CONNECTRESPONSE']._serialized_end=1421
- _globals['_SENDINPUTREQUEST']._serialized_start=1424
- _globals['_SENDINPUTREQUEST']._serialized_end=1555
- _globals['_SENDINPUTRESPONSE']._serialized_start=1557
- _globals['_SENDINPUTRESPONSE']._serialized_end=1576
- _globals['_PROCESSINPUT']._serialized_start=1578
- _globals['_PROCESSINPUT']._serialized_end=1645
- _globals['_STREAMINPUTREQUEST']._serialized_start=1648
- _globals['_STREAMINPUTREQUEST']._serialized_end=1958
- _globals['_STREAMINPUTREQUEST_STARTEVENT']._serialized_start=1811
- _globals['_STREAMINPUTREQUEST_STARTEVENT']._serialized_end=1883
- _globals['_STREAMINPUTREQUEST_DATAEVENT']._serialized_start=1885
- _globals['_STREAMINPUTREQUEST_DATAEVENT']._serialized_end=1949
- _globals['_STREAMINPUTRESPONSE']._serialized_start=1960
- _globals['_STREAMINPUTRESPONSE']._serialized_end=1981
- _globals['_SENDSIGNALREQUEST']._serialized_start=1984
- _globals['_SENDSIGNALREQUEST']._serialized_end=2112
- _globals['_SENDSIGNALRESPONSE']._serialized_start=2114
- _globals['_SENDSIGNALRESPONSE']._serialized_end=2134
- _globals['_CONNECTREQUEST']._serialized_start=2136
- _globals['_CONNECTREQUEST']._serialized_end=2212
- _globals['_PROCESSSELECTOR']._serialized_start=2214
- _globals['_PROCESSSELECTOR']._serialized_end=2263
- _globals['_PROCESSSERVICE']._serialized_start=2340
- _globals['_PROCESSSERVICE']._serialized_end=2917
+ _globals["DESCRIPTOR"]._loaded_options = None
+ _globals[
+ "DESCRIPTOR"
+ ]._serialized_options = b"\n\023com.envd.process.v1B\014ProcessProtoP\001\242\002\003EPX\252\002\017Envd.Process.V1\312\002\017Envd\\Process\\V1\342\002\033Envd\\Process\\V1\\GPBMetadata\352\002\021Envd::Process::V1"
+ _globals["_PROCESSCONFIG_ENVSENTRY"]._loaded_options = None
+ _globals["_PROCESSCONFIG_ENVSENTRY"]._serialized_options = b"8\001"
+ _globals["_SIGNAL"]._serialized_start = 2285
+ _globals["_SIGNAL"]._serialized_end = 2357
+ _globals["_PTY"]._serialized_start = 50
+ _globals["_PTY"]._serialized_end = 150
+ _globals["_PTY_SIZE"]._serialized_start = 104
+ _globals["_PTY_SIZE"]._serialized_end = 150
+ _globals["_PROCESSCONFIG"]._serialized_start = 153
+ _globals["_PROCESSCONFIG"]._serialized_end = 343
+ _globals["_PROCESSCONFIG_ENVSENTRY"]._serialized_start = 288
+ _globals["_PROCESSCONFIG_ENVSENTRY"]._serialized_end = 343
+ _globals["_LISTREQUEST"]._serialized_start = 345
+ _globals["_LISTREQUEST"]._serialized_end = 358
+ _globals["_LISTRESPONSE"]._serialized_start = 360
+ _globals["_LISTRESPONSE"]._serialized_end = 436
+ _globals["_CREDENTIAL"]._serialized_start = 438
+ _globals["_CREDENTIAL"]._serialized_end = 494
+ _globals["_STARTREQUEST"]._serialized_start = 497
+ _globals["_STARTREQUEST"]._serialized_end = 673
+ _globals["_UPDATEREQUEST"]._serialized_start = 676
+ _globals["_UPDATEREQUEST"]._serialized_end = 804
+ _globals["_UPDATERESPONSE"]._serialized_start = 806
+ _globals["_UPDATERESPONSE"]._serialized_end = 822
+ _globals["_PROCESSEVENT"]._serialized_start = 825
+ _globals["_PROCESSEVENT"]._serialized_end = 1299
+ _globals["_PROCESSEVENT_STARTEVENT"]._serialized_start = 1030
+ _globals["_PROCESSEVENT_STARTEVENT"]._serialized_end = 1060
+ _globals["_PROCESSEVENT_DATAEVENT"]._serialized_start = 1062
+ _globals["_PROCESSEVENT_DATAEVENT"]._serialized_end = 1155
+ _globals["_PROCESSEVENT_ENDEVENT"]._serialized_start = 1158
+ _globals["_PROCESSEVENT_ENDEVENT"]._serialized_end = 1290
+ _globals["_STARTRESPONSE"]._serialized_start = 1301
+ _globals["_STARTRESPONSE"]._serialized_end = 1369
+ _globals["_CONNECTRESPONSE"]._serialized_start = 1371
+ _globals["_CONNECTRESPONSE"]._serialized_end = 1441
+ _globals["_SENDINPUTREQUEST"]._serialized_start = 1444
+ _globals["_SENDINPUTREQUEST"]._serialized_end = 1575
+ _globals["_SENDINPUTRESPONSE"]._serialized_start = 1577
+ _globals["_SENDINPUTRESPONSE"]._serialized_end = 1596
+ _globals["_PROCESSINPUT"]._serialized_start = 1598
+ _globals["_PROCESSINPUT"]._serialized_end = 1665
+ _globals["_STREAMINPUTREQUEST"]._serialized_start = 1668
+ _globals["_STREAMINPUTREQUEST"]._serialized_end = 1978
+ _globals["_STREAMINPUTREQUEST_STARTEVENT"]._serialized_start = 1831
+ _globals["_STREAMINPUTREQUEST_STARTEVENT"]._serialized_end = 1903
+ _globals["_STREAMINPUTREQUEST_DATAEVENT"]._serialized_start = 1905
+ _globals["_STREAMINPUTREQUEST_DATAEVENT"]._serialized_end = 1969
+ _globals["_STREAMINPUTRESPONSE"]._serialized_start = 1980
+ _globals["_STREAMINPUTRESPONSE"]._serialized_end = 2001
+ _globals["_SENDSIGNALREQUEST"]._serialized_start = 2004
+ _globals["_SENDSIGNALREQUEST"]._serialized_end = 2132
+ _globals["_SENDSIGNALRESPONSE"]._serialized_start = 2134
+ _globals["_SENDSIGNALRESPONSE"]._serialized_end = 2154
+ _globals["_CONNECTREQUEST"]._serialized_start = 2156
+ _globals["_CONNECTREQUEST"]._serialized_end = 2232
+ _globals["_PROCESSSELECTOR"]._serialized_start = 2234
+ _globals["_PROCESSSELECTOR"]._serialized_end = 2283
+ _globals["_PROCESSSERVICE"]._serialized_start = 2360
+ _globals["_PROCESSSERVICE"]._serialized_end = 2937
# @@protoc_insertion_point(module_scope)
diff --git a/packages/python-sdk/envd/process/v1/process_pb2.pyi b/packages/python-sdk/envd/process/v1/process_pb2.pyi
index 63f05f848..6338afd33 100644
--- a/packages/python-sdk/envd/process/v1/process_pb2.pyi
+++ b/packages/python-sdk/envd/process/v1/process_pb2.pyi
@@ -2,7 +2,13 @@ from google.protobuf.internal import containers as _containers
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
-from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
+from typing import (
+ ClassVar as _ClassVar,
+ Iterable as _Iterable,
+ Mapping as _Mapping,
+ Optional as _Optional,
+ Union as _Union,
+)
DESCRIPTOR: _descriptor.FileDescriptor
@@ -11,32 +17,39 @@ class Signal(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
SIGNAL_UNSPECIFIED: _ClassVar[Signal]
SIGNAL_SIGTERM: _ClassVar[Signal]
SIGNAL_SIGKILL: _ClassVar[Signal]
+
SIGNAL_UNSPECIFIED: Signal
SIGNAL_SIGTERM: Signal
SIGNAL_SIGKILL: Signal
class PTY(_message.Message):
__slots__ = ("size",)
+
class Size(_message.Message):
__slots__ = ("cols", "rows")
COLS_FIELD_NUMBER: _ClassVar[int]
ROWS_FIELD_NUMBER: _ClassVar[int]
cols: int
rows: int
- def __init__(self, cols: _Optional[int] = ..., rows: _Optional[int] = ...) -> None: ...
+ def __init__(
+ self, cols: _Optional[int] = ..., rows: _Optional[int] = ...
+ ) -> None: ...
SIZE_FIELD_NUMBER: _ClassVar[int]
size: PTY.Size
def __init__(self, size: _Optional[_Union[PTY.Size, _Mapping]] = ...) -> None: ...
class ProcessConfig(_message.Message):
__slots__ = ("cmd", "args", "envs", "cwd")
+
class EnvsEntry(_message.Message):
__slots__ = ("key", "value")
KEY_FIELD_NUMBER: _ClassVar[int]
VALUE_FIELD_NUMBER: _ClassVar[int]
key: str
value: str
- def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
+ def __init__(
+ self, key: _Optional[str] = ..., value: _Optional[str] = ...
+ ) -> None: ...
CMD_FIELD_NUMBER: _ClassVar[int]
ARGS_FIELD_NUMBER: _ClassVar[int]
ENVS_FIELD_NUMBER: _ClassVar[int]
@@ -45,7 +58,13 @@ class ProcessConfig(_message.Message):
args: _containers.RepeatedScalarFieldContainer[str]
envs: _containers.ScalarMap[str, str]
cwd: str
- def __init__(self, cmd: _Optional[str] = ..., args: _Optional[_Iterable[str]] = ..., envs: _Optional[_Mapping[str, str]] = ..., cwd: _Optional[str] = ...) -> None: ...
+ def __init__(
+ self,
+ cmd: _Optional[str] = ...,
+ args: _Optional[_Iterable[str]] = ...,
+ envs: _Optional[_Mapping[str, str]] = ...,
+ cwd: _Optional[str] = ...,
+ ) -> None: ...
class ListRequest(_message.Message):
__slots__ = ()
@@ -55,7 +74,9 @@ class ListResponse(_message.Message):
__slots__ = ("processes",)
PROCESSES_FIELD_NUMBER: _ClassVar[int]
processes: _containers.RepeatedCompositeFieldContainer[ProcessConfig]
- def __init__(self, processes: _Optional[_Iterable[_Union[ProcessConfig, _Mapping]]] = ...) -> None: ...
+ def __init__(
+ self, processes: _Optional[_Iterable[_Union[ProcessConfig, _Mapping]]] = ...
+ ) -> None: ...
class Credential(_message.Message):
__slots__ = ("username",)
@@ -71,7 +92,12 @@ class StartRequest(_message.Message):
process: ProcessConfig
pty: PTY
owner: Credential
- def __init__(self, process: _Optional[_Union[ProcessConfig, _Mapping]] = ..., pty: _Optional[_Union[PTY, _Mapping]] = ..., owner: _Optional[_Union[Credential, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self,
+ process: _Optional[_Union[ProcessConfig, _Mapping]] = ...,
+ pty: _Optional[_Union[PTY, _Mapping]] = ...,
+ owner: _Optional[_Union[Credential, _Mapping]] = ...,
+ ) -> None: ...
class UpdateRequest(_message.Message):
__slots__ = ("process", "pty")
@@ -79,7 +105,11 @@ class UpdateRequest(_message.Message):
PTY_FIELD_NUMBER: _ClassVar[int]
process: ProcessSelector
pty: PTY
- def __init__(self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ..., pty: _Optional[_Union[PTY, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self,
+ process: _Optional[_Union[ProcessSelector, _Mapping]] = ...,
+ pty: _Optional[_Union[PTY, _Mapping]] = ...,
+ ) -> None: ...
class UpdateResponse(_message.Message):
__slots__ = ()
@@ -87,18 +117,28 @@ class UpdateResponse(_message.Message):
class ProcessEvent(_message.Message):
__slots__ = ("start", "data", "end")
+
class StartEvent(_message.Message):
__slots__ = ("pid",)
PID_FIELD_NUMBER: _ClassVar[int]
pid: int
def __init__(self, pid: _Optional[int] = ...) -> None: ...
+
class DataEvent(_message.Message):
- __slots__ = ("stdout", "stderr")
+ __slots__ = ("stdout", "stderr", "pty")
STDOUT_FIELD_NUMBER: _ClassVar[int]
STDERR_FIELD_NUMBER: _ClassVar[int]
+ PTY_FIELD_NUMBER: _ClassVar[int]
stdout: bytes
stderr: bytes
- def __init__(self, stdout: _Optional[bytes] = ..., stderr: _Optional[bytes] = ...) -> None: ...
+ pty: bytes
+ def __init__(
+ self,
+ stdout: _Optional[bytes] = ...,
+ stderr: _Optional[bytes] = ...,
+ pty: _Optional[bytes] = ...,
+ ) -> None: ...
+
class EndEvent(_message.Message):
__slots__ = ("exit_code", "terminated", "status", "error")
EXIT_CODE_FIELD_NUMBER: _ClassVar[int]
@@ -109,26 +149,41 @@ class ProcessEvent(_message.Message):
terminated: bool
status: str
error: str
- def __init__(self, exit_code: _Optional[int] = ..., terminated: bool = ..., status: _Optional[str] = ..., error: _Optional[str] = ...) -> None: ...
+ def __init__(
+ self,
+ exit_code: _Optional[int] = ...,
+ terminated: bool = ...,
+ status: _Optional[str] = ...,
+ error: _Optional[str] = ...,
+ ) -> None: ...
START_FIELD_NUMBER: _ClassVar[int]
DATA_FIELD_NUMBER: _ClassVar[int]
END_FIELD_NUMBER: _ClassVar[int]
start: ProcessEvent.StartEvent
data: ProcessEvent.DataEvent
end: ProcessEvent.EndEvent
- def __init__(self, start: _Optional[_Union[ProcessEvent.StartEvent, _Mapping]] = ..., data: _Optional[_Union[ProcessEvent.DataEvent, _Mapping]] = ..., end: _Optional[_Union[ProcessEvent.EndEvent, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self,
+ start: _Optional[_Union[ProcessEvent.StartEvent, _Mapping]] = ...,
+ data: _Optional[_Union[ProcessEvent.DataEvent, _Mapping]] = ...,
+ end: _Optional[_Union[ProcessEvent.EndEvent, _Mapping]] = ...,
+ ) -> None: ...
class StartResponse(_message.Message):
__slots__ = ("event",)
EVENT_FIELD_NUMBER: _ClassVar[int]
event: ProcessEvent
- def __init__(self, event: _Optional[_Union[ProcessEvent, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self, event: _Optional[_Union[ProcessEvent, _Mapping]] = ...
+ ) -> None: ...
class ConnectResponse(_message.Message):
__slots__ = ("event",)
EVENT_FIELD_NUMBER: _ClassVar[int]
event: ProcessEvent
- def __init__(self, event: _Optional[_Union[ProcessEvent, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self, event: _Optional[_Union[ProcessEvent, _Mapping]] = ...
+ ) -> None: ...
class SendInputRequest(_message.Message):
__slots__ = ("process", "input")
@@ -136,37 +191,53 @@ class SendInputRequest(_message.Message):
INPUT_FIELD_NUMBER: _ClassVar[int]
process: ProcessSelector
input: ProcessInput
- def __init__(self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ..., input: _Optional[_Union[ProcessInput, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self,
+ process: _Optional[_Union[ProcessSelector, _Mapping]] = ...,
+ input: _Optional[_Union[ProcessInput, _Mapping]] = ...,
+ ) -> None: ...
class SendInputResponse(_message.Message):
__slots__ = ()
def __init__(self) -> None: ...
class ProcessInput(_message.Message):
- __slots__ = ("stdin", "tty")
+ __slots__ = ("stdin", "pty")
STDIN_FIELD_NUMBER: _ClassVar[int]
- TTY_FIELD_NUMBER: _ClassVar[int]
+ PTY_FIELD_NUMBER: _ClassVar[int]
stdin: bytes
- tty: bytes
- def __init__(self, stdin: _Optional[bytes] = ..., tty: _Optional[bytes] = ...) -> None: ...
+ pty: bytes
+ def __init__(
+ self, stdin: _Optional[bytes] = ..., pty: _Optional[bytes] = ...
+ ) -> None: ...
class StreamInputRequest(_message.Message):
__slots__ = ("start", "data")
+
class StartEvent(_message.Message):
__slots__ = ("process",)
PROCESS_FIELD_NUMBER: _ClassVar[int]
process: ProcessSelector
- def __init__(self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ...
+ ) -> None: ...
+
class DataEvent(_message.Message):
__slots__ = ("input",)
INPUT_FIELD_NUMBER: _ClassVar[int]
input: ProcessInput
- def __init__(self, input: _Optional[_Union[ProcessInput, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self, input: _Optional[_Union[ProcessInput, _Mapping]] = ...
+ ) -> None: ...
START_FIELD_NUMBER: _ClassVar[int]
DATA_FIELD_NUMBER: _ClassVar[int]
start: StreamInputRequest.StartEvent
data: StreamInputRequest.DataEvent
- def __init__(self, start: _Optional[_Union[StreamInputRequest.StartEvent, _Mapping]] = ..., data: _Optional[_Union[StreamInputRequest.DataEvent, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self,
+ start: _Optional[_Union[StreamInputRequest.StartEvent, _Mapping]] = ...,
+ data: _Optional[_Union[StreamInputRequest.DataEvent, _Mapping]] = ...,
+ ) -> None: ...
class StreamInputResponse(_message.Message):
__slots__ = ()
@@ -178,7 +249,11 @@ class SendSignalRequest(_message.Message):
SIGNAL_FIELD_NUMBER: _ClassVar[int]
process: ProcessSelector
signal: Signal
- def __init__(self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ..., signal: _Optional[_Union[Signal, str]] = ...) -> None: ...
+ def __init__(
+ self,
+ process: _Optional[_Union[ProcessSelector, _Mapping]] = ...,
+ signal: _Optional[_Union[Signal, str]] = ...,
+ ) -> None: ...
class SendSignalResponse(_message.Message):
__slots__ = ()
@@ -188,7 +263,9 @@ class ConnectRequest(_message.Message):
__slots__ = ("process",)
PROCESS_FIELD_NUMBER: _ClassVar[int]
process: ProcessSelector
- def __init__(self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ...) -> None: ...
+ def __init__(
+ self, process: _Optional[_Union[ProcessSelector, _Mapping]] = ...
+ ) -> None: ...
class ProcessSelector(_message.Message):
__slots__ = ("pid",)
diff --git a/spec/envd/process/v1/process.proto b/spec/envd/process/v1/process.proto
index cdf7b47db..dc74d9a10 100644
--- a/spec/envd/process/v1/process.proto
+++ b/spec/envd/process/v1/process.proto
@@ -75,6 +75,7 @@ message ProcessEvent {
oneof output {
bytes stdout = 1;
bytes stderr = 2;
+ bytes pty = 3;
}
}
@@ -105,7 +106,7 @@ message SendInputResponse {}
message ProcessInput {
oneof input {
bytes stdin = 1;
- bytes tty = 2;
+ bytes pty = 2;
}
}