@artifyfun/comfy-ui-client
Version:
WebSockets API client for ComfyUI
136 lines (133 loc) • 4.41 kB
text/typescript
interface NodeInfo {
class_type: string;
inputs: {
[key: string]: any;
};
}
interface Prompt {
[nodeId: string]: {
inputs: Record<string, any>;
class_type: string;
};
}
interface ComfyUIError {
type: string;
message: string;
details: string;
extra_info: any;
}
interface QueuePromptResult {
prompt_id: string;
number: number;
node_errors: Record<string, ComfyUIError>;
}
interface UploadImageResult {
name: string;
subfolder: string;
type: string;
}
interface ImageRef {
filename: string;
subfolder?: string;
type?: string;
}
interface EditHistoryRequest {
clear?: boolean;
delete?: string[];
}
interface PromptHistory {
prompt: any[];
outputs: Record<string, any>;
}
interface HistoryResult {
[prompt_id: string]: PromptHistory;
}
interface OutputImage {
filename: string;
subfolder: string;
type: string;
}
interface ImageContainer {
blob: Blob;
image: OutputImage;
}
interface ImagesResponse {
[nodeId: string]: ImageContainer[];
}
interface DeviceStats {
name: string;
type: string;
index: number;
vram_total: number;
vram_free: number;
torch_vram_total: number;
torch_vram_free: number;
}
interface SystemStatsResponse {
devices: DeviceStats[];
}
interface ViewMetadataResponse {
[key: string]: any;
}
type QueueDataPrimitives = number | string | object;
type QueueData = QueueDataPrimitives | Array<QueueDataPrimitives>;
interface QueueResponse {
queue_running: QueueData[];
queue_pending: QueueData[];
}
interface ExecInfo {
queue_remaining: number;
}
interface PromptQueueResponse {
exec_info: ExecInfo;
}
interface ObjectInfo {
input: {
[key: string]: any;
};
output: string[];
output_is_list: boolean[];
output_name: string[];
name: string;
display_name: string;
description: string;
category: string;
output_node: boolean;
}
interface ObjectInfoResponse {
[nodeClass: string]: ObjectInfo;
}
interface ResponseError {
error: string | ComfyUIError;
node_errors: Record<string, ComfyUIError>;
}
type FolderName = 'checkpoints' | 'configs' | 'loras' | 'vae' | 'clip' | 'unet' | 'clip_vision' | 'style_models' | 'embeddings' | 'diffusers' | 'vae_approx' | 'controlnet' | 'gligen' | 'upscale_models' | 'custom_nodes' | 'hypernetworks';
declare class ComfyUIClient {
host: string;
clientId: string;
historyResult: HistoryResult;
eventEmitter: (type: string, data: any) => void;
handlers: any;
protected ws?: any;
constructor(host: string, clientId: string, eventEmitter?: (type: string, data: any) => void);
connect(): Promise<void>;
disconnect(): Promise<void>;
getEmbeddings(): Promise<string[]>;
getExtensions(): Promise<string[]>;
queuePrompt(prompt: Prompt): Promise<QueuePromptResult>;
interrupt(): Promise<Response>;
editHistory(params: EditHistoryRequest): Promise<void>;
uploadImage(image: Buffer, filename: string, overwrite?: boolean): Promise<UploadImageResult>;
uploadMask(image: Buffer, filename: string, originalRef: ImageRef, overwrite?: boolean): Promise<UploadImageResult>;
getImage(filename: string, subfolder: string, type: string): Promise<Blob>;
viewMetadata(folderName: FolderName, filename: string): Promise<ViewMetadataResponse>;
getSystemStats(): Promise<SystemStatsResponse>;
getPrompt(): Promise<PromptQueueResponse>;
getObjectInfo(nodeClass?: string): Promise<ObjectInfoResponse>;
getHistory(fetchOptionOrPromptId?: any, promptId?: string): Promise<HistoryResult>;
getQueue(fetchOption: any): Promise<QueueResponse>;
deleteQueue(id: string): Promise<QueueResponse>;
getResult(fetchOptionOrPrompt: any, promptParam?: Prompt): Promise<PromptHistory>;
getImages(prompt: Prompt): Promise<ImagesResponse>;
}
export { ComfyUIClient, type ComfyUIError, type DeviceStats, type EditHistoryRequest, type ExecInfo, type FolderName, type HistoryResult, type ImageContainer, type ImageRef, type ImagesResponse, type NodeInfo, type ObjectInfo, type ObjectInfoResponse, type OutputImage, type Prompt, type PromptHistory, type PromptQueueResponse, type QueueData, type QueueDataPrimitives, type QueuePromptResult, type QueueResponse, type ResponseError, type SystemStatsResponse, type UploadImageResult, type ViewMetadataResponse };