comfy-ts 2.23.0 → 2.24.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.
Files changed (76) hide show
  1. package/dist/{ServeApp-DolRCMHj.js → ServeApp-fsHtW5zG.js} +3 -3
  2. package/dist/{ServeApp-DolRCMHj.js.map → ServeApp-fsHtW5zG.js.map} +1 -1
  3. package/dist/cli.js +5 -5
  4. package/dist/{exampleAssets-Duneoq6r.js → exampleAssets-DZynSkZm.js} +79 -15
  5. package/dist/exampleAssets-DZynSkZm.js.map +1 -0
  6. package/dist/{findDefinedWorkflow-DjoJA8y7.js → findDefinedWorkflow-qyqFea7q.js} +2 -2
  7. package/dist/{findDefinedWorkflow-DjoJA8y7.js.map → findDefinedWorkflow-qyqFea7q.js.map} +1 -1
  8. package/dist/index.cjs +80 -14
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +53 -19
  11. package/dist/index.d.ts +53 -19
  12. package/dist/index.js +80 -15
  13. package/dist/index.js.map +1 -1
  14. package/dist/{run-run-Cr0L9lCK.js → run-run-Cn2JzKlE.js} +5 -5
  15. package/dist/{run-run-Cr0L9lCK.js.map → run-run-Cn2JzKlE.js.map} +1 -1
  16. package/dist/{run-serve---qA7o_m.js → run-serve-BhGegaCI.js} +4 -4
  17. package/dist/{run-serve---qA7o_m.js.map → run-serve-BhGegaCI.js.map} +1 -1
  18. package/dist/{run-tui-DxXiWo5J.js → run-tui-CrM4ijkH.js} +4 -4
  19. package/dist/{run-tui-DxXiWo5J.js.map → run-tui-CrM4ijkH.js.map} +1 -1
  20. package/dist/{schemaDrift-BTxdABHi.js → schemaDrift-BGYJZGMD.js} +3 -2
  21. package/dist/{schemaDrift-BTxdABHi.js.map → schemaDrift-BGYJZGMD.js.map} +1 -1
  22. package/dist/web.d.ts +53 -19
  23. package/dist/web.js +80 -15
  24. package/dist/web.js.map +1 -1
  25. package/examples/README.md +1 -0
  26. package/examples/depth-explorer/models.ts +6 -56
  27. package/examples/depth-explorer/serve.ts +12 -133
  28. package/examples/depth-explorer/web/App.tsx +20 -91
  29. package/examples/depth-explorer/web/index.html +1 -0
  30. package/examples/depth-explorer/web/state.ts +26 -109
  31. package/examples/depth-explorer/web/styles.css +1 -286
  32. package/examples/explorer-kit/catalog.ts +80 -0
  33. package/examples/explorer-kit/server.ts +167 -0
  34. package/examples/explorer-kit/web/base.css +289 -0
  35. package/examples/explorer-kit/web/runs.ts +160 -0
  36. package/examples/explorer-kit/web/ui.tsx +125 -0
  37. package/examples/rvion/17-relight.cflow.ts +2 -1
  38. package/examples/rvion/19-flythrough.cflow.ts +312 -0
  39. package/examples/rvion/20-grow-splat.cflow.ts +88 -0
  40. package/examples/rvion/21-photo-to-model.cflow.ts +191 -0
  41. package/examples/rvion/flythroughChain.ts +171 -0
  42. package/examples/rvion/flythroughColmap.ts +157 -0
  43. package/examples/rvion/flythroughFuse.ts +199 -0
  44. package/examples/rvion/flythroughGuide.ts +300 -0
  45. package/examples/rvion/flythroughPalette.ts +310 -0
  46. package/examples/rvion/flythroughPath.ts +177 -0
  47. package/examples/rvion/flythroughSplat.ts +73 -0
  48. package/examples/rvion/grow-splat/align.ts +114 -0
  49. package/examples/rvion/grow-splat/grow.ts +198 -0
  50. package/examples/rvion/grow-splat/ply.ts +166 -0
  51. package/examples/rvion/grow-splat/raster.ts +207 -0
  52. package/examples/rvion/grow-splat/sharp.ts +45 -0
  53. package/examples/rvion/splatDataset.ts +80 -0
  54. package/examples/rvion/splatEval.ts +380 -0
  55. package/examples/upscale-explorer/models.ts +341 -0
  56. package/examples/upscale-explorer/serve.ts +19 -0
  57. package/examples/upscale-explorer/web/App.tsx +250 -0
  58. package/examples/upscale-explorer/web/compare.tsx +285 -0
  59. package/examples/upscale-explorer/web/index.html +15 -0
  60. package/examples/upscale-explorer/web/main.tsx +12 -0
  61. package/examples/upscale-explorer/web/state.ts +279 -0
  62. package/examples/upscale-explorer/web/styles.css +241 -0
  63. package/examples/upscale-explorer/web/tsconfig.json +16 -0
  64. package/examples/upscale-explorer/web/viewport.tsx +130 -0
  65. package/examples/world-explorer/web/main.tsx +2 -2
  66. package/package.json +4 -3
  67. package/src/coreExports.ts +5 -0
  68. package/src/host/ComfyHost.ts +6 -0
  69. package/src/runner/ComfyExecution.ts +22 -5
  70. package/src/runner/ComfyWorkflow.ts +22 -0
  71. package/src/runner/ComfyWsApi.ts +1 -1
  72. package/src/runner/comfyOrgApiKey.ts +44 -0
  73. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +2 -0
  74. package/src/state.ts +2 -0
  75. package/src/vars/DefinedWorkflow.ts +1 -0
  76. package/dist/exampleAssets-Duneoq6r.js.map +0 -1
package/dist/web.d.ts CHANGED
@@ -12234,6 +12234,7 @@ declare const types$1: import("arktype").Module<{
12234
12234
  client_id: string;
12235
12235
  extra_data: {
12236
12236
  extra_pnginfo: unknown;
12237
+ api_key_comfy_org?: string | undefined;
12237
12238
  };
12238
12239
  prompt: unknown;
12239
12240
  };
@@ -12262,16 +12263,9 @@ declare const types$1: import("arktype").Module<{
12262
12263
  };
12263
12264
  PromptID: PromptID;
12264
12265
  PromptRelated_WsMsg: {
12265
- type: "progress";
12266
- data: {
12267
- value: number;
12268
- max: number;
12269
- };
12270
- } | {
12271
- type: "executing";
12266
+ type: "execution_start";
12272
12267
  data: {
12273
12268
  prompt_id: PromptID;
12274
- node?: ComfyNodeId | null | undefined;
12275
12269
  };
12276
12270
  } | {
12277
12271
  type: "execution_cached";
@@ -12280,9 +12274,16 @@ declare const types$1: import("arktype").Module<{
12280
12274
  prompt_id: PromptID;
12281
12275
  };
12282
12276
  } | {
12283
- type: "execution_start";
12277
+ type: "executing";
12284
12278
  data: {
12285
12279
  prompt_id: PromptID;
12280
+ node?: ComfyNodeId | null | undefined;
12281
+ };
12282
+ } | {
12283
+ type: "progress";
12284
+ data: {
12285
+ value: number;
12286
+ max: number;
12286
12287
  };
12287
12288
  } | {
12288
12289
  type: "progress_state";
@@ -12366,16 +12367,9 @@ declare const types$1: import("arktype").Module<{
12366
12367
  data: string;
12367
12368
  };
12368
12369
  WsMsg: {
12369
- type: "progress";
12370
- data: {
12371
- value: number;
12372
- max: number;
12373
- };
12374
- } | {
12375
- type: "executing";
12370
+ type: "execution_start";
12376
12371
  data: {
12377
12372
  prompt_id: PromptID;
12378
- node?: ComfyNodeId | null | undefined;
12379
12373
  };
12380
12374
  } | {
12381
12375
  type: "execution_cached";
@@ -12384,9 +12378,16 @@ declare const types$1: import("arktype").Module<{
12384
12378
  prompt_id: PromptID;
12385
12379
  };
12386
12380
  } | {
12387
- type: "execution_start";
12381
+ type: "executing";
12388
12382
  data: {
12389
12383
  prompt_id: PromptID;
12384
+ node?: ComfyNodeId | null | undefined;
12385
+ };
12386
+ } | {
12387
+ type: "progress";
12388
+ data: {
12389
+ value: number;
12390
+ max: number;
12390
12391
  };
12391
12392
  } | {
12392
12393
  type: "progress_state";
@@ -12995,6 +12996,7 @@ declare const types: import("arktype").Module<{
12995
12996
  output_tooltips?: (string | null)[] | undefined;
12996
12997
  deprecated?: boolean | undefined;
12997
12998
  experimental?: boolean | undefined;
12999
+ api_node?: boolean | undefined;
12998
13000
  };
12999
13001
  ComfySchemaJSON: {
13000
13002
  [x: string]: {
@@ -13103,6 +13105,7 @@ declare const types: import("arktype").Module<{
13103
13105
  output_tooltips?: (string | null)[] | undefined;
13104
13106
  deprecated?: boolean | undefined;
13105
13107
  experimental?: boolean | undefined;
13108
+ api_node?: boolean | undefined;
13106
13109
  };
13107
13110
  };
13108
13111
  }>;
@@ -13285,6 +13288,8 @@ type ComfyAudioOutput = {
13285
13288
  mime: string;
13286
13289
  bytes: Uint8Array;
13287
13290
  absPath: AbsolutePath | null;
13291
+ /** the `tag` / `tags` of the output node's metadata, as on images */
13292
+ tags: string[];
13288
13293
  };
13289
13294
  /** one video file an output node published (SaveVideo, SaveWEBM, VHS_VideoCombine), same
13290
13295
  * shape and same retrieval as an audio file */
@@ -13446,6 +13451,10 @@ declare class ComfyExecution {
13446
13451
  private encodeAndWrite;
13447
13452
  /** accumulate an output on the prompt; tags from node metadata ride along */
13448
13453
  private pushImage;
13454
+ /** the tags an output node was built with (`{ tag }` / `{ tags }` metadata) */
13455
+ private tagsOf;
13456
+ /** the sent graph saves through SaveImageWebsocket: those outputs exist only as ws frames */
13457
+ private get sendsWsFrames();
13449
13458
  /** true while the currently executing node is a SaveImageWebsocket in the
13450
13459
  * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
13451
13460
  * live graph may still say SaveImage) — binary frames are then OUTPUTS */
@@ -17759,6 +17768,23 @@ type SchemaDrift = {
17759
17768
  } & Delta)[];
17760
17769
  };
17761
17770
  //#endregion
17771
+ //#region src/runner/comfyOrgApiKey.d.ts
17772
+ /** a Comfy account key, or a thunk read only when a run with a partner node starts */
17773
+ type ComfyOrgApiKeySource = string | (() => string | undefined | Promise<string | undefined>);
17774
+ /** a partner API node of a prompt: what the error names */
17775
+ type PartnerApiNode = {
17776
+ id: string;
17777
+ classType: string;
17778
+ };
17779
+ /** the prompt holds a paid partner node and no Comfy account key was set */
17780
+ declare class ComfyOrgApiKeyMissingError extends Error {
17781
+ hostId: string;
17782
+ nodes: PartnerApiNode[];
17783
+ /** name, not instanceof: the cli bundle and dist/index.js each define this class */
17784
+ readonly name = "ComfyOrgApiKeyMissingError";
17785
+ constructor(hostId: string, nodes: PartnerApiNode[]);
17786
+ }
17787
+ //#endregion
17762
17788
  //#region src/host/ComfyHost.d.ts
17763
17789
  type ComfyHostID = Tagged<string, {
17764
17790
  HostID: true;
@@ -17775,6 +17801,11 @@ type ComfyHostData = {
17775
17801
  /** sent as X-API-Key on every request AND the ws upgrade.
17776
17802
  * NEVER persist the value: read it from an env var (e.g. COMFY_CLOUD_API_KEY) */
17777
17803
  apiKey?: string;
17804
+ /** the Comfy account key (platform.comfy.org) that paid partner API nodes bill to, sent as
17805
+ * `extra_data.api_key_comfy_org` with a prompt that holds one. A thunk is read only when such
17806
+ * a run starts. `RunSettings.comfyOrgApiKey` overrides it for one run; a cloud.comfy.org host
17807
+ * falls back to its apiKey. NEVER persist the value (architecture.md, Partner API nodes) */
17808
+ comfyOrgApiKey?: ComfyOrgApiKeySource;
17778
17809
  /** default true. false = never write sdk.d.ts to .comfy-ts/hosts/<id>/ —
17779
17810
  * schema updates stay in-memory. The comfy-cloud example sets false: its sdk
17780
17811
  * home is the COMMITTED examples/comfy-cloud/sdk.d.ts (gen:sdk:cloud), and a
@@ -18311,6 +18342,9 @@ type RunSettings = {
18311
18342
  * without it no frame is decoded for the run. ComfyUI sends frames only when launched with
18312
18343
  * `--preview-method`, see `host.fetchPreviewMethod()` */
18313
18344
  onPreview?: (p: ExecutionPreview) => void;
18345
+ /** the Comfy account key for this run's paid partner API nodes; overrides the host's
18346
+ * `comfyOrgApiKey`. Sent only when the prompt holds one, never saved */
18347
+ comfyOrgApiKey?: ComfyOrgApiKeySource;
18314
18348
  };
18315
18349
  /** exactly what was sent to the host for one execution, frozen at send time */
18316
18350
  type ExecutionSnapshot = {
@@ -19122,5 +19156,5 @@ type HostToPanel = {
19122
19156
  comfyTs: 'get-state';
19123
19157
  };
19124
19158
  //#endregion
19125
- 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 ChoiceOptionLook, type ChoiceSelect, ChoiceVar, type CodegenOptions, type Comfy3DOutput, 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, type HostToPanel, 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 OutputWidget, type OutputWidgetKind, type PanelError, type PanelHostAction, type PanelRequest, type PanelResultAction, type PanelState, type PanelToHost, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type RelightRoles, type RelightWidget, 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, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resolveWidgetRoles, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v, widget };
19159
+ 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 ChoiceOptionLook, type ChoiceSelect, ChoiceVar, type CodegenOptions, type Comfy3DOutput, 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, ComfyOrgApiKeyMissingError, type ComfyOrgApiKeySource, 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, type HostToPanel, 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 OutputWidget, type OutputWidgetKind, type PanelError, type PanelHostAction, type PanelRequest, type PanelResultAction, type PanelState, type PanelToHost, type ParsedHostBase, PartialOmit, type PartnerApiNode, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type RelightRoles, type RelightWidget, 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, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resolveWidgetRoles, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v, widget };
19126
19160
  //# sourceMappingURL=web.d.ts.map
package/dist/web.js CHANGED
@@ -101,7 +101,7 @@ function getComfyStorage() {
101
101
  }
102
102
  //#endregion
103
103
  //#region package.json
104
- var version = "2.23.0";
104
+ var version = "2.24.0";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -2323,7 +2323,10 @@ const types$1 = scope({
2323
2323
  Timestamp: "number",
2324
2324
  ApiPromptInput: {
2325
2325
  client_id: "string",
2326
- extra_data: { extra_pnginfo: "unknown" },
2326
+ extra_data: {
2327
+ extra_pnginfo: "unknown",
2328
+ "api_key_comfy_org?": "string"
2329
+ },
2327
2330
  prompt: "unknown"
2328
2331
  },
2329
2332
  NodeProgress: {
@@ -2996,6 +2999,8 @@ var ComfyExecution = class {
2996
2999
  });
2997
3000
  return "lost";
2998
3001
  }
3002
+ const sinceHeard = Date.now() - this.lastHeardAt;
3003
+ if (!this.mayHaveMissedEvents && this.sendsWsFrames && sinceHeard < this.host.runSilenceMaxMs) return "waiting";
2999
3004
  logInfo(`run ${id}: ended on host '${hostId}' without its end reaching the socket, finishing from its history`);
3000
3005
  for (const p of replay.problems) logError(`run ${id}: a history entry does not match the ws schemas, skipped: ${p}`);
3001
3006
  this.replayUnheardOutputs(replay);
@@ -3026,13 +3031,15 @@ var ComfyExecution = class {
3026
3031
  this.retrieveFile = async (info, promptNodeID, mime) => {
3027
3032
  const response = await this.host.fetchFile("/view?" + new URLSearchParams(info).toString());
3028
3033
  const bytes = new Uint8Array(await response.arrayBuffer());
3034
+ const tags = this.tagsOf(promptNodeID);
3029
3035
  const sf = this.save;
3030
3036
  if (sf == null) return {
3031
3037
  nodeId: promptNodeID,
3032
3038
  filename: info.filename,
3033
3039
  mime,
3034
3040
  bytes,
3035
- absPath: null
3041
+ absPath: null,
3042
+ tags
3036
3043
  };
3037
3044
  const promptPrefix = this.workflow.data.apiJson?.[promptNodeID]?.inputs["filename_prefix"];
3038
3045
  const written = await this.encodeAndWrite({
@@ -3050,7 +3057,8 @@ var ComfyExecution = class {
3050
3057
  filename: info.filename,
3051
3058
  mime,
3052
3059
  bytes,
3053
- absPath: written.path
3060
+ absPath: written.path,
3061
+ tags
3054
3062
  };
3055
3063
  };
3056
3064
  this.imageErrors = [];
@@ -3277,11 +3285,19 @@ var ComfyExecution = class {
3277
3285
  }
3278
3286
  /** accumulate an output on the prompt; tags from node metadata ride along */
3279
3287
  pushImage(img, promptNodeID) {
3280
- const promptMeta = promptNodeID != null ? this.workflow.data.metadata?.[promptNodeID] : null;
3281
- if (promptMeta?.tag) img.tags.push(promptMeta.tag);
3282
- if (promptMeta?.tags) img.tags.push(...promptMeta.tags);
3288
+ img.tags.push(...this.tagsOf(promptNodeID));
3283
3289
  this.images.push(img);
3284
3290
  }
3291
+ /** the tags an output node was built with (`{ tag }` / `{ tags }` metadata) */
3292
+ tagsOf(promptNodeID) {
3293
+ const promptMeta = promptNodeID != null ? this.workflow.data.metadata?.[promptNodeID] : null;
3294
+ return [...promptMeta?.tag ? [promptMeta.tag] : [], ...promptMeta?.tags ?? []];
3295
+ }
3296
+ /** the sent graph saves through SaveImageWebsocket: those outputs exist only as ws frames */
3297
+ get sendsWsFrames() {
3298
+ const apiJson = this.snapshot?.apiJson ?? this.workflow.apiJson;
3299
+ return Object.values(apiJson).some((n) => n?.class_type === "SaveImageWebsocket");
3300
+ }
3285
3301
  /** true while the currently executing node is a SaveImageWebsocket in the
3286
3302
  * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
3287
3303
  * live graph may still say SaveImage) — binary frames are then OUTPUTS */
@@ -3329,6 +3345,35 @@ var ComfyExecution = class {
3329
3345
  }
3330
3346
  };
3331
3347
  //#endregion
3348
+ //#region src/runner/comfyOrgApiKey.ts
3349
+ /** the prompt holds a paid partner node and no Comfy account key was set */
3350
+ var ComfyOrgApiKeyMissingError = class extends Error {
3351
+ constructor(hostId, nodes) {
3352
+ const list = nodes.map((n) => `${n.classType} #${n.id}`).join(", ");
3353
+ super(`🔴 host '${hostId}': the prompt holds partner API node(s) ${list}, which bill a Comfy account, and no Comfy account key is set. Set it with \`comfy.host({ id: '${hostId}', comfyOrgApiKey })\` or \`run({ comfyOrgApiKey })\` (a string or a thunk; the key comes from platform.comfy.org). Nothing was sent.`);
3354
+ this.hostId = hostId;
3355
+ this.nodes = nodes;
3356
+ this.name = "ComfyOrgApiKeyMissingError";
3357
+ }
3358
+ };
3359
+ /** the nodes of a prompt whose schema says `api_node: true` */
3360
+ const partnerApiNodes = (apiJson, schema) => {
3361
+ const out = [];
3362
+ for (const [id, node] of Object.entries(apiJson)) if (schema.nodesByNameInComfy[node.class_type]?.raw.api_node === true) out.push({
3363
+ id,
3364
+ classType: node.class_type
3365
+ });
3366
+ return out;
3367
+ };
3368
+ /** the first source set wins; an empty string counts as unset */
3369
+ const resolveComfyOrgApiKey = async (sources) => {
3370
+ for (const src of sources) {
3371
+ if (src == null) continue;
3372
+ const key = typeof src === "string" ? src : await src();
3373
+ if (key != null && key !== "") return key;
3374
+ }
3375
+ };
3376
+ //#endregion
3332
3377
  //#region src/runner/ephemeral.ts
3333
3378
  /**
3334
3379
  * the `ephemeral: true` rewrite (architecture.md item 14): every SaveImage
@@ -3488,6 +3533,8 @@ function comfyWorkflowAutoLayout(p) {
3488
3533
  }
3489
3534
  //#endregion
3490
3535
  //#region src/runner/ComfyWorkflow.ts
3536
+ /** a Comfy Cloud host's X-API-Key is a platform.comfy.org key, the one partner nodes bill to */
3537
+ const COMFY_CLOUD_HOST = "cloud.comfy.org";
3491
3538
  const asComfyWorkflowID = (x) => x;
3492
3539
  var ComfyWorkflow = class {
3493
3540
  constructor(host, data) {
@@ -3618,14 +3665,29 @@ var ComfyWorkflow = class {
3618
3665
  const hasWsSaver = Object.values(snapshot.apiJson).some((n) => n.class_type === "SaveImageWebsocket");
3619
3666
  if (rewritten === 0 && !hasWsSaver) console.warn(`🟡 ephemeral run: no SaveImage/SaveImageWebsocket node in workflow '${this.id}' — nothing streams back`);
3620
3667
  }
3668
+ const partners = partnerApiNodes(snapshot.apiJson, this.schema);
3669
+ let comfyOrgApiKey;
3670
+ if (partners.length > 0) {
3671
+ const data = this.host.data;
3672
+ const cloudKey = data.apiKey != null && this.host.base.host === COMFY_CLOUD_HOST ? data.apiKey : void 0;
3673
+ comfyOrgApiKey = await resolveComfyOrgApiKey([
3674
+ p.comfyOrgApiKey,
3675
+ data.comfyOrgApiKey,
3676
+ cloudKey
3677
+ ]);
3678
+ if (comfyOrgApiKey == null) throw new ComfyOrgApiKeyMissingError(data.id, partners);
3679
+ }
3621
3680
  const out = {
3622
3681
  client_id: this.host.comfySessionId,
3623
3682
  prompt: snapshot.apiJson,
3624
- extra_data: { extra_pnginfo: {
3625
- workflow: snapshot.workflowJson,
3626
- comfy_ts_workflow_id: this.id,
3627
- comfy_ts_version: comfyts.version
3628
- } }
3683
+ extra_data: {
3684
+ extra_pnginfo: {
3685
+ workflow: snapshot.workflowJson,
3686
+ comfy_ts_workflow_id: this.id,
3687
+ comfy_ts_version: comfyts.version
3688
+ },
3689
+ ...comfyOrgApiKey != null ? { api_key_comfy_org: comfyOrgApiKey } : {}
3690
+ }
3629
3691
  };
3630
3692
  const res = await this.host.fetch("/prompt", {
3631
3693
  method: "POST",
@@ -4400,7 +4462,8 @@ const types = scope({
4400
4462
  output_node: "boolean",
4401
4463
  "output_tooltips?": "(string | null)[]",
4402
4464
  "deprecated?": "boolean",
4403
- "experimental?": "boolean"
4465
+ "experimental?": "boolean",
4466
+ "api_node?": "boolean"
4404
4467
  },
4405
4468
  ComfyInputSpecAlt1: ["ComfyInputType", "ComfyInputOpts"],
4406
4469
  ComfyInputSpecAlt2: ["ComfyInputType"],
@@ -6927,7 +6990,8 @@ var DefinedWorkflow = class {
6927
6990
  idMode: settings.idMode,
6928
6991
  log: settings.log,
6929
6992
  onProgress: settings.onProgress,
6930
- onPreview: settings.onPreview
6993
+ onPreview: settings.onPreview,
6994
+ comfyOrgApiKey: settings.comfyOrgApiKey
6931
6995
  });
6932
6996
  this.lastExecution = execution;
6933
6997
  return execution;
@@ -8421,6 +8485,7 @@ var ComfyTS = class ComfyTS {
8421
8485
  const authed = (p) => p.apiKey != null ? " (authed)" : "";
8422
8486
  throw new Error(`host id '${data.id}' already registered ${cur == null ? "with no address" : `at ${renderHttpBase(cur)}`}${authed(existing.data)} — refusing ${incoming == null ? "the id alone" : renderHttpBase(incoming)}${authed(data)}`);
8423
8487
  }
8488
+ if (data.comfyOrgApiKey != null) existing.data.comfyOrgApiKey = data.comfyOrgApiKey;
8424
8489
  return existing;
8425
8490
  }
8426
8491
  const created = new ComfyHost(data);
@@ -8518,6 +8583,6 @@ function loraTag(name, strength = 1, clipStrength) {
8518
8583
  */
8519
8584
  setDefaultComfyStorage(createMemoryStorage());
8520
8585
  //#endregion
8521
- export { AudioVar, ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, MediaVar, MediaVarEmptyError, MultiChoiceVar, OptionalChoiceVar, PromptVar, ResilientWebSocketClient, SD15_SIZE_PRESETS, SeedVar, SizeVar, TextVar, ToggleVar, VideoVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resolveWidgetRoles, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v, widget };
8586
+ export { AudioVar, ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfyOrgApiKeyMissingError, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, MediaVar, MediaVarEmptyError, MultiChoiceVar, OptionalChoiceVar, PromptVar, ResilientWebSocketClient, SD15_SIZE_PRESETS, SeedVar, SizeVar, TextVar, ToggleVar, VideoVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resolveWidgetRoles, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v, widget };
8522
8587
 
8523
8588
  //# sourceMappingURL=web.js.map