@codesandbox/sdk
Version:
The CodeSandbox SDK
52 lines (51 loc) • 1.73 kB
TypeScript
import * as protocol from "../pitcher-protocol";
import { Disposable } from "../utils/disposable";
import { ShellRunOpts } from "./commands";
import { type IAgentClient } from "../agent-client-interface";
import { Tracer } from "@opentelemetry/api";
export type ShellSize = {
cols: number;
rows: number;
};
export declare const DEFAULT_SHELL_SIZE: ShellSize;
export declare class Terminals {
private agentClient;
private disposable;
private tracer?;
constructor(sessionDisposable: Disposable, agentClient: IAgentClient, tracer?: Tracer);
private withSpan;
create(command?: "bash" | "zsh" | "fish" | "ksh" | "dash", opts?: ShellRunOpts): Promise<Terminal>;
get(shellId: string): Promise<Terminal | undefined>;
/**
* Gets all terminals running in the current sandbox
*/
getAll(): Promise<Terminal[]>;
}
export declare class Terminal {
private shell;
private agentClient;
private disposable;
private tracer?;
private onOutputEmitter;
readonly onOutput: import("../utils/event").Event<string>;
private output;
/**
* Gets the ID of the terminal. Can be used to open it again.
*/
get id(): string;
/**
* Gets the name of the terminal.
*/
get name(): string;
constructor(shell: protocol.shell.ShellDTO & {
buffer?: string[];
}, agentClient: IAgentClient, tracer?: Tracer);
private withSpan;
/**
* Open the terminal and get its current output, subscribes to future output
*/
open(dimensions?: ShellSize): Promise<string>;
write(input: string, dimensions?: ShellSize): Promise<void>;
run(input: string, dimensions?: ShellSize): Promise<void>;
kill(): Promise<void>;
}