import { Disposable } from "../utils/disposable"; import { IAgentClient } from "../agent-client-interface"; import * as protocol from "../pitcher-protocol"; import { Tracer } from "@opentelemetry/api"; type ShellSize = { cols: number; rows: number; }; export type ShellRunOpts = { dimensions?: ShellSize; name?: string; env?: Record; cwd?: string; /** * Run the command in the global session instead of the current session. This makes * any environment variables available to all users of the Sandbox. */ asGlobalSession?: boolean; }; export type CommandStatus = "RUNNING" | "FINISHED" | "ERROR" | "KILLED" | "RESTARTING"; /** * Error thrown when a command fails with a non-zero exit code. */ export declare class CommandError extends Error { /** * The exit code returned by the command. */ exitCode: number; /** * The output produced by the command. */ output: string; constructor(message: string, exitCode: number, output: string); } export declare class SandboxCommands { private agentClient; private disposable; private tracer?; constructor(sessionDisposable: Disposable, agentClient: IAgentClient, tracer?: Tracer); private withSpan; /** * Create and run command in a new shell. Allows you to listen to the output and kill the command. */ runBackground(command: string | string[], opts?: ShellRunOpts): Promise; /** * Run a command in a new shell and wait for it to finish, returning its output. */ run(command: string | string[], opts?: ShellRunOpts): Promise; /** * Get all running commands. */ getAll(): Promise; } export declare function isCommandShell(shell: protocol.shell.ShellDTO): shell is protocol.shell.CommandShellDTO; export declare class Command { #private; private agentClient; private shell; private disposable; private tracer?; private onOutputEmitter; /** * An event that is emitted when the command outputs something. */ readonly onOutput: import("../utils/event").Event; private onStatusChangeEmitter; /** * An event that is emitted when the command status changes. */ readonly onStatusChange: import("../utils/event").Event; private barrier; private output; /** * The exit code of the command, available after it completes. */ private exitCode?; get status(): CommandStatus; set status(value: CommandStatus); /** * The command that was run */ command: string; /** * The name of the command */ name?: string; constructor(agentClient: IAgentClient, shell: protocol.shell.ShellDTO & { buffer?: string[]; }, details: { command: string; name?: string; }, tracer?: Tracer); private withSpan; /** * Open the command and get its current output, subscribes to future output */ open(dimensions?: { cols: number; rows: number; }): Promise; /** * Wait for the command to finish with its returned output */ waitUntilComplete(): Promise; /** * Kill the command and remove it from the session. */ kill(): Promise; /** * Restart the command. */ restart(): Promise; } export {};