comfy-ts 2.16.0 → 2.17.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/{run-serve-C78hD7t9.js → ServeApp-BSA5yzxZ.js} +17 -444
- package/dist/ServeApp-BSA5yzxZ.js.map +1 -0
- package/dist/cli.js +18 -5
- package/dist/cli.js.map +1 -1
- package/dist/exampleAssets-BfWzygoM.js +38 -0
- package/dist/exampleAssets-BfWzygoM.js.map +1 -0
- package/dist/{LogsSt-Ct7Le0S_.js → findDefinedWorkflow-0lG-VTEd.js} +201 -201
- package/dist/findDefinedWorkflow-0lG-VTEd.js.map +1 -0
- package/dist/index.cjs +146 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -8
- package/dist/index.d.ts +61 -8
- package/dist/index.js +146 -59
- package/dist/index.js.map +1 -1
- package/dist/run-run-DnaMLCFn.js +450 -0
- package/dist/run-run-DnaMLCFn.js.map +1 -0
- package/dist/run-serve-CbKxIu6i.js +418 -0
- package/dist/run-serve-CbKxIu6i.js.map +1 -0
- package/dist/{run-tui-nPETFRmk.js → run-tui-B0AQWbad.js} +6 -37
- package/dist/run-tui-B0AQWbad.js.map +1 -0
- package/dist/{schemaDrift-wb5XkrHV.js → schemaDrift-CbsABBuk.js} +3 -2
- package/dist/{schemaDrift-wb5XkrHV.js.map → schemaDrift-CbsABBuk.js.map} +1 -1
- package/dist/serve-web.js +37 -37
- package/dist/{state-BMW57_M0.js → state-C2oDiQ26.js} +146 -60
- package/dist/state-C2oDiQ26.js.map +1 -0
- package/dist/web.d.ts +61 -8
- package/dist/web.js +146 -59
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/rvion/15-tts-voice-clone.cflow.ts +8 -8
- package/examples/rvion/16-tts-voice-design.cflow.ts +71 -0
- package/guide-for-agents.md +3 -0
- package/package.json +1 -1
- package/src/cli/comfy-ts-cli.ts +14 -1
- package/src/cli/run/findModules.ts +36 -0
- package/src/cli/run/flagValue.ts +61 -0
- package/src/cli/run/outputPaths.ts +41 -0
- package/src/cli/run/pickModule.ts +41 -0
- package/src/cli/run/run-run.ts +250 -0
- package/src/cli/run/runArgs.ts +61 -0
- package/src/cli/run/sidecar.ts +27 -0
- package/src/cli/serve/ServeApp.ts +13 -39
- package/src/cli/serve/web/components/DraftTabs.tsx +8 -2
- package/src/cli/serve/web/state/draftTabs.ts +12 -0
- package/src/cli/serve/web/state/shortcutCatalog.ts +1 -0
- package/src/coreExports.ts +2 -0
- package/src/host/ComfyHost.ts +73 -40
- package/src/host/previewMethod.ts +29 -0
- package/src/runner/ComfyExecution.ts +45 -1
- package/src/runner/ComfyWorkflow.ts +6 -1
- package/src/runner/ComfyWsApi.ts +1 -1
- package/src/runner/wsBinaryFrame.ts +48 -25
- package/src/vars/ComfyVars.ts +3 -0
- package/src/vars/DefinedWorkflow.ts +1 -0
- package/dist/LogsSt-Ct7Le0S_.js.map +0 -1
- package/dist/run-serve-C78hD7t9.js.map +0 -1
- package/dist/run-tui-nPETFRmk.js.map +0 -1
- package/dist/state-BMW57_M0.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -12283,6 +12283,7 @@ type PendingBinaryFrame = {
|
|
|
12283
12283
|
type: 'binary_preview_frame';
|
|
12284
12284
|
bytes: Uint8Array;
|
|
12285
12285
|
mime: string;
|
|
12286
|
+
metadata: unknown;
|
|
12286
12287
|
};
|
|
12287
12288
|
type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
|
|
12288
12289
|
type WsMsg = typeof types$1.WsMsg.infer;
|
|
@@ -12759,6 +12760,25 @@ type ExecutionProgress = ProgressReport & {
|
|
|
12759
12760
|
* puts its partial answer here every few tokens */
|
|
12760
12761
|
progressText: string | null;
|
|
12761
12762
|
};
|
|
12763
|
+
/** one live preview frame of a run: the image a sampler is forming, once per step */
|
|
12764
|
+
type ExecutionPreview = {
|
|
12765
|
+
promptId: PromptID;
|
|
12766
|
+
/** the image as ComfyUI encoded it, jpeg or png */
|
|
12767
|
+
bytes: Uint8Array;
|
|
12768
|
+
mime: string;
|
|
12769
|
+
/** the node that sent the frame: the frame's own metadata when it names one (type 4 frames),
|
|
12770
|
+
* else the node executing when it arrived. Null when neither is known */
|
|
12771
|
+
nodeId: ComfyNodeId | null;
|
|
12772
|
+
/** that node's class name in the sent prompt (`KSampler`), null when unknown */
|
|
12773
|
+
nodeName: string | null;
|
|
12774
|
+
/** that node's own counter when the frame arrived (sampler step of total), null when unknown */
|
|
12775
|
+
step: {
|
|
12776
|
+
value: number;
|
|
12777
|
+
max: number;
|
|
12778
|
+
} | null;
|
|
12779
|
+
/** the raw metadata json of a type 4 frame (`node_id`, `prompt_id`, …), null on a type 1 frame */
|
|
12780
|
+
metadata: unknown;
|
|
12781
|
+
};
|
|
12762
12782
|
declare class ComfyExecution {
|
|
12763
12783
|
workflow: ComfyWorkflow;
|
|
12764
12784
|
data: ComfyExecutionData;
|
|
@@ -12769,6 +12789,7 @@ declare class ComfyExecution {
|
|
|
12769
12789
|
scrubHistory?: boolean;
|
|
12770
12790
|
ephemeral?: boolean;
|
|
12771
12791
|
onProgress?: Maybe<(p: ExecutionProgress) => void>;
|
|
12792
|
+
onPreview?: Maybe<(p: ExecutionPreview) => void>;
|
|
12772
12793
|
logProgress?: boolean;
|
|
12773
12794
|
});
|
|
12774
12795
|
/** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
|
|
@@ -12781,6 +12802,8 @@ declare class ComfyExecution {
|
|
|
12781
12802
|
snapshot: Maybe<ExecutionSnapshot>;
|
|
12782
12803
|
/** called on every progress-relevant websocket message */
|
|
12783
12804
|
onProgress: Maybe<(p: ExecutionProgress) => void>;
|
|
12805
|
+
/** called on every live preview frame of this run. Null = frames are never decoded for it */
|
|
12806
|
+
onPreview: Maybe<(p: ExecutionPreview) => void>;
|
|
12784
12807
|
/** render a live single-line progress report to the console */
|
|
12785
12808
|
logProgress: boolean;
|
|
12786
12809
|
readonly startedAt: number;
|
|
@@ -12834,6 +12857,13 @@ declare class ComfyExecution {
|
|
|
12834
12857
|
* SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
|
|
12835
12858
|
* live graph may still say SaveImage) — binary frames are then OUTPUTS */
|
|
12836
12859
|
get wsOutputNodeExecuting(): boolean;
|
|
12860
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
12861
|
+
* to onWsImageOutput before they get here) */
|
|
12862
|
+
onPreviewFrame(p: {
|
|
12863
|
+
bytes: Uint8Array;
|
|
12864
|
+
mime: string;
|
|
12865
|
+
metadata: unknown;
|
|
12866
|
+
}): void;
|
|
12837
12867
|
/** one binary ws frame = one output image of the executing SaveImageWebsocket
|
|
12838
12868
|
* node (architecture.md item 14 — the zero-server-disk path) */
|
|
12839
12869
|
onWsImageOutput: (p: {
|
|
@@ -12863,6 +12893,9 @@ declare class ComfyExecution {
|
|
|
12863
12893
|
private _finish;
|
|
12864
12894
|
}
|
|
12865
12895
|
//#endregion
|
|
12896
|
+
//#region src/host/previewMethod.d.ts
|
|
12897
|
+
type PreviewMethod = 'none' | 'auto' | 'latent2rgb' | 'taesd';
|
|
12898
|
+
//#endregion
|
|
12866
12899
|
//#region src/sdk-generator/comfyui-sdk-codegen.d.ts
|
|
12867
12900
|
/**
|
|
12868
12901
|
* convert a host id to the namespace name it gets inside the global `Comfy` namespace
|
|
@@ -16586,6 +16619,9 @@ type MediaVarOpts = {
|
|
|
16586
16619
|
* not what the api accepts) */
|
|
16587
16620
|
extensions?: readonly string[];
|
|
16588
16621
|
label?: string;
|
|
16622
|
+
/** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file
|
|
16623
|
+
* and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */
|
|
16624
|
+
sidecarText?: TextVar;
|
|
16589
16625
|
};
|
|
16590
16626
|
type ImageVarOpts = MediaVarOpts;
|
|
16591
16627
|
type AudioVarOpts = MediaVarOpts;
|
|
@@ -16887,6 +16923,12 @@ declare class ComfyHostAuthError extends Error {
|
|
|
16887
16923
|
hostId: string;
|
|
16888
16924
|
constructor(code: 401 | 402 | 429, hostId: string, message: string);
|
|
16889
16925
|
}
|
|
16926
|
+
type LatentPreview = {
|
|
16927
|
+
promptID: Maybe<PromptID>;
|
|
16928
|
+
receivedAt: number_Timestamp;
|
|
16929
|
+
blob: Blob;
|
|
16930
|
+
url: string;
|
|
16931
|
+
};
|
|
16890
16932
|
declare class ComfyHost<ID extends string = string> {
|
|
16891
16933
|
data: ComfyHostData & {
|
|
16892
16934
|
id: ID;
|
|
@@ -17028,6 +17070,10 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17028
17070
|
deleteHistory: (promptId: string) => Promise<void>;
|
|
17029
17071
|
/** wipe the server's WHOLE prompt history (every user of that server) */
|
|
17030
17072
|
clearHistory: () => Promise<void>;
|
|
17073
|
+
/** the `--preview-method` this host was launched with, read from `GET /system_stats`.
|
|
17074
|
+
* `'none'` (ComfyUI's default) means no live preview frame will ever arrive; null = the host
|
|
17075
|
+
* does not publish its launch flags (a cloud host), so only a run can tell */
|
|
17076
|
+
fetchPreviewMethod: () => Promise<PreviewMethod | null>;
|
|
17031
17077
|
/** the server's recent console buffer (entries are write CHUNKS, not lines) */
|
|
17032
17078
|
fetchRawLogs: () => Promise<{
|
|
17033
17079
|
entries: LogEntry[];
|
|
@@ -17056,13 +17102,12 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17056
17102
|
private activePromptID;
|
|
17057
17103
|
/** method to either execute or buffer the incoming message */
|
|
17058
17104
|
routeOrBuffer(prompt_id: PromptID, msg: PromptRelated_WsMsg): void;
|
|
17059
|
-
/** the
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
}>;
|
|
17105
|
+
/** the last raw preview frame; `latentPreview` decodes it only when read */
|
|
17106
|
+
private _latentFrame;
|
|
17107
|
+
private _latentPreview;
|
|
17108
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
17109
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
17110
|
+
get latentPreview(): Maybe<LatentPreview>;
|
|
17066
17111
|
/** byte-level latent-preview hook (e.g. TUI live preview panel) */
|
|
17067
17112
|
onLatentPreview: Maybe<(p: {
|
|
17068
17113
|
bytes: Uint8Array;
|
|
@@ -17097,6 +17142,10 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17097
17142
|
* sockets keep streaming (a half-open socket receives nothing, so this
|
|
17098
17143
|
* never revives one) */
|
|
17099
17144
|
lastWsMessageAt: number | null;
|
|
17145
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
17146
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
17147
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
17148
|
+
private onPreviewFrame;
|
|
17100
17149
|
onMessage(e: WsMessageEvent): void;
|
|
17101
17150
|
}
|
|
17102
17151
|
//#endregion
|
|
@@ -17294,6 +17343,10 @@ type RunSettings = {
|
|
|
17294
17343
|
log?: boolean;
|
|
17295
17344
|
/** called on every progress-relevant websocket message */
|
|
17296
17345
|
onProgress?: (p: ExecutionProgress) => void;
|
|
17346
|
+
/** called on every live preview frame of this run (the image a sampler is forming). Opt in:
|
|
17347
|
+
* without it no frame is decoded for the run. ComfyUI sends frames only when launched with
|
|
17348
|
+
* `--preview-method`, see `host.fetchPreviewMethod()` */
|
|
17349
|
+
onPreview?: (p: ExecutionPreview) => void;
|
|
17297
17350
|
};
|
|
17298
17351
|
/** exactly what was sent to the host for one execution, frozen at send time */
|
|
17299
17352
|
type ExecutionSnapshot = {
|
|
@@ -18047,5 +18100,5 @@ declare function promptEnhancerPresets(): VarPresetSpec;
|
|
|
18047
18100
|
//#region src/cli/tui-env.d.ts
|
|
18048
18101
|
declare function isTuiActive(): boolean;
|
|
18049
18102
|
//#endregion
|
|
18050
|
-
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptEnhancer, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
|
|
18103
|
+
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionPreview, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptEnhancer, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
|
|
18051
18104
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -12283,6 +12283,7 @@ type PendingBinaryFrame = {
|
|
|
12283
12283
|
type: 'binary_preview_frame';
|
|
12284
12284
|
bytes: Uint8Array;
|
|
12285
12285
|
mime: string;
|
|
12286
|
+
metadata: unknown;
|
|
12286
12287
|
};
|
|
12287
12288
|
type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
|
|
12288
12289
|
type WsMsg = typeof types$1.WsMsg.infer;
|
|
@@ -12759,6 +12760,25 @@ type ExecutionProgress = ProgressReport & {
|
|
|
12759
12760
|
* puts its partial answer here every few tokens */
|
|
12760
12761
|
progressText: string | null;
|
|
12761
12762
|
};
|
|
12763
|
+
/** one live preview frame of a run: the image a sampler is forming, once per step */
|
|
12764
|
+
type ExecutionPreview = {
|
|
12765
|
+
promptId: PromptID;
|
|
12766
|
+
/** the image as ComfyUI encoded it, jpeg or png */
|
|
12767
|
+
bytes: Uint8Array;
|
|
12768
|
+
mime: string;
|
|
12769
|
+
/** the node that sent the frame: the frame's own metadata when it names one (type 4 frames),
|
|
12770
|
+
* else the node executing when it arrived. Null when neither is known */
|
|
12771
|
+
nodeId: ComfyNodeId | null;
|
|
12772
|
+
/** that node's class name in the sent prompt (`KSampler`), null when unknown */
|
|
12773
|
+
nodeName: string | null;
|
|
12774
|
+
/** that node's own counter when the frame arrived (sampler step of total), null when unknown */
|
|
12775
|
+
step: {
|
|
12776
|
+
value: number;
|
|
12777
|
+
max: number;
|
|
12778
|
+
} | null;
|
|
12779
|
+
/** the raw metadata json of a type 4 frame (`node_id`, `prompt_id`, …), null on a type 1 frame */
|
|
12780
|
+
metadata: unknown;
|
|
12781
|
+
};
|
|
12762
12782
|
declare class ComfyExecution {
|
|
12763
12783
|
workflow: ComfyWorkflow;
|
|
12764
12784
|
data: ComfyExecutionData;
|
|
@@ -12769,6 +12789,7 @@ declare class ComfyExecution {
|
|
|
12769
12789
|
scrubHistory?: boolean;
|
|
12770
12790
|
ephemeral?: boolean;
|
|
12771
12791
|
onProgress?: Maybe<(p: ExecutionProgress) => void>;
|
|
12792
|
+
onPreview?: Maybe<(p: ExecutionPreview) => void>;
|
|
12772
12793
|
logProgress?: boolean;
|
|
12773
12794
|
});
|
|
12774
12795
|
/** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
|
|
@@ -12781,6 +12802,8 @@ declare class ComfyExecution {
|
|
|
12781
12802
|
snapshot: Maybe<ExecutionSnapshot>;
|
|
12782
12803
|
/** called on every progress-relevant websocket message */
|
|
12783
12804
|
onProgress: Maybe<(p: ExecutionProgress) => void>;
|
|
12805
|
+
/** called on every live preview frame of this run. Null = frames are never decoded for it */
|
|
12806
|
+
onPreview: Maybe<(p: ExecutionPreview) => void>;
|
|
12784
12807
|
/** render a live single-line progress report to the console */
|
|
12785
12808
|
logProgress: boolean;
|
|
12786
12809
|
readonly startedAt: number;
|
|
@@ -12834,6 +12857,13 @@ declare class ComfyExecution {
|
|
|
12834
12857
|
* SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
|
|
12835
12858
|
* live graph may still say SaveImage) — binary frames are then OUTPUTS */
|
|
12836
12859
|
get wsOutputNodeExecuting(): boolean;
|
|
12860
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
12861
|
+
* to onWsImageOutput before they get here) */
|
|
12862
|
+
onPreviewFrame(p: {
|
|
12863
|
+
bytes: Uint8Array;
|
|
12864
|
+
mime: string;
|
|
12865
|
+
metadata: unknown;
|
|
12866
|
+
}): void;
|
|
12837
12867
|
/** one binary ws frame = one output image of the executing SaveImageWebsocket
|
|
12838
12868
|
* node (architecture.md item 14 — the zero-server-disk path) */
|
|
12839
12869
|
onWsImageOutput: (p: {
|
|
@@ -12863,6 +12893,9 @@ declare class ComfyExecution {
|
|
|
12863
12893
|
private _finish;
|
|
12864
12894
|
}
|
|
12865
12895
|
//#endregion
|
|
12896
|
+
//#region src/host/previewMethod.d.ts
|
|
12897
|
+
type PreviewMethod = 'none' | 'auto' | 'latent2rgb' | 'taesd';
|
|
12898
|
+
//#endregion
|
|
12866
12899
|
//#region src/sdk-generator/comfyui-sdk-codegen.d.ts
|
|
12867
12900
|
/**
|
|
12868
12901
|
* convert a host id to the namespace name it gets inside the global `Comfy` namespace
|
|
@@ -16586,6 +16619,9 @@ type MediaVarOpts = {
|
|
|
16586
16619
|
* not what the api accepts) */
|
|
16587
16620
|
extensions?: readonly string[];
|
|
16588
16621
|
label?: string;
|
|
16622
|
+
/** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file
|
|
16623
|
+
* and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */
|
|
16624
|
+
sidecarText?: TextVar;
|
|
16589
16625
|
};
|
|
16590
16626
|
type ImageVarOpts = MediaVarOpts;
|
|
16591
16627
|
type AudioVarOpts = MediaVarOpts;
|
|
@@ -16887,6 +16923,12 @@ declare class ComfyHostAuthError extends Error {
|
|
|
16887
16923
|
hostId: string;
|
|
16888
16924
|
constructor(code: 401 | 402 | 429, hostId: string, message: string);
|
|
16889
16925
|
}
|
|
16926
|
+
type LatentPreview = {
|
|
16927
|
+
promptID: Maybe<PromptID>;
|
|
16928
|
+
receivedAt: number_Timestamp;
|
|
16929
|
+
blob: Blob;
|
|
16930
|
+
url: string;
|
|
16931
|
+
};
|
|
16890
16932
|
declare class ComfyHost<ID extends string = string> {
|
|
16891
16933
|
data: ComfyHostData & {
|
|
16892
16934
|
id: ID;
|
|
@@ -17028,6 +17070,10 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17028
17070
|
deleteHistory: (promptId: string) => Promise<void>;
|
|
17029
17071
|
/** wipe the server's WHOLE prompt history (every user of that server) */
|
|
17030
17072
|
clearHistory: () => Promise<void>;
|
|
17073
|
+
/** the `--preview-method` this host was launched with, read from `GET /system_stats`.
|
|
17074
|
+
* `'none'` (ComfyUI's default) means no live preview frame will ever arrive; null = the host
|
|
17075
|
+
* does not publish its launch flags (a cloud host), so only a run can tell */
|
|
17076
|
+
fetchPreviewMethod: () => Promise<PreviewMethod | null>;
|
|
17031
17077
|
/** the server's recent console buffer (entries are write CHUNKS, not lines) */
|
|
17032
17078
|
fetchRawLogs: () => Promise<{
|
|
17033
17079
|
entries: LogEntry[];
|
|
@@ -17056,13 +17102,12 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17056
17102
|
private activePromptID;
|
|
17057
17103
|
/** method to either execute or buffer the incoming message */
|
|
17058
17104
|
routeOrBuffer(prompt_id: PromptID, msg: PromptRelated_WsMsg): void;
|
|
17059
|
-
/** the
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
}>;
|
|
17105
|
+
/** the last raw preview frame; `latentPreview` decodes it only when read */
|
|
17106
|
+
private _latentFrame;
|
|
17107
|
+
private _latentPreview;
|
|
17108
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
17109
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
17110
|
+
get latentPreview(): Maybe<LatentPreview>;
|
|
17066
17111
|
/** byte-level latent-preview hook (e.g. TUI live preview panel) */
|
|
17067
17112
|
onLatentPreview: Maybe<(p: {
|
|
17068
17113
|
bytes: Uint8Array;
|
|
@@ -17097,6 +17142,10 @@ declare class ComfyHost<ID extends string = string> {
|
|
|
17097
17142
|
* sockets keep streaming (a half-open socket receives nothing, so this
|
|
17098
17143
|
* never revives one) */
|
|
17099
17144
|
lastWsMessageAt: number | null;
|
|
17145
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
17146
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
17147
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
17148
|
+
private onPreviewFrame;
|
|
17100
17149
|
onMessage(e: WsMessageEvent): void;
|
|
17101
17150
|
}
|
|
17102
17151
|
//#endregion
|
|
@@ -17294,6 +17343,10 @@ type RunSettings = {
|
|
|
17294
17343
|
log?: boolean;
|
|
17295
17344
|
/** called on every progress-relevant websocket message */
|
|
17296
17345
|
onProgress?: (p: ExecutionProgress) => void;
|
|
17346
|
+
/** called on every live preview frame of this run (the image a sampler is forming). Opt in:
|
|
17347
|
+
* without it no frame is decoded for the run. ComfyUI sends frames only when launched with
|
|
17348
|
+
* `--preview-method`, see `host.fetchPreviewMethod()` */
|
|
17349
|
+
onPreview?: (p: ExecutionPreview) => void;
|
|
17297
17350
|
};
|
|
17298
17351
|
/** exactly what was sent to the host for one execution, frozen at send time */
|
|
17299
17352
|
type ExecutionSnapshot = {
|
|
@@ -18047,5 +18100,5 @@ declare function promptEnhancerPresets(): VarPresetSpec;
|
|
|
18047
18100
|
//#region src/cli/tui-env.d.ts
|
|
18048
18101
|
declare function isTuiActive(): boolean;
|
|
18049
18102
|
//#endregion
|
|
18050
|
-
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptEnhancer, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
|
|
18103
|
+
export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionPreview, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptEnhancer, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
|
|
18051
18104
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -110,7 +110,7 @@ function createNodeStorage() {
|
|
|
110
110
|
}
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region package.json
|
|
113
|
-
var version = "2.
|
|
113
|
+
var version = "2.17.0";
|
|
114
114
|
//#endregion
|
|
115
115
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
116
116
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -660,21 +660,41 @@ const normalizeGroup = (g) => {
|
|
|
660
660
|
};
|
|
661
661
|
};
|
|
662
662
|
//#endregion
|
|
663
|
-
//#region src/
|
|
664
|
-
function
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
663
|
+
//#region src/host/previewMethod.ts
|
|
664
|
+
function isPreviewMethod(x) {
|
|
665
|
+
return x === "none" || x === "auto" || x === "latent2rgb" || x === "taesd";
|
|
666
|
+
}
|
|
667
|
+
/** the preview method a host was launched with, from its /system_stats payload. `'none'` when
|
|
668
|
+
* the flag is absent (ComfyUI's default), null when the payload carries no argv to read (a cloud
|
|
669
|
+
* host) or the flag holds a value this parser does not know */
|
|
670
|
+
function previewMethodFromSystemStats(stats) {
|
|
671
|
+
if (stats == null || typeof stats !== "object" || !("system" in stats)) return null;
|
|
672
|
+
const system = stats.system;
|
|
673
|
+
if (system == null || typeof system !== "object" || !("argv" in system)) return null;
|
|
674
|
+
const argv = system.argv;
|
|
675
|
+
if (!Array.isArray(argv)) return null;
|
|
676
|
+
for (let i = 0; i < argv.length; i++) {
|
|
677
|
+
const arg = argv[i];
|
|
678
|
+
if (typeof arg !== "string") continue;
|
|
679
|
+
const value = arg === "--preview-method" ? argv[i + 1] : arg.startsWith("--preview-method=") ? arg.slice(17) : void 0;
|
|
680
|
+
if (value === void 0) continue;
|
|
681
|
+
return isPreviewMethod(value) ? value : null;
|
|
675
682
|
}
|
|
683
|
+
return "none";
|
|
684
|
+
}
|
|
685
|
+
/** the frame's event type, read in place: deciding whether anyone wants a frame costs no copy */
|
|
686
|
+
function binaryFrameType(data) {
|
|
687
|
+
if (data.byteLength < 4) return -1;
|
|
688
|
+
return new DataView(data).getUint32(0);
|
|
689
|
+
}
|
|
690
|
+
function isPreviewFrameType(eventType) {
|
|
691
|
+
return eventType === 1 || eventType === 4;
|
|
692
|
+
}
|
|
693
|
+
function parseBinaryWsFrame(data) {
|
|
694
|
+
const eventType = binaryFrameType(data);
|
|
695
|
+
if (isPreviewFrameType(eventType)) return parsePreviewFrame(data);
|
|
676
696
|
if (eventType === 3) {
|
|
677
|
-
const nodeIdLen =
|
|
697
|
+
const nodeIdLen = new DataView(data).getUint32(4);
|
|
678
698
|
const decoder = new TextDecoder();
|
|
679
699
|
return {
|
|
680
700
|
kind: "text",
|
|
@@ -682,25 +702,41 @@ function parseBinaryWsFrame(data) {
|
|
|
682
702
|
text: decoder.decode(data.slice(8 + nodeIdLen))
|
|
683
703
|
};
|
|
684
704
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
705
|
+
return {
|
|
706
|
+
kind: "unknown",
|
|
707
|
+
eventType
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
/** a type 1 or type 4 frame; the caller checked the type with `isPreviewFrameType` */
|
|
711
|
+
function parsePreviewFrame(data) {
|
|
712
|
+
const view = new DataView(data);
|
|
713
|
+
if (view.getUint32(0) === 1) {
|
|
714
|
+
const imageType = view.getUint32(4);
|
|
692
715
|
return {
|
|
693
716
|
kind: "preview",
|
|
694
|
-
bytes,
|
|
695
|
-
mime:
|
|
696
|
-
metadata
|
|
717
|
+
bytes: new Uint8Array(data.slice(8)),
|
|
718
|
+
mime: imageType === 2 ? "image/png" : "image/jpeg",
|
|
719
|
+
metadata: null
|
|
697
720
|
};
|
|
698
721
|
}
|
|
722
|
+
const metadataLen = view.getUint32(4);
|
|
723
|
+
let metadata = null;
|
|
724
|
+
try {
|
|
725
|
+
metadata = JSON.parse(new TextDecoder().decode(data.slice(8, 8 + metadataLen)));
|
|
726
|
+
} catch {}
|
|
727
|
+
const bytes = new Uint8Array(data.slice(8 + metadataLen));
|
|
699
728
|
return {
|
|
700
|
-
kind: "
|
|
701
|
-
|
|
729
|
+
kind: "preview",
|
|
730
|
+
bytes,
|
|
731
|
+
mime: bytes[0] === 137 && bytes[1] === 80 ? "image/png" : "image/jpeg",
|
|
732
|
+
metadata
|
|
702
733
|
};
|
|
703
734
|
}
|
|
735
|
+
/** the node a type 4 frame names (`node_id` in its metadata), null when absent or malformed */
|
|
736
|
+
function previewMetadataNodeId(metadata) {
|
|
737
|
+
if (metadata == null || typeof metadata !== "object" || !("node_id" in metadata)) return null;
|
|
738
|
+
return typeof metadata.node_id === "string" && metadata.node_id !== "" ? metadata.node_id : null;
|
|
739
|
+
}
|
|
704
740
|
//#endregion
|
|
705
741
|
//#region src/sdk-generator/Primitives.ts
|
|
706
742
|
const ComfyPrimitiveMapping = {
|
|
@@ -2350,6 +2386,7 @@ var ComfyExecution = class {
|
|
|
2350
2386
|
this.ephemeral = false;
|
|
2351
2387
|
this.snapshot = null;
|
|
2352
2388
|
this.onProgress = null;
|
|
2389
|
+
this.onPreview = null;
|
|
2353
2390
|
this.logProgress = false;
|
|
2354
2391
|
this.startedAt = Date.now();
|
|
2355
2392
|
this._lastLoggedLine = "";
|
|
@@ -2363,6 +2400,7 @@ var ComfyExecution = class {
|
|
|
2363
2400
|
bytes: msg.bytes,
|
|
2364
2401
|
mime: msg.mime
|
|
2365
2402
|
});
|
|
2403
|
+
else this.onPreviewFrame(msg);
|
|
2366
2404
|
return;
|
|
2367
2405
|
}
|
|
2368
2406
|
if (msg.type === "execution_start") return;
|
|
@@ -2609,6 +2647,7 @@ var ComfyExecution = class {
|
|
|
2609
2647
|
this.scrubHistory = init.scrubHistory ?? false;
|
|
2610
2648
|
this.ephemeral = init.ephemeral ?? false;
|
|
2611
2649
|
this.onProgress = init.onProgress ?? null;
|
|
2650
|
+
this.onPreview = init.onPreview ?? null;
|
|
2612
2651
|
this.logProgress = init.logProgress ?? false;
|
|
2613
2652
|
this.host.executions.set(data.id, this);
|
|
2614
2653
|
this.onCreate();
|
|
@@ -2689,6 +2728,28 @@ var ComfyExecution = class {
|
|
|
2689
2728
|
if (uid == null) return false;
|
|
2690
2729
|
return (this.snapshot?.apiJson ?? this.workflow.apiJson)[uid]?.class_type === "SaveImageWebsocket";
|
|
2691
2730
|
}
|
|
2731
|
+
/** @internal a live preview frame of this run; never an output (the host routes ws saver frames
|
|
2732
|
+
* to onWsImageOutput before they get here) */
|
|
2733
|
+
onPreviewFrame(p) {
|
|
2734
|
+
const listener = this.onPreview;
|
|
2735
|
+
if (listener == null) return;
|
|
2736
|
+
const current = this.workflow.currentExecutingNode;
|
|
2737
|
+
const nodeId = previewMetadataNodeId(p.metadata) ?? current?.uid ?? null;
|
|
2738
|
+
const apiJson = this.snapshot?.apiJson ?? this.workflow.apiJson;
|
|
2739
|
+
const counter = current != null && current.uid === nodeId ? current.progress : null;
|
|
2740
|
+
listener({
|
|
2741
|
+
promptId: this.data.id,
|
|
2742
|
+
bytes: p.bytes,
|
|
2743
|
+
mime: p.mime,
|
|
2744
|
+
nodeId,
|
|
2745
|
+
nodeName: nodeId != null ? apiJson[nodeId]?.class_type ?? null : null,
|
|
2746
|
+
step: counter != null ? {
|
|
2747
|
+
value: counter.value,
|
|
2748
|
+
max: counter.max
|
|
2749
|
+
} : null,
|
|
2750
|
+
metadata: p.metadata
|
|
2751
|
+
});
|
|
2752
|
+
}
|
|
2692
2753
|
/** @internal a live-text frame for one node */
|
|
2693
2754
|
onProgressText(p) {
|
|
2694
2755
|
this.progressTexts.set(p.nodeId, p.text);
|
|
@@ -3028,6 +3089,7 @@ var ComfyWorkflow = class {
|
|
|
3028
3089
|
ephemeral: p.ephemeral ?? false,
|
|
3029
3090
|
scrubHistory: p.scrubHistory ?? p.ephemeral ?? false,
|
|
3030
3091
|
onProgress: p.onProgress,
|
|
3092
|
+
onPreview: p.onPreview,
|
|
3031
3093
|
logProgress: p.log ?? false
|
|
3032
3094
|
});
|
|
3033
3095
|
};
|
|
@@ -5699,7 +5761,8 @@ var DefinedWorkflow = class {
|
|
|
5699
5761
|
scrubHistory: settings.scrubHistory,
|
|
5700
5762
|
idMode: settings.idMode,
|
|
5701
5763
|
log: settings.log,
|
|
5702
|
-
onProgress: settings.onProgress
|
|
5764
|
+
onProgress: settings.onProgress,
|
|
5765
|
+
onPreview: settings.onPreview
|
|
5703
5766
|
});
|
|
5704
5767
|
this.lastExecution = execution;
|
|
5705
5768
|
return execution;
|
|
@@ -6004,6 +6067,11 @@ var ComfyHost = class {
|
|
|
6004
6067
|
this.clearHistory = () => {
|
|
6005
6068
|
return this.postJSON_("/history", { clear: true });
|
|
6006
6069
|
};
|
|
6070
|
+
this.fetchPreviewMethod = async () => {
|
|
6071
|
+
const res = await this.fetch("/system_stats", {});
|
|
6072
|
+
if (!res.ok) throw new Error(`GET /system_stats failed: ${res.status}`);
|
|
6073
|
+
return previewMethodFromSystemStats(await res.json());
|
|
6074
|
+
};
|
|
6007
6075
|
this.fetchRawLogs = async () => {
|
|
6008
6076
|
const res = await this.fetch("/internal/logs/raw", {}, { apiPrefix: false });
|
|
6009
6077
|
if (!res.ok) throw new Error(`GET /internal/logs/raw failed: ${res.status}`);
|
|
@@ -6080,7 +6148,8 @@ var ComfyHost = class {
|
|
|
6080
6148
|
this.executions = /* @__PURE__ */ new Map();
|
|
6081
6149
|
this._pendingMsgs = /* @__PURE__ */ new Map();
|
|
6082
6150
|
this.activePromptID = null;
|
|
6083
|
-
this.
|
|
6151
|
+
this._latentFrame = null;
|
|
6152
|
+
this._latentPreview = null;
|
|
6084
6153
|
this.onLatentPreview = null;
|
|
6085
6154
|
this.onProgressText = null;
|
|
6086
6155
|
this.onStatus = null;
|
|
@@ -6257,42 +6326,60 @@ var ComfyHost = class {
|
|
|
6257
6326
|
}
|
|
6258
6327
|
prompt.onPromptRelatedMessage(msg);
|
|
6259
6328
|
}
|
|
6329
|
+
/** the latent image beeing generated, in case you want to display it. Built on read: a
|
|
6330
|
+
* session that never reads it never decodes a frame nor holds an object url */
|
|
6331
|
+
get latentPreview() {
|
|
6332
|
+
if (this._latentPreview != null || this._latentFrame == null) return this._latentPreview;
|
|
6333
|
+
const frame = parsePreviewFrame(this._latentFrame.data);
|
|
6334
|
+
const blob = new Blob([frame.bytes], { type: frame.mime });
|
|
6335
|
+
this._latentPreview = {
|
|
6336
|
+
blob,
|
|
6337
|
+
url: URL.createObjectURL(blob),
|
|
6338
|
+
receivedAt: this._latentFrame.receivedAt,
|
|
6339
|
+
promptID: this._latentFrame.promptID
|
|
6340
|
+
};
|
|
6341
|
+
return this._latentPreview;
|
|
6342
|
+
}
|
|
6343
|
+
/** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
|
|
6344
|
+
* Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
|
|
6345
|
+
* the host hook. Nobody listening = the frame is kept by reference and never copied */
|
|
6346
|
+
onPreviewFrame(data) {
|
|
6347
|
+
let parsed = null;
|
|
6348
|
+
const frame = () => parsed ??= parsePreviewFrame(data);
|
|
6349
|
+
const promptID = this.activePromptID;
|
|
6350
|
+
const activeExec = promptID != null ? this.executions.get(promptID) : null;
|
|
6351
|
+
if (activeExec?.wsOutputNodeExecuting) return activeExec.onWsImageOutput({
|
|
6352
|
+
bytes: frame().bytes,
|
|
6353
|
+
mime: frame().mime
|
|
6354
|
+
});
|
|
6355
|
+
const pending = promptID != null ? this._pendingMsgs.get(promptID) : void 0;
|
|
6356
|
+
if (pending != null) pending.push({
|
|
6357
|
+
type: "binary_preview_frame",
|
|
6358
|
+
bytes: frame().bytes,
|
|
6359
|
+
mime: frame().mime,
|
|
6360
|
+
metadata: frame().metadata
|
|
6361
|
+
});
|
|
6362
|
+
if (this._latentPreview != null) URL.revokeObjectURL(this._latentPreview.url);
|
|
6363
|
+
this._latentPreview = null;
|
|
6364
|
+
this._latentFrame = {
|
|
6365
|
+
data,
|
|
6366
|
+
promptID,
|
|
6367
|
+
receivedAt: Date.now()
|
|
6368
|
+
};
|
|
6369
|
+
if (activeExec?.onPreview != null) activeExec.onPreviewFrame(frame());
|
|
6370
|
+
if (this.onLatentPreview != null) this.onLatentPreview({
|
|
6371
|
+
bytes: frame().bytes,
|
|
6372
|
+
mime: frame().mime,
|
|
6373
|
+
promptID
|
|
6374
|
+
});
|
|
6375
|
+
}
|
|
6260
6376
|
onMessage(e) {
|
|
6261
6377
|
this.lastWsMessageAt = Date.now();
|
|
6262
6378
|
if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
|
|
6263
6379
|
if (e.data instanceof ArrayBuffer) {
|
|
6380
|
+
if (isPreviewFrameType(binaryFrameType(e.data))) return this.onPreviewFrame(e.data);
|
|
6264
6381
|
const frame = parseBinaryWsFrame(e.data);
|
|
6265
|
-
if (frame.kind === "
|
|
6266
|
-
const activeExec = this.activePromptID != null ? this.executions.get(this.activePromptID) : null;
|
|
6267
|
-
if (activeExec?.wsOutputNodeExecuting) {
|
|
6268
|
-
activeExec.onWsImageOutput({
|
|
6269
|
-
bytes: frame.bytes,
|
|
6270
|
-
mime: frame.mime
|
|
6271
|
-
});
|
|
6272
|
-
return;
|
|
6273
|
-
}
|
|
6274
|
-
if (this.activePromptID != null) {
|
|
6275
|
-
const pending = this._pendingMsgs.get(this.activePromptID);
|
|
6276
|
-
if (pending != null) pending.push({
|
|
6277
|
-
type: "binary_preview_frame",
|
|
6278
|
-
bytes: frame.bytes,
|
|
6279
|
-
mime: frame.mime
|
|
6280
|
-
});
|
|
6281
|
-
}
|
|
6282
|
-
if (this.latentPreview != null) URL.revokeObjectURL(this.latentPreview.url);
|
|
6283
|
-
const imageBlob = new Blob([frame.bytes], { type: frame.mime });
|
|
6284
|
-
this.latentPreview = {
|
|
6285
|
-
blob: imageBlob,
|
|
6286
|
-
url: URL.createObjectURL(imageBlob),
|
|
6287
|
-
receivedAt: Date.now(),
|
|
6288
|
-
promptID: this.activePromptID
|
|
6289
|
-
};
|
|
6290
|
-
this.onLatentPreview?.({
|
|
6291
|
-
bytes: frame.bytes,
|
|
6292
|
-
mime: frame.mime,
|
|
6293
|
-
promptID: this.activePromptID
|
|
6294
|
-
});
|
|
6295
|
-
} else if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
6382
|
+
if (frame.kind === "unknown" && !this._unknownBinaryFrameTypes.has(frame.eventType)) {
|
|
6296
6383
|
this._unknownBinaryFrameTypes.add(frame.eventType);
|
|
6297
6384
|
console.error(`🔴 unknown binary ws frame type ${frame.eventType} from host ${this.data.id} — ignored`);
|
|
6298
6385
|
}
|