orgo
Version:
Computers for AI agents
213 lines (205 loc) • 6.7 kB
TypeScript
/**
* Core types for Orgo SDK
*/
interface ProjectInfo {
id: string;
name: string;
user_id: string;
created_at: string;
computer_count?: number;
}
interface ComputerInfo {
id: string;
name: string;
project_name: string;
os: 'linux' | 'windows';
ram: 1 | 2 | 4 | 8 | 16 | 32 | 64;
cpu: 1 | 2 | 4 | 8 | 16;
gpu: 'none' | 'a10' | 'l40s' | 'a100-40gb' | 'a100-80gb';
status: string;
url?: string;
created_at: string;
}
interface ComputerConfig {
os?: 'linux' | 'windows';
ram?: 1 | 2 | 4 | 8 | 16 | 32 | 64;
cpu?: 1 | 2 | 4 | 8 | 16;
gpu?: 'none' | 'a10' | 'l40s' | 'a100-40gb' | 'a100-80gb';
}
interface ComputerStatus {
id: string;
name: string;
status: string;
[key: string]: unknown;
}
interface ScrollOptions {
direction: 'up' | 'down';
amount?: number;
}
interface ScreenshotOptions {
format?: 'base64' | 'buffer';
}
interface ExecResponse {
success: boolean;
output: string;
error?: string;
error_type?: string;
timeout?: boolean;
}
interface StreamStartResponse {
success: boolean;
status: string;
pid?: number;
}
interface StreamStatusResponse {
status: 'idle' | 'streaming' | 'terminated';
start_time?: string;
pid?: number;
}
interface StreamStopResponse {
success: boolean;
}
interface PromptOptions {
instruction: string;
provider?: string;
model?: string;
displayWidth?: number;
displayHeight?: number;
callback?: PromptCallback;
thinkingEnabled?: boolean;
thinkingBudget?: number;
maxTokens?: number;
maxIterations?: number;
maxSavedScreenshots?: number;
apiKey?: string;
}
type PromptCallback = (type: string, data: unknown) => void;
interface PromptMessage {
role: 'user' | 'assistant';
content: string | unknown[];
}
/**
* Project class for managing Orgo projects
*/
declare class Project {
private apiKey;
private baseApiUrl?;
private api;
name: string;
id: string;
private _info;
private constructor();
/**
* Create or connect to a Project
*
* @param options Configuration options
* @param options.name Project name. If exists, connects to it. If not, creates it.
* @param options.apiKey Orgo API key (defaults to ORGO_API_KEY env var)
* @param options.baseApiUrl Custom API URL (optional)
*/
static create(options?: {
name?: string;
apiKey?: string;
baseApiUrl?: string;
}): Promise<Project>;
private _initializeProject;
get info(): ProjectInfo;
status(): Promise<ProjectInfo>;
destroy(): Promise<unknown>;
listComputers(): Promise<ComputerInfo[]>;
getComputer(computerName?: string): Promise<ComputerInfo | null>;
}
/**
* Computer class for interacting with Orgo virtual environments
*/
declare class Computer {
private apiKey;
private baseApiUrl?;
private api;
projectName?: string;
projectId?: string;
computerId: string;
name?: string;
private os;
private ram;
private cpu;
private gpu;
private constructor();
/**
* Create a new Computer instance
*
* @param options Configuration options
* @param options.project Project name (string) or Project instance. If not provided, creates a new project.
* @param options.name Computer name within the project (optional, auto-generated if not provided)
* @param options.computerId Existing computer ID to connect to (optional)
* @param options.apiKey Orgo API key (defaults to ORGO_API_KEY env var)
* @param options.baseApiUrl Custom API URL (optional)
* @param options.ram RAM in GB (1, 2, 4, 8, 16, 32, or 64) - only used when creating
* @param options.memory Alternative parameter for RAM in GB - only used when creating
* @param options.cpu CPU cores (1, 2, 4, 8, or 16) - only used when creating
* @param options.os Operating system ("linux" or "windows") - only used when creating
* @param options.gpu GPU type - only used when creating
*/
static create(options?: {
project?: string | Project;
name?: string;
computerId?: string;
apiKey?: string;
baseApiUrl?: string;
ram?: 1 | 2 | 4 | 8 | 16 | 32 | 64;
memory?: 1 | 2 | 4 | 8 | 16 | 32 | 64;
cpu?: 1 | 2 | 4 | 8 | 16;
os?: 'linux' | 'windows';
gpu?: 'none' | 'a10' | 'l40s' | 'a100-40gb' | 'a100-80gb';
}): Promise<Computer>;
private _initializeWithProjectName;
private _initializeWithProjectInstance;
private _createNewProjectAndComputer;
private _connectToExistingComputer;
private _createComputer;
status(): Promise<ComputerInfo>;
restart(): Promise<unknown>;
destroy(): Promise<unknown>;
leftClick(x: number, y: number): Promise<unknown>;
rightClick(x: number, y: number): Promise<unknown>;
doubleClick(x: number, y: number): Promise<unknown>;
drag(startX: number, startY: number, endX: number, endY: number, button?: 'left' | 'right', duration?: number): Promise<unknown>;
scroll(direction?: ScrollOptions['direction'], amount?: number): Promise<unknown>;
type(text: string): Promise<unknown>;
key(key: string): Promise<unknown>;
screenshot(options?: ScreenshotOptions): Promise<Buffer | string>;
screenshotBase64(): Promise<string>;
bash(command: string): Promise<string>;
exec(code: string, timeout?: number): Promise<ExecResponse>;
wait(seconds: number): Promise<unknown>;
startStream(connection: string): Promise<StreamStartResponse>;
stopStream(): Promise<StreamStopResponse>;
streamStatus(): Promise<StreamStatusResponse>;
prompt(options: PromptOptions): Promise<PromptMessage[]>;
}
/**
* Custom error types for Orgo SDK
*/
declare class OrgoError extends Error {
constructor(message: string);
}
declare class ApiError extends OrgoError {
statusCode?: number;
response?: unknown;
constructor(message: string, statusCode?: number, response?: unknown);
}
declare class ConfigError extends OrgoError {
constructor(message: string);
}
declare function createComputer(options?: {
projectId?: string;
apiKey?: string;
config?: Record<string, unknown>;
baseApiUrl?: string;
}): Promise<Computer>;
declare function createProject(options?: {
name?: string;
apiKey?: string;
baseApiUrl?: string;
}): Promise<Project>;
export { ApiError, Computer, type ComputerConfig, type ComputerInfo, type ComputerStatus, ConfigError, type ExecResponse, OrgoError, Project, type ProjectInfo, type PromptMessage, type PromptOptions, type ScreenshotOptions, createComputer, createProject };