import { fs, port, PitcherRequest, PitcherResponse, PitcherResponseStatus, shell, setup, task, system } from "./pitcher-protocol"; import { Event } from "./utils/event"; export interface IAgentClientShells { onShellExited: Event<{ shellId: string; exitCode: number; }>; onShellTerminated: Event; onShellOut: Event; create(projectPath: string, size: shell.ShellSize, command?: string, type?: shell.ShellProcessType, isSystemShell?: boolean): Promise; rename(shellId: shell.ShellId, name: string): Promise; getShells(): Promise; open(shellId: shell.ShellId, size: shell.ShellSize): Promise; delete(shellId: shell.ShellId): Promise; restart(shellId: shell.ShellId): Promise; send(shellId: shell.ShellId, input: string, size: shell.ShellSize): Promise; } export type RawFsResult = { type: "ok"; result: T; } | { type: "error"; error: string; errno: number | null; }; export type PickRawFsResult = RawFsResult["result"]>; export interface IAgentClientFS { readFile(path: string): Promise>; readdir(path: string): Promise>; writeFile(path: string, content: Uint8Array, create?: boolean, overwrite?: boolean): Promise>; stat(path: string): Promise>; copy(from: string, to: string, recursive?: boolean, overwrite?: boolean): Promise>; rename(from: string, to: string, overwrite?: boolean): Promise>; remove(path: string, recursive?: boolean): Promise>; mkdir(path: string, recursive?: boolean): Promise>; watch(path: string, options: { readonly recursive?: boolean; readonly excludes?: readonly string[]; }, onEvent: (watchEvent: fs.FSWatchEvent) => void): Promise<(PickRawFsResult<"fs/watch"> & { type: "error"; }) | { type: "success"; dispose(): void; }>; download(path?: string): Promise<{ downloadUrl: string; }>; } export interface IAgentClientPorts { onPortsUpdated: Event; getPorts(): Promise; } export interface IAgentClientSetup { onSetupProgressUpdate: Event; getProgress(): Promise; init(): Promise; } export interface IAgentClientTasks { onTaskUpdate: Event; getTasks(): Promise; getTask(taskId: string): Promise; runTask(taskId: string): Promise; stopTask(taskId: string): Promise; } export interface IAgentClientSystem { onInitStatusUpdate: Event; update(): Promise>; } export type IAgentClientState = "CONNECTED" | "CONNECTING" | "RECONNECTING" | "DISCONNECTED" | "HIBERNATED"; export interface IAgentClient { sandboxId: string; workspacePath: string; isUpToDate: boolean; state: IAgentClientState; onStateChange: Event; shells: IAgentClientShells; fs: IAgentClientFS; ports: IAgentClientPorts; setup: IAgentClientSetup; tasks: IAgentClientTasks; system: IAgentClientSystem; ping(): void; disconnect(): Promise; reconnect(): Promise; dispose(): void; }