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/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { a as readableStringify, c as renderHttpBase, n as comfyTsPackageDir, o as ComfySchema, r as ComfyTS, s as writeHostFile } from "./exampleAssets-Duneoq6r.js";
3
- import { D as readLoraMirror, F as fetchLoraList, H as lmModelName, K as lmTrainedWords, _ as buildLoraMirror, j as writeLoraMirror } from "./schemaDrift-BTxdABHi.js";
2
+ import { a as readableStringify, c as renderHttpBase, n as comfyTsPackageDir, o as ComfySchema, r as ComfyTS, s as writeHostFile } from "./exampleAssets-DZynSkZm.js";
3
+ import { D as readLoraMirror, F as fetchLoraList, H as lmModelName, K as lmTrainedWords, _ as buildLoraMirror, j as writeLoraMirror } from "./schemaDrift-BGYJZGMD.js";
4
4
  import { spawn } from "node:child_process";
5
5
  import { constants, homedir } from "node:os";
6
6
  import { fileURLToPath } from "node:url";
@@ -554,14 +554,14 @@ async function main() {
554
554
  }
555
555
  armHopChild();
556
556
  if (cmd === "run") {
557
- const { runRun } = await import("./run-run-Cr0L9lCK.js");
557
+ const { runRun } = await import("./run-run-Cn2JzKlE.js");
558
558
  return runRun(rest);
559
559
  }
560
560
  if (cmd === "serve") {
561
- const { runServe } = await import("./run-serve---qA7o_m.js");
561
+ const { runServe } = await import("./run-serve-BhGegaCI.js");
562
562
  return runServe(rest);
563
563
  }
564
- const { runTui } = await import("./run-tui-DxXiWo5J.js");
564
+ const { runTui } = await import("./run-tui-CrM4ijkH.js");
565
565
  return runTui(rest);
566
566
  }
567
567
  console.log(HELP);
@@ -1,4 +1,4 @@
1
- import { X as ansi, _t as sha1HexOfString, a as DefinedWorkflow, at as mediaMime, ct as isRecord$1, dt as resolveComfyStorage, et as model3dMime, ft as isQuiet, gt as statelessRegex, ht as logSuccess, it as isVideoFilename, lt as bang, mt as logInfo, n as diffSchemas, ot as hashArrayBuffer, pt as logError, rt as extensionOf, st as importSharp, t as MODEL_LISTS, ut as getComfyStorage, vt as extractErrorMessage } from "./schemaDrift-BTxdABHi.js";
1
+ import { X as ansi, _t as sha1HexOfString, a as DefinedWorkflow, at as mediaMime, ct as isRecord$1, dt as resolveComfyStorage, et as model3dMime, ft as isQuiet, gt as statelessRegex, ht as logSuccess, it as isVideoFilename, lt as bang, mt as logInfo, n as diffSchemas, ot as hashArrayBuffer, pt as logError, rt as extensionOf, st as importSharp, t as MODEL_LISTS, ut as getComfyStorage, vt as extractErrorMessage } from "./schemaDrift-BGYJZGMD.js";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { basename, dirname, join } from "pathe";
@@ -1008,7 +1008,7 @@ var ComfySchema = class {
1008
1008
  };
1009
1009
  //#endregion
1010
1010
  //#region package.json
1011
- var version = "2.23.0";
1011
+ var version = "2.24.0";
1012
1012
  //#endregion
1013
1013
  //#region src/litegraph/LiteGraphLinkID.ts
1014
1014
  const asLiteGraphLinkID = (id) => id;
@@ -2854,7 +2854,10 @@ const types$1 = scope({
2854
2854
  Timestamp: "number",
2855
2855
  ApiPromptInput: {
2856
2856
  client_id: "string",
2857
- extra_data: { extra_pnginfo: "unknown" },
2857
+ extra_data: {
2858
+ extra_pnginfo: "unknown",
2859
+ "api_key_comfy_org?": "string"
2860
+ },
2858
2861
  prompt: "unknown"
2859
2862
  },
2860
2863
  NodeProgress: {
@@ -3438,6 +3441,8 @@ var ComfyExecution = class {
3438
3441
  });
3439
3442
  return "lost";
3440
3443
  }
3444
+ const sinceHeard = Date.now() - this.lastHeardAt;
3445
+ if (!this.mayHaveMissedEvents && this.sendsWsFrames && sinceHeard < this.host.runSilenceMaxMs) return "waiting";
3441
3446
  logInfo(`run ${id}: ended on host '${hostId}' without its end reaching the socket, finishing from its history`);
3442
3447
  for (const p of replay.problems) logError(`run ${id}: a history entry does not match the ws schemas, skipped: ${p}`);
3443
3448
  this.replayUnheardOutputs(replay);
@@ -3468,13 +3473,15 @@ var ComfyExecution = class {
3468
3473
  this.retrieveFile = async (info, promptNodeID, mime) => {
3469
3474
  const response = await this.host.fetchFile("/view?" + new URLSearchParams(info).toString());
3470
3475
  const bytes = new Uint8Array(await response.arrayBuffer());
3476
+ const tags = this.tagsOf(promptNodeID);
3471
3477
  const sf = this.save;
3472
3478
  if (sf == null) return {
3473
3479
  nodeId: promptNodeID,
3474
3480
  filename: info.filename,
3475
3481
  mime,
3476
3482
  bytes,
3477
- absPath: null
3483
+ absPath: null,
3484
+ tags
3478
3485
  };
3479
3486
  const promptPrefix = this.workflow.data.apiJson?.[promptNodeID]?.inputs["filename_prefix"];
3480
3487
  const written = await this.encodeAndWrite({
@@ -3492,7 +3499,8 @@ var ComfyExecution = class {
3492
3499
  filename: info.filename,
3493
3500
  mime,
3494
3501
  bytes,
3495
- absPath: written.path
3502
+ absPath: written.path,
3503
+ tags
3496
3504
  };
3497
3505
  };
3498
3506
  this.imageErrors = [];
@@ -3719,11 +3727,19 @@ var ComfyExecution = class {
3719
3727
  }
3720
3728
  /** accumulate an output on the prompt; tags from node metadata ride along */
3721
3729
  pushImage(img, promptNodeID) {
3722
- const promptMeta = promptNodeID != null ? this.workflow.data.metadata?.[promptNodeID] : null;
3723
- if (promptMeta?.tag) img.tags.push(promptMeta.tag);
3724
- if (promptMeta?.tags) img.tags.push(...promptMeta.tags);
3730
+ img.tags.push(...this.tagsOf(promptNodeID));
3725
3731
  this.images.push(img);
3726
3732
  }
3733
+ /** the tags an output node was built with (`{ tag }` / `{ tags }` metadata) */
3734
+ tagsOf(promptNodeID) {
3735
+ const promptMeta = promptNodeID != null ? this.workflow.data.metadata?.[promptNodeID] : null;
3736
+ return [...promptMeta?.tag ? [promptMeta.tag] : [], ...promptMeta?.tags ?? []];
3737
+ }
3738
+ /** the sent graph saves through SaveImageWebsocket: those outputs exist only as ws frames */
3739
+ get sendsWsFrames() {
3740
+ const apiJson = this.snapshot?.apiJson ?? this.workflow.apiJson;
3741
+ return Object.values(apiJson).some((n) => n?.class_type === "SaveImageWebsocket");
3742
+ }
3727
3743
  /** true while the currently executing node is a SaveImageWebsocket in the
3728
3744
  * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
3729
3745
  * live graph may still say SaveImage) — binary frames are then OUTPUTS */
@@ -3771,6 +3787,35 @@ var ComfyExecution = class {
3771
3787
  }
3772
3788
  };
3773
3789
  //#endregion
3790
+ //#region src/runner/comfyOrgApiKey.ts
3791
+ /** the prompt holds a paid partner node and no Comfy account key was set */
3792
+ var ComfyOrgApiKeyMissingError = class extends Error {
3793
+ constructor(hostId, nodes) {
3794
+ const list = nodes.map((n) => `${n.classType} #${n.id}`).join(", ");
3795
+ 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.`);
3796
+ this.hostId = hostId;
3797
+ this.nodes = nodes;
3798
+ this.name = "ComfyOrgApiKeyMissingError";
3799
+ }
3800
+ };
3801
+ /** the nodes of a prompt whose schema says `api_node: true` */
3802
+ const partnerApiNodes = (apiJson, schema) => {
3803
+ const out = [];
3804
+ for (const [id, node] of Object.entries(apiJson)) if (schema.nodesByNameInComfy[node.class_type]?.raw.api_node === true) out.push({
3805
+ id,
3806
+ classType: node.class_type
3807
+ });
3808
+ return out;
3809
+ };
3810
+ /** the first source set wins; an empty string counts as unset */
3811
+ const resolveComfyOrgApiKey = async (sources) => {
3812
+ for (const src of sources) {
3813
+ if (src == null) continue;
3814
+ const key = typeof src === "string" ? src : await src();
3815
+ if (key != null && key !== "") return key;
3816
+ }
3817
+ };
3818
+ //#endregion
3774
3819
  //#region src/runner/ephemeral.ts
3775
3820
  /**
3776
3821
  * the `ephemeral: true` rewrite (architecture.md item 14): every SaveImage
@@ -3907,6 +3952,8 @@ function comfyWorkflowAutoLayout(p) {
3907
3952
  }
3908
3953
  //#endregion
3909
3954
  //#region src/runner/ComfyWorkflow.ts
3955
+ /** a Comfy Cloud host's X-API-Key is a platform.comfy.org key, the one partner nodes bill to */
3956
+ const COMFY_CLOUD_HOST = "cloud.comfy.org";
3910
3957
  const asComfyWorkflowID = (x) => x;
3911
3958
  var ComfyWorkflow = class {
3912
3959
  constructor(host, data) {
@@ -4037,14 +4084,29 @@ var ComfyWorkflow = class {
4037
4084
  const hasWsSaver = Object.values(snapshot.apiJson).some((n) => n.class_type === "SaveImageWebsocket");
4038
4085
  if (rewritten === 0 && !hasWsSaver) console.warn(`🟡 ephemeral run: no SaveImage/SaveImageWebsocket node in workflow '${this.id}' — nothing streams back`);
4039
4086
  }
4087
+ const partners = partnerApiNodes(snapshot.apiJson, this.schema);
4088
+ let comfyOrgApiKey;
4089
+ if (partners.length > 0) {
4090
+ const data = this.host.data;
4091
+ const cloudKey = data.apiKey != null && this.host.base.host === COMFY_CLOUD_HOST ? data.apiKey : void 0;
4092
+ comfyOrgApiKey = await resolveComfyOrgApiKey([
4093
+ p.comfyOrgApiKey,
4094
+ data.comfyOrgApiKey,
4095
+ cloudKey
4096
+ ]);
4097
+ if (comfyOrgApiKey == null) throw new ComfyOrgApiKeyMissingError(data.id, partners);
4098
+ }
4040
4099
  const out = {
4041
4100
  client_id: this.host.comfySessionId,
4042
4101
  prompt: snapshot.apiJson,
4043
- extra_data: { extra_pnginfo: {
4044
- workflow: snapshot.workflowJson,
4045
- comfy_ts_workflow_id: this.id,
4046
- comfy_ts_version: comfyts.version
4047
- } }
4102
+ extra_data: {
4103
+ extra_pnginfo: {
4104
+ workflow: snapshot.workflowJson,
4105
+ comfy_ts_workflow_id: this.id,
4106
+ comfy_ts_version: comfyts.version
4107
+ },
4108
+ ...comfyOrgApiKey != null ? { api_key_comfy_org: comfyOrgApiKey } : {}
4109
+ }
4048
4110
  };
4049
4111
  const res = await this.host.fetch("/prompt", {
4050
4112
  method: "POST",
@@ -4151,7 +4213,8 @@ const types = scope({
4151
4213
  output_node: "boolean",
4152
4214
  "output_tooltips?": "(string | null)[]",
4153
4215
  "deprecated?": "boolean",
4154
- "experimental?": "boolean"
4216
+ "experimental?": "boolean",
4217
+ "api_node?": "boolean"
4155
4218
  },
4156
4219
  ComfyInputSpecAlt1: ["ComfyInputType", "ComfyInputOpts"],
4157
4220
  ComfyInputSpecAlt2: ["ComfyInputType"],
@@ -6516,6 +6579,7 @@ var ComfyTS = class ComfyTS {
6516
6579
  const authed = (p) => p.apiKey != null ? " (authed)" : "";
6517
6580
  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)}`);
6518
6581
  }
6582
+ if (data.comfyOrgApiKey != null) existing.data.comfyOrgApiKey = data.comfyOrgApiKey;
6519
6583
  return existing;
6520
6584
  }
6521
6585
  const created = new ComfyHost(data);
@@ -6607,4 +6671,4 @@ function comfyTsPackageDir(moduleUrl = import.meta.url) {
6607
6671
  //#endregion
6608
6672
  export { readableStringify as a, renderHttpBase as c, settingsPathFor as i, comfyTsPackageDir as n, ComfySchema as o, ComfyTS as r, writeHostFile as s, bundledExamplesDir as t };
6609
6673
 
6610
- //# sourceMappingURL=exampleAssets-Duneoq6r.js.map
6674
+ //# sourceMappingURL=exampleAssets-DZynSkZm.js.map