plato-sdk
Version:
JavaScript client for interacting with the Plato API
95 lines (94 loc) • 3.12 kB
TypeScript
import { z } from 'zod';
export declare const PlatoTaskSchema: z.ZodObject<{
name: z.ZodString;
prompt: z.ZodString;
start_url: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
prompt: string;
start_url: string;
}, {
name: string;
prompt: string;
start_url: string;
}>;
export type PlatoTask = z.infer<typeof PlatoTaskSchema>;
export interface WorkerReadyResponse {
ready: boolean;
worker_public_ip?: string;
worker_ip?: string;
worker_port?: number;
health_status?: Record<string, any>;
error?: string;
}
export declare class PlatoEnvironment {
private client;
id: string;
private heartbeatInterval;
private heartbeatIntervalMs;
private runSessionId;
constructor(client: Plato, id: string);
getStatus(): Promise<any>;
getCdpUrl(): Promise<string>;
close(): Promise<any>;
evaluate(): Promise<any>;
/**
* Resets the environment with a new task
* @param task The task to run in the environment, or a simplified object with just name, prompt, and start_url
* @returns The response from the server
*/
reset(task?: PlatoTask | {
name: string;
prompt: string;
start_url: string;
}, test_case_public_id?: string): Promise<string | null>;
getState(): Promise<any>;
getLiveViewUrl(): Promise<string>;
backup(): Promise<any>;
/**
* Starts the heartbeat interval to keep the environment alive
* @private
*/
private startHeartbeat;
/**
* Stops the heartbeat interval
* @private
*/
private stopHeartbeat;
waitForReady(timeout?: number): Promise<void>;
}
export declare class Plato {
private apiKey;
private baseUrl;
private http;
constructor(apiKey: string, baseUrl?: string);
/**
* Create a new Plato environment for the given environment ID.
*
* @param envId The environment ID to create
* @param openPageOnStart Whether to open the page on start
* @returns The created environment instance
* @throws PlatoClientError If the API request fails
*/
makeEnvironment(envId: string, openPageOnStart?: boolean): Promise<PlatoEnvironment>;
getJobStatus(jobId: string): Promise<any>;
getCdpUrl(jobId: string): Promise<string>;
closeEnvironment(jobId: string): Promise<any>;
evaluate(sessionId: string): Promise<any>;
/**
* Resets an environment with a new task
* @param jobId The ID of the job to reset
* @param task The task to run in the environment, or a simplified object with just name, prompt, and start_url
* @returns The response from the server
*/
resetEnvironment(jobId: string, task?: PlatoTask | {
name: string;
prompt: string;
start_url: string;
}, test_case_public_id?: string): Promise<any>;
getEnvironmentState(jobId: string): Promise<any>;
getWorkerReady(jobId: string): Promise<WorkerReadyResponse>;
getLiveViewUrl(jobId: string): Promise<string>;
sendHeartbeat(jobId: string): Promise<any>;
backupEnvironment(jobId: string): Promise<any>;
}