@happyvertical/comfyui 0.110.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +78 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -207,6 +207,29 @@ interface ProgressEvent {
|
|
|
207
207
|
}
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
+
## Errors
|
|
211
|
+
|
|
212
|
+
A non-2xx response from ComfyUI throws `ComfyUIRequestError` (an `ApiError`
|
|
213
|
+
from `@happyvertical/utils`). It carries `status`, `method`, `path` and the
|
|
214
|
+
response `body` (parsed JSON, or the raw text). ComfyUI rejects a prompt that
|
|
215
|
+
fails validation, such as a missing model file, with HTTP 400; the error then
|
|
216
|
+
exposes the body's `node_errors` as `nodeErrors` and its `error` object as
|
|
217
|
+
`promptError`. The message keeps the `ComfyUI request failed: <status> <body>`
|
|
218
|
+
text.
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import { ComfyUIRequestError } from '@happyvertical/comfyui';
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
await client.queuePrompt(workflow);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
if (error instanceof ComfyUIRequestError && error.nodeErrors) {
|
|
227
|
+
console.error('Prompt rejected:', error.nodeErrors);
|
|
228
|
+
}
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
210
233
|
## Use Cases
|
|
211
234
|
|
|
212
235
|
### AI Video Generation Pipeline
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
* @packageDocumentation
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
+
import { ApiError } from '@happyvertical/utils';
|
|
52
|
+
|
|
51
53
|
/**
|
|
52
54
|
* A single node in a ComfyUI workflow
|
|
53
55
|
*/
|
|
@@ -135,6 +137,9 @@ export declare class ComfyUIClient {
|
|
|
135
137
|
disconnect(): Promise<void>;
|
|
136
138
|
/**
|
|
137
139
|
* Make an HTTP request to ComfyUI
|
|
140
|
+
*
|
|
141
|
+
* @throws {ComfyUIRequestError} for a non-2xx response, with the status and
|
|
142
|
+
* the parsed body (for a rejected prompt, ComfyUI's `node_errors`)
|
|
138
143
|
*/
|
|
139
144
|
private request;
|
|
140
145
|
/**
|
|
@@ -247,6 +252,52 @@ export declare interface ComfyUIClientOptions {
|
|
|
247
252
|
password?: string;
|
|
248
253
|
}
|
|
249
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Thrown when a ComfyUI HTTP request returns a non-2xx status.
|
|
257
|
+
*
|
|
258
|
+
* ComfyUI rejects a prompt that fails validation (a missing model file, a bad
|
|
259
|
+
* link between nodes) with HTTP 400 and a JSON body
|
|
260
|
+
* `{ "error": {...}, "node_errors": {...} }`. This error keeps that body so
|
|
261
|
+
* callers can tell a rejected prompt from a network or server failure without
|
|
262
|
+
* parsing the message. The message keeps the earlier
|
|
263
|
+
* `ComfyUI request failed: <status> <body>` text.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* try {
|
|
268
|
+
* await client.queuePrompt(workflow);
|
|
269
|
+
* } catch (error) {
|
|
270
|
+
* if (error instanceof ComfyUIRequestError && error.nodeErrors) {
|
|
271
|
+
* // The prompt failed validation; error.nodeErrors names the nodes.
|
|
272
|
+
* }
|
|
273
|
+
* throw error;
|
|
274
|
+
* }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
export declare class ComfyUIRequestError extends ApiError {
|
|
278
|
+
/** HTTP status ComfyUI answered with. */
|
|
279
|
+
readonly status: number;
|
|
280
|
+
/** HTTP method of the request. */
|
|
281
|
+
readonly method: string;
|
|
282
|
+
/** Request path, for example `/prompt`. */
|
|
283
|
+
readonly path: string;
|
|
284
|
+
/** Response body: parsed JSON when it is JSON, otherwise the raw text. */
|
|
285
|
+
readonly body: unknown;
|
|
286
|
+
/**
|
|
287
|
+
* The body's `node_errors` (per-node validation errors) when ComfyUI sent
|
|
288
|
+
* any; undefined otherwise.
|
|
289
|
+
*/
|
|
290
|
+
readonly nodeErrors?: Record<string, unknown>;
|
|
291
|
+
/** The body's top-level `error` object (type, message, details), if any. */
|
|
292
|
+
readonly promptError?: unknown;
|
|
293
|
+
constructor(input: {
|
|
294
|
+
status: number;
|
|
295
|
+
method: string;
|
|
296
|
+
path: string;
|
|
297
|
+
bodyText: string;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
250
301
|
/**
|
|
251
302
|
* ComfyUI workflow definition (API format JSON)
|
|
252
303
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
import { createLogger } from "@happyvertical/logger";
|
|
2
|
-
import { ValidationError } from "@happyvertical/utils";
|
|
2
|
+
import { ApiError, ValidationError } from "@happyvertical/utils";
|
|
3
|
+
//#region src/errors.ts
|
|
4
|
+
/**
|
|
5
|
+
* ComfyUI request errors
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Thrown when a ComfyUI HTTP request returns a non-2xx status.
|
|
9
|
+
*
|
|
10
|
+
* ComfyUI rejects a prompt that fails validation (a missing model file, a bad
|
|
11
|
+
* link between nodes) with HTTP 400 and a JSON body
|
|
12
|
+
* `{ "error": {...}, "node_errors": {...} }`. This error keeps that body so
|
|
13
|
+
* callers can tell a rejected prompt from a network or server failure without
|
|
14
|
+
* parsing the message. The message keeps the earlier
|
|
15
|
+
* `ComfyUI request failed: <status> <body>` text.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* try {
|
|
20
|
+
* await client.queuePrompt(workflow);
|
|
21
|
+
* } catch (error) {
|
|
22
|
+
* if (error instanceof ComfyUIRequestError && error.nodeErrors) {
|
|
23
|
+
* // The prompt failed validation; error.nodeErrors names the nodes.
|
|
24
|
+
* }
|
|
25
|
+
* throw error;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
var ComfyUIRequestError = class extends ApiError {
|
|
30
|
+
/** HTTP status ComfyUI answered with. */
|
|
31
|
+
status;
|
|
32
|
+
/** HTTP method of the request. */
|
|
33
|
+
method;
|
|
34
|
+
/** Request path, for example `/prompt`. */
|
|
35
|
+
path;
|
|
36
|
+
/** Response body: parsed JSON when it is JSON, otherwise the raw text. */
|
|
37
|
+
body;
|
|
38
|
+
/**
|
|
39
|
+
* The body's `node_errors` (per-node validation errors) when ComfyUI sent
|
|
40
|
+
* any; undefined otherwise.
|
|
41
|
+
*/
|
|
42
|
+
nodeErrors;
|
|
43
|
+
/** The body's top-level `error` object (type, message, details), if any. */
|
|
44
|
+
promptError;
|
|
45
|
+
constructor(input) {
|
|
46
|
+
super(`ComfyUI request failed: ${input.status} ${input.bodyText}`, {
|
|
47
|
+
status: input.status,
|
|
48
|
+
method: input.method,
|
|
49
|
+
path: input.path
|
|
50
|
+
});
|
|
51
|
+
this.status = input.status;
|
|
52
|
+
this.method = input.method;
|
|
53
|
+
this.path = input.path;
|
|
54
|
+
this.body = parseBody(input.bodyText);
|
|
55
|
+
if (this.body && typeof this.body === "object" && !Array.isArray(this.body)) {
|
|
56
|
+
const { error, node_errors: nodeErrors } = this.body;
|
|
57
|
+
if (nodeErrors && typeof nodeErrors === "object" && !Array.isArray(nodeErrors) && Object.keys(nodeErrors).length > 0) this.nodeErrors = nodeErrors;
|
|
58
|
+
if (error !== void 0) this.promptError = error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function parseBody(text) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(text);
|
|
65
|
+
} catch {
|
|
66
|
+
return text;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
3
70
|
//#region src/client.ts
|
|
4
71
|
/**
|
|
5
72
|
* ComfyUI Client
|
|
@@ -224,6 +291,9 @@ var ComfyUIClient = class {
|
|
|
224
291
|
}
|
|
225
292
|
/**
|
|
226
293
|
* Make an HTTP request to ComfyUI
|
|
294
|
+
*
|
|
295
|
+
* @throws {ComfyUIRequestError} for a non-2xx response, with the status and
|
|
296
|
+
* the parsed body (for a rejected prompt, ComfyUI's `node_errors`)
|
|
227
297
|
*/
|
|
228
298
|
async request(path, options = {}) {
|
|
229
299
|
const url = `${this.httpUrl}${path}`;
|
|
@@ -237,7 +307,12 @@ var ComfyUIClient = class {
|
|
|
237
307
|
});
|
|
238
308
|
if (!response.ok) {
|
|
239
309
|
const errorText = await response.text();
|
|
240
|
-
throw new
|
|
310
|
+
throw new ComfyUIRequestError({
|
|
311
|
+
status: response.status,
|
|
312
|
+
method: options.method ?? "GET",
|
|
313
|
+
path,
|
|
314
|
+
bodyText: errorText
|
|
315
|
+
});
|
|
241
316
|
}
|
|
242
317
|
return response.json();
|
|
243
318
|
}
|
|
@@ -473,6 +548,6 @@ function injectWorkflowParams(workflow, mapping, values) {
|
|
|
473
548
|
return result;
|
|
474
549
|
}
|
|
475
550
|
//#endregion
|
|
476
|
-
export { ComfyUIClient, injectWorkflowParams };
|
|
551
|
+
export { ComfyUIClient, ComfyUIRequestError, injectWorkflowParams };
|
|
477
552
|
|
|
478
553
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\n * ComfyUI Client\n *\n * WebSocket and REST client for interacting with ComfyUI servers.\n * Supports workflow execution, progress monitoring, and file management.\n */\n\nimport { createLogger, type Logger } from '@happyvertical/logger';\nimport { ValidationError } from '@happyvertical/utils';\n\nimport type {\n ComfyUIClientOptions,\n ComfyWorkflow,\n HistoryEntry,\n NodeMapping,\n ProgressEvent,\n PromptResult,\n QueueStatus,\n ResolvedClientOptions,\n SystemStats,\n UploadResult,\n WaitOptions,\n} from './types.js';\n\n/**\n * WebSocket message types from ComfyUI.\n *\n * `data` carries the union of fields the various message types\n * use, discriminated by `type` at runtime in `parseProgressEvent`.\n * Previously typed as `unknown`, which made every\n * `message.data?.<field>` access in that switch fail TS2339 — the\n * narrowing would have required parser-side type guards, much\n * heavier than just listing the actual fields here.\n */\ninterface WSMessage {\n type: string;\n data?: {\n // `node` carries a real `null` value from the ComfyUI protocol —\n // `parseProgressEvent` writes it through to `ProgressEvent.nodeId`,\n // and `waitForCompletion` uses `event.nodeId === null` as the\n // \"no more nodes to execute\" completion sentinel. The previous\n // `data?: unknown` type accepted null implicitly; this narrowed\n // type must keep it. (See `packages/comfyui/src/client.ts:436`\n // and the comment about completion above it.)\n node?: string | null;\n prompt_id?: string;\n output?: Record<string, unknown>;\n value?: number;\n max?: number;\n exception_message?: string;\n };\n}\n\n/**\n * ComfyUI client for workflow execution and management\n *\n * @example\n * ```typescript\n * import { ComfyUIClient } from '@happyvertical/comfyui';\n *\n * const client = new ComfyUIClient({\n * url: 'http://localhost:8188',\n * });\n *\n * await client.connect();\n *\n * const result = await client.queuePrompt(workflow);\n * await client.waitForCompletion(result.promptId, {\n * onProgress: (event) => console.log(`Progress: ${event.value}%`),\n * });\n *\n * const output = await client.downloadOutput('video.mp4');\n * await client.disconnect();\n * ```\n */\nexport class ComfyUIClient {\n private options: ResolvedClientOptions;\n private ws: WebSocket | null = null;\n private logger: Logger;\n private clientId: string;\n private messageHandlers: Map<string, Set<(event: ProgressEvent) => void>> =\n new Map();\n private reconnectAttempts = 0;\n private isConnecting = false;\n private username?: string;\n private password?: string;\n\n constructor(options: ComfyUIClientOptions = {}) {\n this.options = {\n url: options.url ?? 'http://localhost:8188',\n timeout: options.timeout ?? 600000,\n headers: options.headers ?? {},\n reconnect: {\n enabled: options.reconnect?.enabled ?? true,\n maxAttempts: options.reconnect?.maxAttempts ?? 5,\n delay: options.reconnect?.delay ?? 1000,\n },\n };\n\n if (options.username && options.password) {\n this.username = options.username;\n this.password = options.password;\n const credentials = btoa(`${options.username}:${options.password}`);\n this.options.headers.Authorization = `Basic ${credentials}`;\n }\n\n this.logger = createLogger({ level: 'info' });\n this.clientId = crypto.randomUUID();\n }\n\n /**\n * Get the HTTP base URL\n */\n private get httpUrl(): string {\n return this.options.url;\n }\n\n /**\n * Get the WebSocket URL\n */\n private get wsUrl(): string {\n const url = new URL(this.options.url);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.pathname = '/ws';\n url.searchParams.set('clientId', this.clientId);\n if (this.username && this.password) {\n url.username = this.username;\n url.password = this.password;\n }\n return url.toString();\n }\n\n /**\n * Connect to the ComfyUI WebSocket\n */\n async connect(): Promise<void> {\n if (this.ws?.readyState === WebSocket.OPEN) {\n return;\n }\n\n if (this.isConnecting) {\n // Wait for existing connection attempt\n await new Promise<void>((resolve, reject) => {\n const checkConnection = setInterval(() => {\n if (this.ws?.readyState === WebSocket.OPEN) {\n clearInterval(checkConnection);\n resolve();\n } else if (!this.isConnecting) {\n clearInterval(checkConnection);\n reject(new Error('Connection failed'));\n }\n }, 100);\n });\n return;\n }\n\n this.isConnecting = true;\n\n try {\n await this.establishConnection();\n this.reconnectAttempts = 0;\n } finally {\n this.isConnecting = false;\n }\n }\n\n /**\n * Establish WebSocket connection\n */\n private async establishConnection(): Promise<void> {\n return new Promise((resolve, reject) => {\n try {\n this.ws = new WebSocket(this.wsUrl);\n\n const timeout = setTimeout(() => {\n if (this.ws?.readyState !== WebSocket.OPEN) {\n this.ws?.close();\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n\n this.ws.onopen = () => {\n clearTimeout(timeout);\n this.logger.info('Connected to ComfyUI');\n resolve();\n };\n\n this.ws.onerror = (error) => {\n clearTimeout(timeout);\n this.logger.error('WebSocket error', { error });\n reject(new Error('WebSocket connection error'));\n };\n\n this.ws.onclose = () => {\n this.logger.info('Disconnected from ComfyUI');\n this.handleDisconnect();\n };\n\n this.ws.onmessage = (event) => {\n this.handleMessage(event.data);\n };\n } catch (error) {\n reject(error);\n }\n });\n }\n\n /**\n * Handle WebSocket disconnection\n */\n private async handleDisconnect(): Promise<void> {\n const reconnect = this.options.reconnect;\n if (!reconnect.enabled) return;\n\n if (this.reconnectAttempts < reconnect.maxAttempts) {\n this.reconnectAttempts++;\n this.logger.info(\n `Attempting reconnection ${this.reconnectAttempts}/${reconnect.maxAttempts}`,\n );\n\n await new Promise((resolve) => setTimeout(resolve, reconnect.delay));\n\n try {\n await this.connect();\n } catch (error) {\n this.logger.error('Reconnection failed', { error });\n }\n }\n }\n\n /**\n * Handle incoming WebSocket messages\n */\n private handleMessage(data: string): void {\n try {\n const message: WSMessage = JSON.parse(data);\n const event = this.parseProgressEvent(message);\n\n if (event?.promptId) {\n const handlers = this.messageHandlers.get(event.promptId);\n if (handlers) {\n for (const handler of handlers) {\n handler(event);\n }\n }\n }\n } catch (error) {\n this.logger.warn('Failed to parse WebSocket message', { error, data });\n }\n }\n\n /**\n * Parse a WebSocket message into a ProgressEvent\n */\n private parseProgressEvent(message: WSMessage): ProgressEvent | null {\n switch (message.type) {\n case 'executing':\n return {\n type: 'executing',\n nodeId: message.data?.node,\n promptId: message.data?.prompt_id,\n };\n\n case 'progress':\n return {\n type: 'progress',\n value: message.data?.value,\n max: message.data?.max,\n promptId: message.data?.prompt_id,\n };\n\n case 'execution_cached':\n return {\n type: 'execution_cached',\n promptId: message.data?.prompt_id,\n };\n\n case 'executed':\n return {\n type: 'executed',\n nodeId: message.data?.node,\n promptId: message.data?.prompt_id,\n output: message.data?.output,\n };\n\n case 'execution_error':\n return {\n type: 'execution_error',\n promptId: message.data?.prompt_id,\n error: message.data?.exception_message,\n };\n\n default:\n return null;\n }\n }\n\n /**\n * Disconnect from ComfyUI\n */\n async disconnect(): Promise<void> {\n this.options.reconnect.enabled = false; // Prevent auto-reconnect\n this.messageHandlers.clear();\n\n if (this.ws) {\n this.ws.close();\n this.ws = null;\n }\n\n this.logger.info('Disconnected from ComfyUI');\n }\n\n /**\n * Make an HTTP request to ComfyUI\n */\n private async request<T>(\n path: string,\n options: {\n method?: 'GET' | 'POST' | 'DELETE';\n body?: unknown;\n formData?: FormData;\n } = {},\n ): Promise<T> {\n const url = `${this.httpUrl}${path}`;\n\n const headers: Record<string, string> = {\n ...this.options.headers,\n };\n\n if (options.body && !options.formData) {\n headers['Content-Type'] = 'application/json';\n }\n\n const response = await fetch(url, {\n method: options.method ?? 'GET',\n headers,\n body:\n options.formData ??\n (options.body ? JSON.stringify(options.body) : undefined),\n signal: AbortSignal.timeout(this.options.timeout),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(\n `ComfyUI request failed: ${response.status} ${errorText}`,\n );\n }\n\n return response.json();\n }\n\n /**\n * Queue a workflow for execution\n *\n * @param workflow - The ComfyUI workflow to execute\n * @param clientId - Optional client ID (uses default if not provided)\n * @returns Promise resolving to prompt result with ID\n */\n async queuePrompt(\n workflow: ComfyWorkflow,\n clientId?: string,\n ): Promise<PromptResult> {\n const response = await this.request<{\n prompt_id: string;\n number: number;\n node_errors?: Record<string, string[]>;\n }>('/prompt', {\n method: 'POST',\n body: {\n prompt: workflow,\n client_id: clientId ?? this.clientId,\n },\n });\n\n return {\n promptId: response.prompt_id,\n number: response.number,\n nodeErrors: response.node_errors,\n };\n }\n\n /**\n * Subscribe to progress events for a prompt\n *\n * @param promptId - The prompt ID to monitor\n * @param handler - Callback for progress events\n * @returns Unsubscribe function\n */\n onProgress(\n promptId: string,\n handler: (event: ProgressEvent) => void,\n ): () => void {\n if (!this.messageHandlers.has(promptId)) {\n this.messageHandlers.set(promptId, new Set());\n }\n\n this.messageHandlers.get(promptId)?.add(handler);\n\n return () => {\n this.messageHandlers.get(promptId)?.delete(handler);\n if (this.messageHandlers.get(promptId)?.size === 0) {\n this.messageHandlers.delete(promptId);\n }\n };\n }\n\n /**\n * Wait for a prompt to complete\n *\n * @param promptId - The prompt ID to wait for\n * @param options - Wait options including progress callback\n * @returns Promise resolving to the history entry\n */\n async waitForCompletion(\n promptId: string,\n options: WaitOptions = {},\n ): Promise<HistoryEntry> {\n const timeout = options.timeout ?? this.options.timeout;\n const startTime = Date.now();\n\n return new Promise((resolve, reject) => {\n let resolved = false;\n\n // Set up timeout\n const timeoutId =\n timeout > 0\n ? setTimeout(() => {\n if (!resolved) {\n resolved = true;\n unsubscribe();\n reject(new Error(`Timeout waiting for prompt ${promptId}`));\n }\n }, timeout)\n : null;\n\n // Subscribe to progress events\n const unsubscribe = this.onProgress(promptId, async (event) => {\n // Forward progress events\n options.onProgress?.(event);\n\n // Check for completion or error\n if (event.type === 'executed' && event.nodeId === null) {\n // Workflow completed (null nodeId means no more nodes to execute)\n if (!resolved) {\n resolved = true;\n if (timeoutId) clearTimeout(timeoutId);\n unsubscribe();\n\n try {\n const history = await this.getHistory(promptId);\n resolve(history);\n } catch (error) {\n reject(error);\n }\n }\n } else if (event.type === 'execution_error') {\n if (!resolved) {\n resolved = true;\n if (timeoutId) clearTimeout(timeoutId);\n unsubscribe();\n reject(new Error(`Workflow execution error: ${event.error}`));\n }\n }\n });\n\n // Fallback: poll history if WebSocket doesn't give completion\n const pollHistory = async () => {\n while (\n !resolved &&\n (timeout === 0 || Date.now() - startTime < timeout)\n ) {\n await new Promise((r) => setTimeout(r, options.pollInterval ?? 1000));\n\n if (resolved) break;\n\n try {\n const history = await this.getHistory(promptId);\n if (history.status.completed) {\n if (!resolved) {\n resolved = true;\n if (timeoutId) clearTimeout(timeoutId);\n unsubscribe();\n resolve(history);\n }\n break;\n }\n } catch {\n // History not available yet, continue polling\n }\n }\n };\n\n // Start polling as fallback\n pollHistory().catch(() => {});\n });\n }\n\n /**\n * Get history for a specific prompt\n *\n * @param promptId - The prompt ID to get history for\n * @returns Promise resolving to the history entry\n */\n async getHistory(promptId: string): Promise<HistoryEntry> {\n const response = await this.request<Record<string, any>>(\n `/history/${promptId}`,\n );\n\n const entry = response[promptId];\n if (!entry) {\n throw new ValidationError(`History not found for prompt ${promptId}`);\n }\n\n return {\n promptId,\n status: entry.status,\n outputs: entry.outputs,\n prompt: entry.prompt,\n };\n }\n\n /**\n * Download an output file from ComfyUI\n *\n * @param filename - Name of the file to download\n * @param subfolder - Subfolder where file is located\n * @param type - Type of file location ('output', 'temp', or 'input')\n * @returns Promise resolving to the file buffer\n */\n async downloadOutput(\n filename: string,\n subfolder: string = '',\n type: 'output' | 'temp' | 'input' = 'output',\n ): Promise<Buffer> {\n const params = new URLSearchParams({\n filename,\n subfolder,\n type,\n });\n\n const url = `${this.httpUrl}/view?${params}`;\n const response = await fetch(url, {\n headers: this.options.headers,\n signal: AbortSignal.timeout(this.options.timeout),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to download file: ${response.status}`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n }\n\n /**\n * Upload a file to ComfyUI\n *\n * @param file - File buffer to upload\n * @param filename - Name for the file\n * @param type - Where to upload ('input' or 'temp')\n * @param overwrite - Whether to overwrite existing file\n * @returns Promise resolving to upload result\n */\n async uploadFile(\n file: Buffer,\n filename: string,\n type: 'input' | 'temp' = 'input',\n overwrite = false,\n ): Promise<UploadResult> {\n const formData = new FormData();\n formData.append('image', new Blob([new Uint8Array(file)]), filename);\n formData.append('type', type);\n formData.append('overwrite', String(overwrite));\n\n const response = await this.request<{\n name: string;\n subfolder: string;\n type: string;\n }>('/upload/image', {\n method: 'POST',\n formData,\n });\n\n return {\n name: response.name,\n subfolder: response.subfolder,\n type: response.type as 'input' | 'temp' | 'output',\n };\n }\n\n /**\n * Get system statistics from ComfyUI\n *\n * @returns Promise resolving to system stats\n */\n async getSystemStats(): Promise<SystemStats> {\n return this.request<SystemStats>('/system_stats');\n }\n\n /**\n * Get the current queue status\n *\n * @returns Promise resolving to queue status\n */\n async getQueue(): Promise<QueueStatus> {\n const response = await this.request<{\n queue_running: any[];\n queue_pending: any[];\n }>('/queue');\n\n return {\n running: response.queue_running,\n pending: response.queue_pending,\n };\n }\n\n /**\n * Interrupt the current execution\n */\n async interrupt(): Promise<void> {\n await this.request('/interrupt', { method: 'POST' });\n }\n\n /**\n * Clear the execution queue\n */\n async clearQueue(): Promise<void> {\n await this.request('/queue', {\n method: 'POST',\n body: { clear: true },\n });\n }\n\n /**\n * Delete a specific item from the queue\n *\n * @param promptId - The prompt ID to delete\n */\n async deleteFromQueue(promptId: string): Promise<void> {\n await this.request('/queue', {\n method: 'POST',\n body: { delete: [promptId] },\n });\n }\n}\n\n/**\n * Helper function to inject parameters into a workflow\n *\n * @param workflow - The base workflow\n * @param mapping - Node mapping defining where to inject\n * @param values - Values to inject\n * @returns Modified workflow with injected values\n */\nexport function injectWorkflowParams(\n workflow: ComfyWorkflow,\n mapping: NodeMapping,\n values: Record<string, any>,\n): ComfyWorkflow {\n const result = JSON.parse(JSON.stringify(workflow));\n\n for (const [key, nodeId] of Object.entries(mapping)) {\n if (nodeId && values[key] !== undefined && result[nodeId]) {\n // Find the appropriate input field and update it\n const node = result[nodeId];\n\n // Common input field names for different node types\n const inputFieldMap: Record<string, string> = {\n seedImage: 'image',\n audioFile: 'audio',\n baseVideo: 'video',\n prompt: 'text',\n negativePrompt: 'text',\n };\n\n const inputField = inputFieldMap[key] ?? key;\n if (node.inputs && inputField in node.inputs) {\n node.inputs[inputField] = values[key];\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,IAAa,gBAAb,MAA2B;CACzB;CACA,KAA+B;CAC/B;CACA;CACA,kCACE,IAAI,IAAI;CACV,oBAA4B;CAC5B,eAAuB;CACvB;CACA;CAEA,YAAY,UAAgC,CAAC,GAAG;EAC9C,KAAK,UAAU;GACb,KAAK,QAAQ,OAAO;GACpB,SAAS,QAAQ,WAAW;GAC5B,SAAS,QAAQ,WAAW,CAAC;GAC7B,WAAW;IACT,SAAS,QAAQ,WAAW,WAAW;IACvC,aAAa,QAAQ,WAAW,eAAe;IAC/C,OAAO,QAAQ,WAAW,SAAS;GACrC;EACF;EAEA,IAAI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AElD,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,OAAO,GAChD,IAAI,UAAU,OAAO,SAAS,KAAA,KAAa,OAAO,SAAS;EAEzD,MAAM,OAAO,OAAO;EAWpB,MAAM,aAAa;GAPjB,WAAW;GACX,WAAW;GACX,WAAW;GACX,QAAQ;GACR,gBAAgB;EAGC,EAAc,QAAQ;EACzC,IAAI,KAAK,UAAU,cAAc,KAAK,QACpC,KAAK,OAAO,cAAc,OAAO;CAErC;CAGF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["/**\n * ComfyUI request errors\n */\n\nimport { ApiError } from '@happyvertical/utils';\n\n/**\n * Thrown when a ComfyUI HTTP request returns a non-2xx status.\n *\n * ComfyUI rejects a prompt that fails validation (a missing model file, a bad\n * link between nodes) with HTTP 400 and a JSON body\n * `{ \"error\": {...}, \"node_errors\": {...} }`. This error keeps that body so\n * callers can tell a rejected prompt from a network or server failure without\n * parsing the message. The message keeps the earlier\n * `ComfyUI request failed: <status> <body>` text.\n *\n * @example\n * ```typescript\n * try {\n * await client.queuePrompt(workflow);\n * } catch (error) {\n * if (error instanceof ComfyUIRequestError && error.nodeErrors) {\n * // The prompt failed validation; error.nodeErrors names the nodes.\n * }\n * throw error;\n * }\n * ```\n */\nexport class ComfyUIRequestError extends ApiError {\n /** HTTP status ComfyUI answered with. */\n public readonly status: number;\n /** HTTP method of the request. */\n public readonly method: string;\n /** Request path, for example `/prompt`. */\n public readonly path: string;\n /** Response body: parsed JSON when it is JSON, otherwise the raw text. */\n public readonly body: unknown;\n /**\n * The body's `node_errors` (per-node validation errors) when ComfyUI sent\n * any; undefined otherwise.\n */\n public readonly nodeErrors?: Record<string, unknown>;\n /** The body's top-level `error` object (type, message, details), if any. */\n public readonly promptError?: unknown;\n\n constructor(input: {\n status: number;\n method: string;\n path: string;\n bodyText: string;\n }) {\n super(`ComfyUI request failed: ${input.status} ${input.bodyText}`, {\n status: input.status,\n method: input.method,\n path: input.path,\n });\n this.status = input.status;\n this.method = input.method;\n this.path = input.path;\n this.body = parseBody(input.bodyText);\n\n if (\n this.body &&\n typeof this.body === 'object' &&\n !Array.isArray(this.body)\n ) {\n const { error, node_errors: nodeErrors } = this.body as {\n error?: unknown;\n // biome-ignore lint/style/useNamingConvention: ComfyUI API field\n node_errors?: unknown;\n };\n if (\n nodeErrors &&\n typeof nodeErrors === 'object' &&\n !Array.isArray(nodeErrors) &&\n Object.keys(nodeErrors).length > 0\n ) {\n this.nodeErrors = nodeErrors as Record<string, unknown>;\n }\n if (error !== undefined) {\n this.promptError = error;\n }\n }\n }\n}\n\nfunction parseBody(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n","/**\n * ComfyUI Client\n *\n * WebSocket and REST client for interacting with ComfyUI servers.\n * Supports workflow execution, progress monitoring, and file management.\n */\n\nimport { createLogger, type Logger } from '@happyvertical/logger';\nimport { ValidationError } from '@happyvertical/utils';\n\nimport { ComfyUIRequestError } from './errors.js';\n\nimport type {\n ComfyUIClientOptions,\n ComfyWorkflow,\n HistoryEntry,\n NodeMapping,\n ProgressEvent,\n PromptResult,\n QueueStatus,\n ResolvedClientOptions,\n SystemStats,\n UploadResult,\n WaitOptions,\n} from './types.js';\n\n/**\n * WebSocket message types from ComfyUI.\n *\n * `data` carries the union of fields the various message types\n * use, discriminated by `type` at runtime in `parseProgressEvent`.\n * Previously typed as `unknown`, which made every\n * `message.data?.<field>` access in that switch fail TS2339 — the\n * narrowing would have required parser-side type guards, much\n * heavier than just listing the actual fields here.\n */\ninterface WSMessage {\n type: string;\n data?: {\n // `node` carries a real `null` value from the ComfyUI protocol —\n // `parseProgressEvent` writes it through to `ProgressEvent.nodeId`,\n // and `waitForCompletion` uses `event.nodeId === null` as the\n // \"no more nodes to execute\" completion sentinel. The previous\n // `data?: unknown` type accepted null implicitly; this narrowed\n // type must keep it. (See `packages/comfyui/src/client.ts:436`\n // and the comment about completion above it.)\n node?: string | null;\n prompt_id?: string;\n output?: Record<string, unknown>;\n value?: number;\n max?: number;\n exception_message?: string;\n };\n}\n\n/**\n * ComfyUI client for workflow execution and management\n *\n * @example\n * ```typescript\n * import { ComfyUIClient } from '@happyvertical/comfyui';\n *\n * const client = new ComfyUIClient({\n * url: 'http://localhost:8188',\n * });\n *\n * await client.connect();\n *\n * const result = await client.queuePrompt(workflow);\n * await client.waitForCompletion(result.promptId, {\n * onProgress: (event) => console.log(`Progress: ${event.value}%`),\n * });\n *\n * const output = await client.downloadOutput('video.mp4');\n * await client.disconnect();\n * ```\n */\nexport class ComfyUIClient {\n private options: ResolvedClientOptions;\n private ws: WebSocket | null = null;\n private logger: Logger;\n private clientId: string;\n private messageHandlers: Map<string, Set<(event: ProgressEvent) => void>> =\n new Map();\n private reconnectAttempts = 0;\n private isConnecting = false;\n private username?: string;\n private password?: string;\n\n constructor(options: ComfyUIClientOptions = {}) {\n this.options = {\n url: options.url ?? 'http://localhost:8188',\n timeout: options.timeout ?? 600000,\n headers: options.headers ?? {},\n reconnect: {\n enabled: options.reconnect?.enabled ?? true,\n maxAttempts: options.reconnect?.maxAttempts ?? 5,\n delay: options.reconnect?.delay ?? 1000,\n },\n };\n\n if (options.username && options.password) {\n this.username = options.username;\n this.password = options.password;\n const credentials = btoa(`${options.username}:${options.password}`);\n this.options.headers.Authorization = `Basic ${credentials}`;\n }\n\n this.logger = createLogger({ level: 'info' });\n this.clientId = crypto.randomUUID();\n }\n\n /**\n * Get the HTTP base URL\n */\n private get httpUrl(): string {\n return this.options.url;\n }\n\n /**\n * Get the WebSocket URL\n */\n private get wsUrl(): string {\n const url = new URL(this.options.url);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.pathname = '/ws';\n url.searchParams.set('clientId', this.clientId);\n if (this.username && this.password) {\n url.username = this.username;\n url.password = this.password;\n }\n return url.toString();\n }\n\n /**\n * Connect to the ComfyUI WebSocket\n */\n async connect(): Promise<void> {\n if (this.ws?.readyState === WebSocket.OPEN) {\n return;\n }\n\n if (this.isConnecting) {\n // Wait for existing connection attempt\n await new Promise<void>((resolve, reject) => {\n const checkConnection = setInterval(() => {\n if (this.ws?.readyState === WebSocket.OPEN) {\n clearInterval(checkConnection);\n resolve();\n } else if (!this.isConnecting) {\n clearInterval(checkConnection);\n reject(new Error('Connection failed'));\n }\n }, 100);\n });\n return;\n }\n\n this.isConnecting = true;\n\n try {\n await this.establishConnection();\n this.reconnectAttempts = 0;\n } finally {\n this.isConnecting = false;\n }\n }\n\n /**\n * Establish WebSocket connection\n */\n private async establishConnection(): Promise<void> {\n return new Promise((resolve, reject) => {\n try {\n this.ws = new WebSocket(this.wsUrl);\n\n const timeout = setTimeout(() => {\n if (this.ws?.readyState !== WebSocket.OPEN) {\n this.ws?.close();\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n\n this.ws.onopen = () => {\n clearTimeout(timeout);\n this.logger.info('Connected to ComfyUI');\n resolve();\n };\n\n this.ws.onerror = (error) => {\n clearTimeout(timeout);\n this.logger.error('WebSocket error', { error });\n reject(new Error('WebSocket connection error'));\n };\n\n this.ws.onclose = () => {\n this.logger.info('Disconnected from ComfyUI');\n this.handleDisconnect();\n };\n\n this.ws.onmessage = (event) => {\n this.handleMessage(event.data);\n };\n } catch (error) {\n reject(error);\n }\n });\n }\n\n /**\n * Handle WebSocket disconnection\n */\n private async handleDisconnect(): Promise<void> {\n const reconnect = this.options.reconnect;\n if (!reconnect.enabled) return;\n\n if (this.reconnectAttempts < reconnect.maxAttempts) {\n this.reconnectAttempts++;\n this.logger.info(\n `Attempting reconnection ${this.reconnectAttempts}/${reconnect.maxAttempts}`,\n );\n\n await new Promise((resolve) => setTimeout(resolve, reconnect.delay));\n\n try {\n await this.connect();\n } catch (error) {\n this.logger.error('Reconnection failed', { error });\n }\n }\n }\n\n /**\n * Handle incoming WebSocket messages\n */\n private handleMessage(data: string): void {\n try {\n const message: WSMessage = JSON.parse(data);\n const event = this.parseProgressEvent(message);\n\n if (event?.promptId) {\n const handlers = this.messageHandlers.get(event.promptId);\n if (handlers) {\n for (const handler of handlers) {\n handler(event);\n }\n }\n }\n } catch (error) {\n this.logger.warn('Failed to parse WebSocket message', { error, data });\n }\n }\n\n /**\n * Parse a WebSocket message into a ProgressEvent\n */\n private parseProgressEvent(message: WSMessage): ProgressEvent | null {\n switch (message.type) {\n case 'executing':\n return {\n type: 'executing',\n nodeId: message.data?.node,\n promptId: message.data?.prompt_id,\n };\n\n case 'progress':\n return {\n type: 'progress',\n value: message.data?.value,\n max: message.data?.max,\n promptId: message.data?.prompt_id,\n };\n\n case 'execution_cached':\n return {\n type: 'execution_cached',\n promptId: message.data?.prompt_id,\n };\n\n case 'executed':\n return {\n type: 'executed',\n nodeId: message.data?.node,\n promptId: message.data?.prompt_id,\n output: message.data?.output,\n };\n\n case 'execution_error':\n return {\n type: 'execution_error',\n promptId: message.data?.prompt_id,\n error: message.data?.exception_message,\n };\n\n default:\n return null;\n }\n }\n\n /**\n * Disconnect from ComfyUI\n */\n async disconnect(): Promise<void> {\n this.options.reconnect.enabled = false; // Prevent auto-reconnect\n this.messageHandlers.clear();\n\n if (this.ws) {\n this.ws.close();\n this.ws = null;\n }\n\n this.logger.info('Disconnected from ComfyUI');\n }\n\n /**\n * Make an HTTP request to ComfyUI\n *\n * @throws {ComfyUIRequestError} for a non-2xx response, with the status and\n * the parsed body (for a rejected prompt, ComfyUI's `node_errors`)\n */\n private async request<T>(\n path: string,\n options: {\n method?: 'GET' | 'POST' | 'DELETE';\n body?: unknown;\n formData?: FormData;\n } = {},\n ): Promise<T> {\n const url = `${this.httpUrl}${path}`;\n\n const headers: Record<string, string> = {\n ...this.options.headers,\n };\n\n if (options.body && !options.formData) {\n headers['Content-Type'] = 'application/json';\n }\n\n const response = await fetch(url, {\n method: options.method ?? 'GET',\n headers,\n body:\n options.formData ??\n (options.body ? JSON.stringify(options.body) : undefined),\n signal: AbortSignal.timeout(this.options.timeout),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new ComfyUIRequestError({\n status: response.status,\n method: options.method ?? 'GET',\n path,\n bodyText: errorText,\n });\n }\n\n return response.json();\n }\n\n /**\n * Queue a workflow for execution\n *\n * @param workflow - The ComfyUI workflow to execute\n * @param clientId - Optional client ID (uses default if not provided)\n * @returns Promise resolving to prompt result with ID\n */\n async queuePrompt(\n workflow: ComfyWorkflow,\n clientId?: string,\n ): Promise<PromptResult> {\n const response = await this.request<{\n prompt_id: string;\n number: number;\n node_errors?: Record<string, string[]>;\n }>('/prompt', {\n method: 'POST',\n body: {\n prompt: workflow,\n client_id: clientId ?? this.clientId,\n },\n });\n\n return {\n promptId: response.prompt_id,\n number: response.number,\n nodeErrors: response.node_errors,\n };\n }\n\n /**\n * Subscribe to progress events for a prompt\n *\n * @param promptId - The prompt ID to monitor\n * @param handler - Callback for progress events\n * @returns Unsubscribe function\n */\n onProgress(\n promptId: string,\n handler: (event: ProgressEvent) => void,\n ): () => void {\n if (!this.messageHandlers.has(promptId)) {\n this.messageHandlers.set(promptId, new Set());\n }\n\n this.messageHandlers.get(promptId)?.add(handler);\n\n return () => {\n this.messageHandlers.get(promptId)?.delete(handler);\n if (this.messageHandlers.get(promptId)?.size === 0) {\n this.messageHandlers.delete(promptId);\n }\n };\n }\n\n /**\n * Wait for a prompt to complete\n *\n * @param promptId - The prompt ID to wait for\n * @param options - Wait options including progress callback\n * @returns Promise resolving to the history entry\n */\n async waitForCompletion(\n promptId: string,\n options: WaitOptions = {},\n ): Promise<HistoryEntry> {\n const timeout = options.timeout ?? this.options.timeout;\n const startTime = Date.now();\n\n return new Promise((resolve, reject) => {\n let resolved = false;\n\n // Set up timeout\n const timeoutId =\n timeout > 0\n ? setTimeout(() => {\n if (!resolved) {\n resolved = true;\n unsubscribe();\n reject(new Error(`Timeout waiting for prompt ${promptId}`));\n }\n }, timeout)\n : null;\n\n // Subscribe to progress events\n const unsubscribe = this.onProgress(promptId, async (event) => {\n // Forward progress events\n options.onProgress?.(event);\n\n // Check for completion or error\n if (event.type === 'executed' && event.nodeId === null) {\n // Workflow completed (null nodeId means no more nodes to execute)\n if (!resolved) {\n resolved = true;\n if (timeoutId) clearTimeout(timeoutId);\n unsubscribe();\n\n try {\n const history = await this.getHistory(promptId);\n resolve(history);\n } catch (error) {\n reject(error);\n }\n }\n } else if (event.type === 'execution_error') {\n if (!resolved) {\n resolved = true;\n if (timeoutId) clearTimeout(timeoutId);\n unsubscribe();\n reject(new Error(`Workflow execution error: ${event.error}`));\n }\n }\n });\n\n // Fallback: poll history if WebSocket doesn't give completion\n const pollHistory = async () => {\n while (\n !resolved &&\n (timeout === 0 || Date.now() - startTime < timeout)\n ) {\n await new Promise((r) => setTimeout(r, options.pollInterval ?? 1000));\n\n if (resolved) break;\n\n try {\n const history = await this.getHistory(promptId);\n if (history.status.completed) {\n if (!resolved) {\n resolved = true;\n if (timeoutId) clearTimeout(timeoutId);\n unsubscribe();\n resolve(history);\n }\n break;\n }\n } catch {\n // History not available yet, continue polling\n }\n }\n };\n\n // Start polling as fallback\n pollHistory().catch(() => {});\n });\n }\n\n /**\n * Get history for a specific prompt\n *\n * @param promptId - The prompt ID to get history for\n * @returns Promise resolving to the history entry\n */\n async getHistory(promptId: string): Promise<HistoryEntry> {\n const response = await this.request<Record<string, any>>(\n `/history/${promptId}`,\n );\n\n const entry = response[promptId];\n if (!entry) {\n throw new ValidationError(`History not found for prompt ${promptId}`);\n }\n\n return {\n promptId,\n status: entry.status,\n outputs: entry.outputs,\n prompt: entry.prompt,\n };\n }\n\n /**\n * Download an output file from ComfyUI\n *\n * @param filename - Name of the file to download\n * @param subfolder - Subfolder where file is located\n * @param type - Type of file location ('output', 'temp', or 'input')\n * @returns Promise resolving to the file buffer\n */\n async downloadOutput(\n filename: string,\n subfolder: string = '',\n type: 'output' | 'temp' | 'input' = 'output',\n ): Promise<Buffer> {\n const params = new URLSearchParams({\n filename,\n subfolder,\n type,\n });\n\n const url = `${this.httpUrl}/view?${params}`;\n const response = await fetch(url, {\n headers: this.options.headers,\n signal: AbortSignal.timeout(this.options.timeout),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to download file: ${response.status}`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n }\n\n /**\n * Upload a file to ComfyUI\n *\n * @param file - File buffer to upload\n * @param filename - Name for the file\n * @param type - Where to upload ('input' or 'temp')\n * @param overwrite - Whether to overwrite existing file\n * @returns Promise resolving to upload result\n */\n async uploadFile(\n file: Buffer,\n filename: string,\n type: 'input' | 'temp' = 'input',\n overwrite = false,\n ): Promise<UploadResult> {\n const formData = new FormData();\n formData.append('image', new Blob([new Uint8Array(file)]), filename);\n formData.append('type', type);\n formData.append('overwrite', String(overwrite));\n\n const response = await this.request<{\n name: string;\n subfolder: string;\n type: string;\n }>('/upload/image', {\n method: 'POST',\n formData,\n });\n\n return {\n name: response.name,\n subfolder: response.subfolder,\n type: response.type as 'input' | 'temp' | 'output',\n };\n }\n\n /**\n * Get system statistics from ComfyUI\n *\n * @returns Promise resolving to system stats\n */\n async getSystemStats(): Promise<SystemStats> {\n return this.request<SystemStats>('/system_stats');\n }\n\n /**\n * Get the current queue status\n *\n * @returns Promise resolving to queue status\n */\n async getQueue(): Promise<QueueStatus> {\n const response = await this.request<{\n queue_running: any[];\n queue_pending: any[];\n }>('/queue');\n\n return {\n running: response.queue_running,\n pending: response.queue_pending,\n };\n }\n\n /**\n * Interrupt the current execution\n */\n async interrupt(): Promise<void> {\n await this.request('/interrupt', { method: 'POST' });\n }\n\n /**\n * Clear the execution queue\n */\n async clearQueue(): Promise<void> {\n await this.request('/queue', {\n method: 'POST',\n body: { clear: true },\n });\n }\n\n /**\n * Delete a specific item from the queue\n *\n * @param promptId - The prompt ID to delete\n */\n async deleteFromQueue(promptId: string): Promise<void> {\n await this.request('/queue', {\n method: 'POST',\n body: { delete: [promptId] },\n });\n }\n}\n\n/**\n * Helper function to inject parameters into a workflow\n *\n * @param workflow - The base workflow\n * @param mapping - Node mapping defining where to inject\n * @param values - Values to inject\n * @returns Modified workflow with injected values\n */\nexport function injectWorkflowParams(\n workflow: ComfyWorkflow,\n mapping: NodeMapping,\n values: Record<string, any>,\n): ComfyWorkflow {\n const result = JSON.parse(JSON.stringify(workflow));\n\n for (const [key, nodeId] of Object.entries(mapping)) {\n if (nodeId && values[key] !== undefined && result[nodeId]) {\n // Find the appropriate input field and update it\n const node = result[nodeId];\n\n // Common input field names for different node types\n const inputFieldMap: Record<string, string> = {\n seedImage: 'image',\n audioFile: 'audio',\n baseVideo: 'video',\n prompt: 'text',\n negativePrompt: 'text',\n };\n\n const inputField = inputFieldMap[key] ?? key;\n if (node.inputs && inputField in node.inputs) {\n node.inputs[inputField] = values[key];\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,sBAAb,cAAyC,SAAS;;CAEhD;;CAEA;;CAEA;;CAEA;;;;;CAKA;;CAEA;CAEA,YAAY,OAKT;EACD,MAAM,2BAA2B,MAAM,OAAO,GAAG,MAAM,YAAY;GACjE,QAAQ,MAAM;GACd,QAAQ,MAAM;GACd,MAAM,MAAM;EACd,CAAC;EACD,KAAK,SAAS,MAAM;EACpB,KAAK,SAAS,MAAM;EACpB,KAAK,OAAO,MAAM;EAClB,KAAK,OAAO,UAAU,MAAM,QAAQ;EAEpC,IACE,KAAK,QACL,OAAO,KAAK,SAAS,YACrB,CAAC,MAAM,QAAQ,KAAK,IAAI,GACxB;GACA,MAAM,EAAE,OAAO,aAAa,eAAe,KAAK;GAKhD,IACE,cACA,OAAO,eAAe,YACtB,CAAC,MAAM,QAAQ,UAAU,KACzB,OAAO,KAAK,UAAU,CAAC,CAAC,SAAS,GAEjC,KAAK,aAAa;GAEpB,IAAI,UAAU,KAAA,GACZ,KAAK,cAAc;EAEvB;CACF;AACF;AAEA,SAAS,UAAU,MAAuB;CACxC,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QA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;GACL,SAAS,SAAS;GAClB,SAAS,SAAS;EACpB;CACF;;;;CAKA,MAAM,YAA2B;EAC/B,MAAM,KAAK,QAAQ,cAAc,EAAE,QAAQ,OAAO,CAAC;CACrD;;;;CAKA,MAAM,aAA4B;EAChC,MAAM,KAAK,QAAQ,UAAU;GAC3B,QAAQ;GACR,MAAM,EAAE,OAAO,KAAK;EACtB,CAAC;CACH;;;;;;CAOA,MAAM,gBAAgB,UAAiC;EACrD,MAAM,KAAK,QAAQ,UAAU;GAC3B,QAAQ;GACR,MAAM,EAAE,QAAQ,CAAC,QAAQ,EAAE;EAC7B,CAAC;CACH;AACF;;;;;;;;;AAUA,SAAgB,qBACd,UACA,SACA,QACe;CACf,MAAM,SAAS,KAAK,MAAM,KAAK,UAAU,QAAQ,CAAC;CAElD,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,OAAO,GAChD,IAAI,UAAU,OAAO,SAAS,KAAA,KAAa,OAAO,SAAS;EAEzD,MAAM,OAAO,OAAO;EAWpB,MAAM,aAAa;GAPjB,WAAW;GACX,WAAW;GACX,WAAW;GACX,QAAQ;GACR,gBAAgB;EAGC,EAAc,QAAQ;EACzC,IAAI,KAAK,UAAU,cAAc,KAAK,QACpC,KAAK,OAAO,cAAc,OAAO;CAErC;CAGF,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/comfyui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.111.0",
|
|
4
4
|
"description": "ComfyUI API client for workflow orchestration and video generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@happyvertical/logger": "0.
|
|
16
|
-
"@happyvertical/utils": "0.
|
|
15
|
+
"@happyvertical/logger": "0.111.0",
|
|
16
|
+
"@happyvertical/utils": "0.111.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "25.0.10",
|