comfy-ts 0.4.0 → 1.0.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 +349 -255
- package/dist/DefinedWorkflow-O3ynII3Y.js +598 -0
- package/dist/DefinedWorkflow-O3ynII3Y.js.map +1 -0
- package/dist/cli.js +3969 -128
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1167 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +401 -115
- package/dist/index.d.ts +401 -115
- package/dist/index.js +1159 -173
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-SDSJo1Qf.js → run-tui-BFhba_oG.js} +132 -609
- package/dist/run-tui-BFhba_oG.js.map +1 -0
- package/examples/01-txt2img.cflow.ts +50 -0
- package/examples/02-img2img-upload.cflow.ts +66 -0
- package/examples/03-export-workflow-json.cflow.ts +56 -0
- package/examples/04-krea2-turbo-t2i.cflow.ts +125 -0
- package/examples/05-comfy-cloud.cflow.ts +67 -0
- package/examples/comfy-cloud/sdk.d.ts +122674 -0
- package/guide-for-agents.md +166 -0
- package/package.json +6 -1
- package/src/cli/comfy-ts-cli.ts +19 -2
- package/src/cli/gen.ts +21 -12
- package/src/cli/tui/components/TreePanel.tsx +15 -2
- package/src/cli/tui/discoverWorkflows.ts +79 -0
- package/src/cli/tui/run-tui.tsx +51 -23
- package/src/cli/tui/state/HostSt.ts +2 -3
- package/src/cli/tui/state/TreeSt.ts +30 -6
- package/src/cli/tui/state/TuiSt.ts +21 -3
- package/src/cli/tui/state/WorkflowsSt.ts +15 -1
- package/src/host/ComfyHost.ts +203 -77
- package/src/host/ComfyManager.ts +10 -9
- package/src/host/ComfyUploader.ts +1 -2
- package/src/host/ResilientWebsocket.ts +3 -1
- package/src/host/hostUrl.ts +59 -0
- package/src/host/loraManagerApi.ts +5 -4
- package/src/index.ts +20 -1
- package/src/litegraph/CanonicalWorkflow.ts +77 -0
- package/src/litegraph/LiteGraphGroup.ts +9 -7
- package/src/litegraph/LiteGraphJSON.ts +34 -13
- package/src/litegraph/LiteGraphLink.ts +32 -2
- package/src/litegraph/LiteGraphNode.ts +18 -33
- package/src/litegraph/LiteGraphNodeInput.ts +10 -8
- package/src/litegraph/LiteGraphNodeOutput.ts +2 -3
- package/src/litegraph/LiteGraphSubgraphDef.ts +74 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +4 -4
- package/src/litegraph/expandSubgraphs.ts +352 -0
- package/src/litegraph/normalizeWorkflow.ts +141 -0
- package/src/runner/ComfyExecution.ts +4 -5
- package/src/runner/ComfyWorkflow.ts +2 -2
- package/src/runner/wsBinaryFrame.ts +48 -0
- package/src/sdk-generator/Primitives.ts +6 -24
- package/src/sdk-generator/comfy-api-json.ts +3 -1
- package/src/sdk-generator/inputWidgetKind.ts +179 -0
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +372 -96
- package/src/state.ts +13 -2
- package/dist/log-CdfgILde.js +0 -10
- package/dist/log-CdfgILde.js.map +0 -1
- package/dist/run-tui-SDSJo1Qf.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -5604,7 +5604,9 @@ type ComfyApiJson = {
|
|
|
5604
5604
|
};
|
|
5605
5605
|
type ComfyApiNodeJson = {
|
|
5606
5606
|
inputs: {
|
|
5607
|
-
[key: string]: [string, number] | string | number | boolean | null
|
|
5607
|
+
[key: string]: [string, number] | string | number | boolean | null | {
|
|
5608
|
+
[key: string]: unknown;
|
|
5609
|
+
};
|
|
5608
5610
|
};
|
|
5609
5611
|
class_type: string;
|
|
5610
5612
|
};
|
|
@@ -6071,112 +6073,6 @@ declare class ComfyExecution {
|
|
|
6071
6073
|
private _finish;
|
|
6072
6074
|
}
|
|
6073
6075
|
//#endregion
|
|
6074
|
-
//#region src/litegraph/LiteGraphGroup.d.ts
|
|
6075
|
-
type LiteGraphGroup = {
|
|
6076
|
-
title: string;
|
|
6077
|
-
bounding: [number, number, number, number];
|
|
6078
|
-
color: string;
|
|
6079
|
-
font_size: number;
|
|
6080
|
-
flags: EmptyRecord;
|
|
6081
|
-
};
|
|
6082
|
-
//#endregion
|
|
6083
|
-
//#region src/litegraph/LiteGraphLinkID.d.ts
|
|
6084
|
-
declare const LiteGraphLinkID_: import("arktype/internal/variants/object.ts").ObjectType<Branded<number, {
|
|
6085
|
-
LiteGraphLinkID: true;
|
|
6086
|
-
}>, {}>;
|
|
6087
|
-
type LiteGraphLinkID = typeof LiteGraphLinkID_.infer;
|
|
6088
|
-
//#endregion
|
|
6089
|
-
//#region src/litegraph/LiteGraphLink.d.ts
|
|
6090
|
-
type LiteGraphLink = [linkId: LiteGraphLinkID, fromNodeId: number, fromNodeOutputIx: number, toNodeId: number, toNodeInputIx: number, linkType: string];
|
|
6091
|
-
//#endregion
|
|
6092
|
-
//#region src/litegraph/LiteGraphNodeInput.d.ts
|
|
6093
|
-
type LiteGraphNodeInput = {
|
|
6094
|
-
name: string;
|
|
6095
|
-
type: string;
|
|
6096
|
-
link: LiteGraphLinkID | null;
|
|
6097
|
-
shape?: number;
|
|
6098
|
-
widget?: {
|
|
6099
|
-
name: string;
|
|
6100
|
-
config: unknown;
|
|
6101
|
-
};
|
|
6102
|
-
};
|
|
6103
|
-
//#endregion
|
|
6104
|
-
//#region src/litegraph/LiteGraphSlotIndex.d.ts
|
|
6105
|
-
declare const LiteGraphSlotIndex_: import("arktype/internal/variants/object.ts").ObjectType<Branded<number, {
|
|
6106
|
-
LiteGraphSlotIndex: true;
|
|
6107
|
-
}>, {}>;
|
|
6108
|
-
type LiteGraphSlotIndex = typeof LiteGraphSlotIndex_.infer;
|
|
6109
|
-
//#endregion
|
|
6110
|
-
//#region src/litegraph/LiteGraphNodeOutput.d.ts
|
|
6111
|
-
type LiteGraphNodeOutput = {
|
|
6112
|
-
name: string;
|
|
6113
|
-
type: string;
|
|
6114
|
-
links: LiteGraphLinkID[] | null;
|
|
6115
|
-
shape?: number;
|
|
6116
|
-
slot_index?: LiteGraphSlotIndex;
|
|
6117
|
-
};
|
|
6118
|
-
//#endregion
|
|
6119
|
-
//#region src/litegraph/LiteGraphNode.d.ts
|
|
6120
|
-
type LiteGraphNode = {
|
|
6121
|
-
id: number;
|
|
6122
|
-
type: string;
|
|
6123
|
-
title?: string;
|
|
6124
|
-
color?: string;
|
|
6125
|
-
bgColor?: string;
|
|
6126
|
-
pos: {
|
|
6127
|
-
'0': number;
|
|
6128
|
-
'1': number;
|
|
6129
|
-
};
|
|
6130
|
-
size: {
|
|
6131
|
-
'0': number;
|
|
6132
|
-
'1': number;
|
|
6133
|
-
};
|
|
6134
|
-
flags?: EmptyRecord;
|
|
6135
|
-
order?: number;
|
|
6136
|
-
/**
|
|
6137
|
-
* 0 = normal
|
|
6138
|
-
* 1 = ?????
|
|
6139
|
-
* 2 = muted
|
|
6140
|
-
* */
|
|
6141
|
-
mode?: number;
|
|
6142
|
-
inputs?: LiteGraphNodeInput[];
|
|
6143
|
-
outputs: LiteGraphNodeOutput[];
|
|
6144
|
-
isVirtualNode?: boolean;
|
|
6145
|
-
properties?: {
|
|
6146
|
-
/**
|
|
6147
|
-
* S&R stands for search and replace
|
|
6148
|
-
* // 💬 2024-11-13 rvion: do we want to populate taht someday soon
|
|
6149
|
-
*/
|
|
6150
|
-
'Node name for S&R'?: string;
|
|
6151
|
-
/** when set to true, it.... */
|
|
6152
|
-
showOutputText?: boolean;
|
|
6153
|
-
/** no clue what it does */
|
|
6154
|
-
horizontal?: boolean;
|
|
6155
|
-
};
|
|
6156
|
-
widgets_values?: unknown[];
|
|
6157
|
-
};
|
|
6158
|
-
//#endregion
|
|
6159
|
-
//#region src/litegraph/LiteGraphJSON.d.ts
|
|
6160
|
-
/** litegraph workflow are stored... in a very unpractical format */
|
|
6161
|
-
type LiteGraphJSON = {
|
|
6162
|
-
last_node_id: number;
|
|
6163
|
-
last_link_id: number;
|
|
6164
|
-
nodes: LiteGraphNode[];
|
|
6165
|
-
links: LiteGraphLink[];
|
|
6166
|
-
groups: LiteGraphGroup[];
|
|
6167
|
-
config: EmptyRecord;
|
|
6168
|
-
extra: {
|
|
6169
|
-
ds?: {
|
|
6170
|
-
scale: number;
|
|
6171
|
-
offset: {
|
|
6172
|
-
0: number;
|
|
6173
|
-
1: number;
|
|
6174
|
-
};
|
|
6175
|
-
};
|
|
6176
|
-
};
|
|
6177
|
-
version: 0.4;
|
|
6178
|
-
};
|
|
6179
|
-
//#endregion
|
|
6180
6076
|
//#region src/sdk-generator/comfyui-sdk-codegen.d.ts
|
|
6181
6077
|
/**
|
|
6182
6078
|
* convert a host id to the namespace name it gets inside the global `Comfy` namespace
|
|
@@ -8790,9 +8686,15 @@ type PluginSuggestion = {
|
|
|
8790
8686
|
declare class ComfyManager {
|
|
8791
8687
|
host: {
|
|
8792
8688
|
getServerHostHTTP: () => string;
|
|
8689
|
+
fetch: (route: string, init?: RequestInit, p?: {
|
|
8690
|
+
apiPrefix?: boolean;
|
|
8691
|
+
}) => Promise<Response>;
|
|
8793
8692
|
};
|
|
8794
8693
|
constructor(host: {
|
|
8795
8694
|
getServerHostHTTP: () => string;
|
|
8695
|
+
fetch: (route: string, init?: RequestInit, p?: {
|
|
8696
|
+
apiPrefix?: boolean;
|
|
8697
|
+
}) => Promise<Response>;
|
|
8796
8698
|
});
|
|
8797
8699
|
get registry(): ComfyRegistry;
|
|
8798
8700
|
fetchPluginsAndModels: () => Promise<void>;
|
|
@@ -8844,6 +8746,29 @@ declare class ComfyUploader {
|
|
|
8844
8746
|
}) => Promise<ComfyImageName>;
|
|
8845
8747
|
}
|
|
8846
8748
|
//#endregion
|
|
8749
|
+
//#region src/host/hostUrl.d.ts
|
|
8750
|
+
/** pure url layer for ComfyHost: parse once, render everywhere. No comfyts global. */
|
|
8751
|
+
type ParsedHostBase = {
|
|
8752
|
+
scheme: 'http' | 'https';
|
|
8753
|
+
host: string;
|
|
8754
|
+
/** always concrete (defaults 80/443 from the scheme when the url omits it) */
|
|
8755
|
+
port: number;
|
|
8756
|
+
/** '' or '/segment…' with no trailing slash */
|
|
8757
|
+
basePath: string;
|
|
8758
|
+
};
|
|
8759
|
+
/** exactly ONE of `url` or the legacy `host`+`port` (+`https?`) spelling */
|
|
8760
|
+
declare function parseHostBase(p: {
|
|
8761
|
+
id: string;
|
|
8762
|
+
url?: string;
|
|
8763
|
+
host?: string;
|
|
8764
|
+
port?: number;
|
|
8765
|
+
https?: boolean;
|
|
8766
|
+
}): ParsedHostBase;
|
|
8767
|
+
/** http(s) base, port omitted when it is the scheme default */
|
|
8768
|
+
declare function renderHttpBase(p: ParsedHostBase): string;
|
|
8769
|
+
/** ws(s) endpoint; auth NEVER rides the query string (headers own it) */
|
|
8770
|
+
declare function renderWsUrl(p: ParsedHostBase): string;
|
|
8771
|
+
//#endregion
|
|
8847
8772
|
//#region src/host/ResilientWebsocket.d.ts
|
|
8848
8773
|
type Message = string | Buffer;
|
|
8849
8774
|
type WsDebugMessage = {
|
|
@@ -8854,6 +8779,8 @@ type WsDebugMessage = {
|
|
|
8854
8779
|
declare class ResilientWebSocketClient {
|
|
8855
8780
|
options: {
|
|
8856
8781
|
url: () => string;
|
|
8782
|
+
/** upgrade-request headers (auth: X-API-Key & co) — a thunk, re-read on every reconnect */
|
|
8783
|
+
headers?: () => Record<string, string>;
|
|
8857
8784
|
onMessage: (event: MessageEvent) => void;
|
|
8858
8785
|
onConnectOrReconnect: () => void;
|
|
8859
8786
|
onClose: () => void;
|
|
@@ -8867,6 +8794,8 @@ declare class ResilientWebSocketClient {
|
|
|
8867
8794
|
private addError;
|
|
8868
8795
|
constructor(options: {
|
|
8869
8796
|
url: () => string;
|
|
8797
|
+
/** upgrade-request headers (auth: X-API-Key & co) — a thunk, re-read on every reconnect */
|
|
8798
|
+
headers?: () => Record<string, string>;
|
|
8870
8799
|
onMessage: (event: MessageEvent) => void;
|
|
8871
8800
|
onConnectOrReconnect: () => void;
|
|
8872
8801
|
onClose: () => void;
|
|
@@ -9225,9 +9154,23 @@ type ComfyHostID = Tagged<string, {
|
|
|
9225
9154
|
}>;
|
|
9226
9155
|
type ComfyHostData = {
|
|
9227
9156
|
id: string;
|
|
9228
|
-
|
|
9229
|
-
|
|
9157
|
+
/** full base url as pasted from a provider (https://cloud.comfy.org,
|
|
9158
|
+
* https://xxx.modal.run, http://192.168.1.5:8188/comfy).
|
|
9159
|
+
* Exactly ONE of url OR the legacy host+port (+https?) spelling. */
|
|
9160
|
+
url?: string;
|
|
9161
|
+
host?: string;
|
|
9162
|
+
port?: number;
|
|
9230
9163
|
https?: boolean;
|
|
9164
|
+
/** sent as X-API-Key on every request AND the ws upgrade.
|
|
9165
|
+
* NEVER persist the value: read it from an env var (e.g. COMFY_CLOUD_API_KEY) */
|
|
9166
|
+
apiKey?: string;
|
|
9167
|
+
/** default true. false = never write sdk.d.ts to .comfy-ts/hosts/<id>/ —
|
|
9168
|
+
* schema updates stay in-memory. The comfy-cloud example sets false: its sdk
|
|
9169
|
+
* home is the COMMITTED examples/comfy-cloud/sdk.d.ts (gen:sdk:cloud), and a
|
|
9170
|
+
* second copy under .comfy-ts/hosts/ would double-declare the globals. */
|
|
9171
|
+
sdkAutoWrite?: boolean;
|
|
9172
|
+
/** extra headers merged into every request + the ws upgrade (Modal-style auth pairs) */
|
|
9173
|
+
headers?: Record<string, string>;
|
|
9231
9174
|
installType?: ComfyInstallType;
|
|
9232
9175
|
onWsMessageAny?: (e: MessageEvent) => void;
|
|
9233
9176
|
onWsMessageArrayBuffer?: (e: ArrayBuffer) => void;
|
|
@@ -9250,6 +9193,14 @@ type ServerLog = {
|
|
|
9250
9193
|
content: string;
|
|
9251
9194
|
id: number;
|
|
9252
9195
|
};
|
|
9196
|
+
/** auth failure with a SPECIFIC meaning (per the Comfy Cloud error table):
|
|
9197
|
+
* 401 invalid/missing key · 402 insufficient credits · 429 subscription inactive
|
|
9198
|
+
* (or plain rate limiting on non-cloud hosts). The key value never appears here. */
|
|
9199
|
+
declare class ComfyHostAuthError extends Error {
|
|
9200
|
+
code: 401 | 402 | 429;
|
|
9201
|
+
hostId: string;
|
|
9202
|
+
constructor(code: 401 | 402 | 429, hostId: string, message: string);
|
|
9203
|
+
}
|
|
9253
9204
|
declare class ComfyHost<ID extends string = string> {
|
|
9254
9205
|
data: ComfyHostData & {
|
|
9255
9206
|
id: ID;
|
|
@@ -9261,6 +9212,8 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9261
9212
|
/** the schema instance with all methods to interract with the host schema */
|
|
9262
9213
|
schema: ComfySchema;
|
|
9263
9214
|
uploader: ComfyUploader;
|
|
9215
|
+
/** parsed ONCE from data (url-first or legacy host/port/https) — the url ground truth */
|
|
9216
|
+
readonly base: ParsedHostBase;
|
|
9264
9217
|
constructor(data: ComfyHostData & {
|
|
9265
9218
|
id: ID;
|
|
9266
9219
|
});
|
|
@@ -9285,6 +9238,30 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9285
9238
|
installCustomNode: (customNode: ComfyManagerPluginInfo) => Promise<boolean>;
|
|
9286
9239
|
getServerHostHTTP(): string;
|
|
9287
9240
|
getWSUrl: () => string;
|
|
9241
|
+
/** extra headers + X-API-Key, for every http request AND the ws upgrade */
|
|
9242
|
+
private authHeaders;
|
|
9243
|
+
/** remembered /api-prefix verdict for this host; null until first probed */
|
|
9244
|
+
private _apiPrefix;
|
|
9245
|
+
/**
|
|
9246
|
+
* the ONE http path to this host: joins basePath, injects X-API-Key + extra
|
|
9247
|
+
* headers, prefers `/api<route>` (required by Comfy Cloud, canonical since
|
|
9248
|
+
* custom nodes hijack bare routes) with a bare-route fallback on 404/405 for
|
|
9249
|
+
* old local servers (winner memoized; the other spelling is still retried
|
|
9250
|
+
* when the memo misses — mixed servers exist, e.g. /internal is bare-only).
|
|
9251
|
+
* Auth failures throw a typed ComfyHostAuthError instead of generic noise.
|
|
9252
|
+
* `p.apiPrefix: false` opts a route out of the prefix game entirely.
|
|
9253
|
+
*/
|
|
9254
|
+
fetch: (route: string, init?: RequestInit, p?: {
|
|
9255
|
+
apiPrefix?: boolean;
|
|
9256
|
+
}) => Promise<Response>;
|
|
9257
|
+
/**
|
|
9258
|
+
* binary download path: Comfy Cloud answers `/api/view` with a 302 to a
|
|
9259
|
+
* temporary signed URL. fetch only auto-strips Authorization/cookies on
|
|
9260
|
+
* cross-origin redirects — a custom X-API-Key WOULD be forwarded to the
|
|
9261
|
+
* storage host — so we follow the Location manually with a CLEAN fetch.
|
|
9262
|
+
*/
|
|
9263
|
+
fetchFile: (route: string) => Promise<Response>;
|
|
9264
|
+
private throwOnAuthError;
|
|
9288
9265
|
schemaRetrievalLogs: string[];
|
|
9289
9266
|
resetLog: () => void;
|
|
9290
9267
|
get isConnected(): boolean;
|
|
@@ -9297,8 +9274,12 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9297
9274
|
* (scripts, the TUI).
|
|
9298
9275
|
*/
|
|
9299
9276
|
defineWorkflow: <V extends VarsSpec>(spec: DefineWorkflowSpec<ID, V>) => DefinedWorkflow<ID, V>;
|
|
9300
|
-
/**
|
|
9301
|
-
|
|
9277
|
+
/**
|
|
9278
|
+
* import a workflow.json (litegraph format) as a live, editable workflow.
|
|
9279
|
+
* Accepts unknown: the JSON is ark-validated + normalized (parseWorkflowJson)
|
|
9280
|
+
* before conversion — invalid documents throw WorkflowNormalizeError.
|
|
9281
|
+
*/
|
|
9282
|
+
importWorkflowJson: (json: unknown, p?: {
|
|
9302
9283
|
id?: string;
|
|
9303
9284
|
}) => ComfyWorkflow<ID>;
|
|
9304
9285
|
/** import an api.json (ComfyUI prompt format) as a live, editable workflow */
|
|
@@ -9339,9 +9320,13 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9339
9320
|
schemaUpdateResult: SchemaUpdateResult;
|
|
9340
9321
|
private _schemaFromCache;
|
|
9341
9322
|
/** load the schema from .comfy-ts/hosts/<id>/ without connecting (offline workflows, fast starts).
|
|
9342
|
-
* idempotent like connect(): N co-imported modules parse the ~4MB cache once
|
|
9323
|
+
* idempotent like connect(): N co-imported modules parse the ~4MB cache once.
|
|
9324
|
+
* A MISSING cache degrades LOUDLY to the base types instead of failing the
|
|
9325
|
+
* module import (a fresh consumer project has no cache yet — the bundled
|
|
9326
|
+
* examples must still open in the TUI; run() fetches the real schema through
|
|
9327
|
+
* connect() anyway). Not memoized in that case, so a later gen/connect retries. */
|
|
9343
9328
|
loadSchemaFromCache(): Promise<void>;
|
|
9344
|
-
/** POST a JSON route
|
|
9329
|
+
/** POST a JSON route through host.fetch (/api preferred, bare fallback) */
|
|
9345
9330
|
private postJSON_;
|
|
9346
9331
|
/** drop every PENDING prompt from the server queue (the running one keeps going) */
|
|
9347
9332
|
clearQueue: () => Promise<void>;
|
|
@@ -9357,7 +9342,7 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9357
9342
|
enabled: boolean;
|
|
9358
9343
|
clientId: string;
|
|
9359
9344
|
}) => Promise<void>;
|
|
9360
|
-
/** GET a JSON route
|
|
9345
|
+
/** GET a JSON route through host.fetch (/api preferred, bare fallback) */
|
|
9361
9346
|
private fetchJSON_;
|
|
9362
9347
|
/** retrieve the comfy spec from the schema*/
|
|
9363
9348
|
fetchAndUpdateSchema: () => Promise<void>;
|
|
@@ -9459,11 +9444,183 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
9459
9444
|
}) => void>;
|
|
9460
9445
|
/** the session assigned to us by the server */
|
|
9461
9446
|
comfySessionId: string; /** send by ComfyUI server */
|
|
9447
|
+
/** binary frame types we already complained about (one log per type, no spam) */
|
|
9448
|
+
private _unknownBinaryFrameTypes;
|
|
9462
9449
|
/** handy to keep around */
|
|
9463
9450
|
status: ComfyStatusData['status'] | null;
|
|
9464
9451
|
onMessage(e: MessageEvent): void;
|
|
9465
9452
|
}
|
|
9466
9453
|
//#endregion
|
|
9454
|
+
//#region src/litegraph/LiteGraphGroup.d.ts
|
|
9455
|
+
type LiteGraphGroup = {
|
|
9456
|
+
id?: number;
|
|
9457
|
+
title: string;
|
|
9458
|
+
bounding: [number, number, number, number];
|
|
9459
|
+
color?: string;
|
|
9460
|
+
font_size?: number;
|
|
9461
|
+
flags?: EmptyRecord;
|
|
9462
|
+
};
|
|
9463
|
+
//#endregion
|
|
9464
|
+
//#region src/litegraph/LiteGraphLinkID.d.ts
|
|
9465
|
+
declare const LiteGraphLinkID_: import("arktype/internal/variants/object.ts").ObjectType<Branded<number, {
|
|
9466
|
+
LiteGraphLinkID: true;
|
|
9467
|
+
}>, {}>;
|
|
9468
|
+
type LiteGraphLinkID = typeof LiteGraphLinkID_.infer;
|
|
9469
|
+
//#endregion
|
|
9470
|
+
//#region src/litegraph/LiteGraphLink.d.ts
|
|
9471
|
+
/** v0.4 serialization: links are 6-tuples (our EXPORT path emits this form) */
|
|
9472
|
+
type LiteGraphLinkTuple = [linkId: LiteGraphLinkID, fromNodeId: number, fromNodeOutputIx: number, toNodeId: number, toNodeInputIx: number, linkType: string];
|
|
9473
|
+
/** v1 serialization: links are objects (subgraph definition interiors use this) */
|
|
9474
|
+
type LiteGraphLinkObject = {
|
|
9475
|
+
id: LiteGraphLinkID;
|
|
9476
|
+
origin_id: number;
|
|
9477
|
+
origin_slot: number;
|
|
9478
|
+
target_id: number;
|
|
9479
|
+
target_slot: number;
|
|
9480
|
+
type: string;
|
|
9481
|
+
parentId?: number;
|
|
9482
|
+
};
|
|
9483
|
+
type LiteGraphLink = LiteGraphLinkTuple | LiteGraphLinkObject;
|
|
9484
|
+
//#endregion
|
|
9485
|
+
//#region src/litegraph/LiteGraphNodeInput.d.ts
|
|
9486
|
+
type LiteGraphNodeInput = {
|
|
9487
|
+
name: string;
|
|
9488
|
+
type: string;
|
|
9489
|
+
link?: LiteGraphLinkID | null;
|
|
9490
|
+
shape?: number;
|
|
9491
|
+
label?: string;
|
|
9492
|
+
widget?: {
|
|
9493
|
+
name: string;
|
|
9494
|
+
config?: unknown;
|
|
9495
|
+
};
|
|
9496
|
+
};
|
|
9497
|
+
//#endregion
|
|
9498
|
+
//#region src/litegraph/LiteGraphSlotIndex.d.ts
|
|
9499
|
+
declare const LiteGraphSlotIndex_: import("arktype/internal/variants/object.ts").ObjectType<Branded<number, {
|
|
9500
|
+
LiteGraphSlotIndex: true;
|
|
9501
|
+
}>, {}>;
|
|
9502
|
+
type LiteGraphSlotIndex = typeof LiteGraphSlotIndex_.infer;
|
|
9503
|
+
//#endregion
|
|
9504
|
+
//#region src/litegraph/LiteGraphNodeOutput.d.ts
|
|
9505
|
+
type LiteGraphNodeOutput = {
|
|
9506
|
+
name: string;
|
|
9507
|
+
type: string;
|
|
9508
|
+
links?: LiteGraphLinkID[] | null;
|
|
9509
|
+
shape?: number;
|
|
9510
|
+
slot_index?: LiteGraphSlotIndex;
|
|
9511
|
+
};
|
|
9512
|
+
//#endregion
|
|
9513
|
+
//#region src/litegraph/LiteGraphNode.d.ts
|
|
9514
|
+
type LiteGraphNode = {
|
|
9515
|
+
id: number;
|
|
9516
|
+
type: string;
|
|
9517
|
+
title?: string;
|
|
9518
|
+
color?: string;
|
|
9519
|
+
bgcolor?: string;
|
|
9520
|
+
pos: {
|
|
9521
|
+
'0': number;
|
|
9522
|
+
'1': number;
|
|
9523
|
+
};
|
|
9524
|
+
size: {
|
|
9525
|
+
'0': number;
|
|
9526
|
+
'1': number;
|
|
9527
|
+
};
|
|
9528
|
+
flags?: Record<string, unknown>;
|
|
9529
|
+
order?: number;
|
|
9530
|
+
/**
|
|
9531
|
+
* 0 = always (normal), 1 = on-event, 2 = muted (never),
|
|
9532
|
+
* 3 = on-trigger, 4 = bypassed
|
|
9533
|
+
*/
|
|
9534
|
+
mode?: number;
|
|
9535
|
+
inputs?: LiteGraphNodeInput[];
|
|
9536
|
+
outputs?: LiteGraphNodeOutput[];
|
|
9537
|
+
isVirtualNode?: boolean;
|
|
9538
|
+
/** open record: proxyWidgets (subgraph widget promotion), cnr_id/ver (pack provenance), … */
|
|
9539
|
+
properties?: Record<string, unknown>;
|
|
9540
|
+
/** array form (positional) OR object form (named, e.g. VHS_VideoCombine) */
|
|
9541
|
+
widgets_values?: unknown[] | Record<string, unknown>;
|
|
9542
|
+
};
|
|
9543
|
+
//#endregion
|
|
9544
|
+
//#region src/litegraph/LiteGraphSubgraphDef.d.ts
|
|
9545
|
+
/** one exposed input/output slot of a subgraph definition */
|
|
9546
|
+
type LiteGraphSubgraphIO = {
|
|
9547
|
+
id: string;
|
|
9548
|
+
name: string;
|
|
9549
|
+
type: string;
|
|
9550
|
+
linkIds?: LiteGraphLinkID[];
|
|
9551
|
+
label?: string;
|
|
9552
|
+
localized_name?: string;
|
|
9553
|
+
pos?: {
|
|
9554
|
+
'0': number;
|
|
9555
|
+
'1': number;
|
|
9556
|
+
};
|
|
9557
|
+
shape?: number;
|
|
9558
|
+
};
|
|
9559
|
+
/**
|
|
9560
|
+
* a subgraph definition body (definitions.subgraphs[] entry). Corpus fact:
|
|
9561
|
+
* every one is a v1-shaped interior (object links, `state`) even when the
|
|
9562
|
+
* root document is v0.4 — instances reference it via node.type = this uuid.
|
|
9563
|
+
*/
|
|
9564
|
+
type LiteGraphSubgraphDef = {
|
|
9565
|
+
id: string;
|
|
9566
|
+
name: string;
|
|
9567
|
+
version: number;
|
|
9568
|
+
state?: Record<string, unknown>;
|
|
9569
|
+
revision?: number;
|
|
9570
|
+
config?: EmptyRecord;
|
|
9571
|
+
extra?: unknown;
|
|
9572
|
+
nodes: LiteGraphNode[];
|
|
9573
|
+
links: LiteGraphLinkObject[];
|
|
9574
|
+
groups?: LiteGraphGroup[];
|
|
9575
|
+
inputNode: {
|
|
9576
|
+
id: number;
|
|
9577
|
+
bounding: number[];
|
|
9578
|
+
};
|
|
9579
|
+
outputNode: {
|
|
9580
|
+
id: number;
|
|
9581
|
+
bounding: number[];
|
|
9582
|
+
};
|
|
9583
|
+
inputs: LiteGraphSubgraphIO[];
|
|
9584
|
+
outputs: LiteGraphSubgraphIO[];
|
|
9585
|
+
widgets: unknown[];
|
|
9586
|
+
};
|
|
9587
|
+
//#endregion
|
|
9588
|
+
//#region src/litegraph/LiteGraphJSON.d.ts
|
|
9589
|
+
/**
|
|
9590
|
+
* litegraph workflow root, TOLERANT: models what upstream actually serializes
|
|
9591
|
+
* across eras — v0.4 (tuple links, last_*_id) and v1 (object links, `state`),
|
|
9592
|
+
* including hybrid files (v0.4 root + v1-shaped subgraph definitions).
|
|
9593
|
+
* Downstream code never reads this shape: `normalizeWorkflow` turns it into
|
|
9594
|
+
* the strict `CanonicalWorkflow`.
|
|
9595
|
+
*/
|
|
9596
|
+
type LiteGraphJSON = {
|
|
9597
|
+
id?: string;
|
|
9598
|
+
revision?: number;
|
|
9599
|
+
last_node_id?: number;
|
|
9600
|
+
last_link_id?: number;
|
|
9601
|
+
state?: Record<string, unknown>;
|
|
9602
|
+
nodes: LiteGraphNode[];
|
|
9603
|
+
links: LiteGraphLink[];
|
|
9604
|
+
groups?: LiteGraphGroup[];
|
|
9605
|
+
config?: EmptyRecord;
|
|
9606
|
+
extra?: {
|
|
9607
|
+
ds?: {
|
|
9608
|
+
scale: number;
|
|
9609
|
+
offset: {
|
|
9610
|
+
0: number;
|
|
9611
|
+
1: number;
|
|
9612
|
+
};
|
|
9613
|
+
};
|
|
9614
|
+
};
|
|
9615
|
+
models?: unknown[];
|
|
9616
|
+
definitions?: {
|
|
9617
|
+
subgraphs: LiteGraphSubgraphDef[];
|
|
9618
|
+
};
|
|
9619
|
+
reroutes?: unknown[];
|
|
9620
|
+
floatingLinks?: unknown[];
|
|
9621
|
+
version: 0.4 | 1;
|
|
9622
|
+
};
|
|
9623
|
+
//#endregion
|
|
9467
9624
|
//#region src/runner/ComfyWorkflow.d.ts
|
|
9468
9625
|
type ProgressReport = {
|
|
9469
9626
|
percent: number;
|
|
@@ -9888,6 +10045,135 @@ declare const auto_: AUTO;
|
|
|
9888
10045
|
//#region src/litegraph/convertFlowToLiteGraphJSON.d.ts
|
|
9889
10046
|
declare const convertFlowToLiteGraphJSON: (graph: ComfyWorkflow) => LiteGraphJSON;
|
|
9890
10047
|
//#endregion
|
|
10048
|
+
//#region src/litegraph/CanonicalWorkflow.d.ts
|
|
10049
|
+
/**
|
|
10050
|
+
* the ONE strict internal shape for imported workflows. ZERO optional fields:
|
|
10051
|
+
* semantic absence is `null`, serializer noise gets a default at normalization.
|
|
10052
|
+
* Every consumer of an imported workflow JSON (converter, sweeps, TUI) reads
|
|
10053
|
+
* this type only — optionality never crosses `normalizeWorkflow`. A new
|
|
10054
|
+
* consumer needing a wire field ADDS it here (with a default), it does not
|
|
10055
|
+
* reach around the pipeline to the raw document.
|
|
10056
|
+
*/
|
|
10057
|
+
type CanonicalWorkflow = {
|
|
10058
|
+
/** subgraph instances with a definition are expanded away by normalization (expandSubgraphs.ts) */
|
|
10059
|
+
nodes: CanonicalNode[];
|
|
10060
|
+
/** object form only, both wire eras unified */
|
|
10061
|
+
links: CanonicalLink[];
|
|
10062
|
+
/** [] when the document had none */
|
|
10063
|
+
groups: CanonicalGroup[];
|
|
10064
|
+
};
|
|
10065
|
+
type CanonicalLink = {
|
|
10066
|
+
id: LiteGraphLinkID;
|
|
10067
|
+
originId: number;
|
|
10068
|
+
originSlot: number;
|
|
10069
|
+
targetId: number;
|
|
10070
|
+
targetSlot: number;
|
|
10071
|
+
type: string;
|
|
10072
|
+
};
|
|
10073
|
+
/**
|
|
10074
|
+
* raw 0/1/3 (always / on-event / on-trigger) → 'normal'; 2 → 'muted'; 4 → 'bypassed'.
|
|
10075
|
+
* Literal union on purpose: converter switches are total, no magic ints downstream.
|
|
10076
|
+
*/
|
|
10077
|
+
type NodeMode = 'normal' | 'muted' | 'bypassed';
|
|
10078
|
+
type CanonicalNode = {
|
|
10079
|
+
id: number;
|
|
10080
|
+
type: string;
|
|
10081
|
+
title: string | null;
|
|
10082
|
+
mode: NodeMode;
|
|
10083
|
+
isVirtualNode: boolean;
|
|
10084
|
+
inputs: CanonicalInput[];
|
|
10085
|
+
outputs: CanonicalOutput[];
|
|
10086
|
+
widgets: CanonicalWidgetValues;
|
|
10087
|
+
pos: [number, number];
|
|
10088
|
+
size: [number, number];
|
|
10089
|
+
properties: Record<string, unknown>;
|
|
10090
|
+
};
|
|
10091
|
+
type CanonicalInput = {
|
|
10092
|
+
name: string;
|
|
10093
|
+
type: string;
|
|
10094
|
+
link: LiteGraphLinkID | null;
|
|
10095
|
+
widgetName: string | null;
|
|
10096
|
+
};
|
|
10097
|
+
type CanonicalOutput = {
|
|
10098
|
+
name: string;
|
|
10099
|
+
type: string;
|
|
10100
|
+
links: LiteGraphLinkID[];
|
|
10101
|
+
};
|
|
10102
|
+
/**
|
|
10103
|
+
* ONE shape for all three widget-value realities: array form (positional),
|
|
10104
|
+
* object form (named, e.g. VHS_*), and subgraph promotion overrides (named).
|
|
10105
|
+
* Both fields ALWAYS present.
|
|
10106
|
+
*/
|
|
10107
|
+
type CanonicalWidgetValues = {
|
|
10108
|
+
positional: unknown[];
|
|
10109
|
+
named: Record<string, unknown>;
|
|
10110
|
+
};
|
|
10111
|
+
type CanonicalGroup = {
|
|
10112
|
+
title: string;
|
|
10113
|
+
bounding: [number, number, number, number];
|
|
10114
|
+
color: string;
|
|
10115
|
+
fontSize: number;
|
|
10116
|
+
};
|
|
10117
|
+
//#endregion
|
|
10118
|
+
//#region src/litegraph/normalizeWorkflow.d.ts
|
|
10119
|
+
type WorkflowNormalizeErrorCode = 'schema-reject' | 'subgraph-cycle' | 'subgraph-io-mismatch' | 'bad-document';
|
|
10120
|
+
/** a workflow JSON we cannot turn into a CanonicalWorkflow — loud, typed, never a cast */
|
|
10121
|
+
declare class WorkflowNormalizeError extends Error {
|
|
10122
|
+
code: WorkflowNormalizeErrorCode;
|
|
10123
|
+
detail?: unknown;
|
|
10124
|
+
constructor(code: WorkflowNormalizeErrorCode, message: string, detail?: unknown);
|
|
10125
|
+
}
|
|
10126
|
+
/**
|
|
10127
|
+
* THE one entry for foreign workflow JSON (files, clipboard, imports):
|
|
10128
|
+
* tolerant ark validation, then normalization to the strict canonical shape.
|
|
10129
|
+
*/
|
|
10130
|
+
declare const parseWorkflowJson: (json: unknown) => CanonicalWorkflow;
|
|
10131
|
+
/**
|
|
10132
|
+
* loose wire document → strict canonical document. Defaults filled, both link
|
|
10133
|
+
* eras unified, cosmetic fields dropped, subgraph definitions expanded away
|
|
10134
|
+
* (see expandSubgraphs.ts — def interiors go through the SAME per-shape
|
|
10135
|
+
* normalizers, they are v1 bodies).
|
|
10136
|
+
*/
|
|
10137
|
+
declare const normalizeWorkflow: (raw: LiteGraphJSON) => CanonicalWorkflow;
|
|
10138
|
+
//#endregion
|
|
10139
|
+
//#region src/sdk-generator/litegraphToApiRequestPayload.d.ts
|
|
10140
|
+
type WorkflowConvertErrorCode = 'unknown-node' | 'missing-widget-value' | 'invalid-widget-value' | 'unknown-dynamic-combo-option' | 'dangling-link' | 'missing-required-input' | 'unsupported-feature';
|
|
10141
|
+
/** a canonical workflow the converter cannot turn into a prompt — the code NAMES the feature that failed */
|
|
10142
|
+
declare class WorkflowConvertError extends Error {
|
|
10143
|
+
code: WorkflowConvertErrorCode;
|
|
10144
|
+
node?: {
|
|
10145
|
+
id: number;
|
|
10146
|
+
type: string;
|
|
10147
|
+
} | undefined;
|
|
10148
|
+
constructor(code: WorkflowConvertErrorCode, message: string, node?: {
|
|
10149
|
+
id: number;
|
|
10150
|
+
type: string;
|
|
10151
|
+
} | undefined);
|
|
10152
|
+
}
|
|
10153
|
+
/**
|
|
10154
|
+
* convert a normalized workflow (CanonicalWorkflow — see parseWorkflowJson)
|
|
10155
|
+
* into the api.json (prompt format) ComfyUI's POST /prompt takes.
|
|
10156
|
+
* Handles: muted nodes (skipped, consumers resolve unconnected), bypassed
|
|
10157
|
+
* nodes (mode 4: link resolution walks through to the first type-matching
|
|
10158
|
+
* input), Note/MarkdownNote/Reroute/PrimitiveNode virtual nodes (reroutes
|
|
10159
|
+
* unwrapped, primitives inlined into their consumers), widget values both
|
|
10160
|
+
* positional (with the phantom `control_after_generate` offset after seeds)
|
|
10161
|
+
* and named (object-form widgets_values + subgraph promotion overrides —
|
|
10162
|
+
* named wins, but a live link wins over both). Widget-ness is decided from
|
|
10163
|
+
* the input CONFIG (inputWidgetKind.ts): V3 string-spelled widget types
|
|
10164
|
+
* (COMBO options, dynamic combos, autogrow containers, socketless customs)
|
|
10165
|
+
* and 2024-era enums go through ONE classifier; a positional array shorter
|
|
10166
|
+
* than the schema's widget list fills schema defaults, never throws
|
|
10167
|
+
* (agent/architecture.md owns both decisions).
|
|
10168
|
+
*/
|
|
10169
|
+
declare const convertLiteGraphToPrompt: (
|
|
10170
|
+
/** the ComfySchema object (to look for references/definitions) */
|
|
10171
|
+
schema: ComfySchema,
|
|
10172
|
+
/** the normalized litegraph document */
|
|
10173
|
+
workflow: CanonicalWorkflow, opts?: {
|
|
10174
|
+
verbose?: boolean;
|
|
10175
|
+
}) => ComfyApiJson;
|
|
10176
|
+
//#endregion
|
|
9891
10177
|
//#region src/vars/loraKeywords.d.ts
|
|
9892
10178
|
declare function getLoraKeyword(name: string): string;
|
|
9893
10179
|
/** empty keyword deletes the entry; every set writes the file (tiny, rare) */
|
|
@@ -9906,5 +10192,5 @@ declare function isTuiActive(): boolean;
|
|
|
9906
10192
|
*/
|
|
9907
10193
|
declare function loraTag<N extends string = string>(name: N, strength?: number, clipStrength?: number): string;
|
|
9908
10194
|
//#endregion
|
|
9909
|
-
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, type ComfyHostData, type ComfyHostID, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageSaveFormat, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LoraNameOf, type LoraStrength, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, NodeOf, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, number_Timestamp, resultFailure, resultSuccess, setLoraKeyword, v };
|
|
10195
|
+
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageSaveFormat, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LoraNameOf, type LoraStrength, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setLoraKeyword, v };
|
|
9910
10196
|
//# sourceMappingURL=index.d.cts.map
|