comfy-ts 2.20.2 → 2.21.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 (31) hide show
  1. package/README.md +17 -1
  2. package/dist/{ServeApp-B469W26E.js → ServeApp-ByMobrWW.js} +3 -3
  3. package/dist/{ServeApp-B469W26E.js.map → ServeApp-ByMobrWW.js.map} +1 -1
  4. package/dist/cli.js +5 -5
  5. package/dist/{exampleAssets-yBLaKXLq.js → exampleAssets-B5sMqNia.js} +58 -3
  6. package/dist/exampleAssets-B5sMqNia.js.map +1 -0
  7. package/dist/{findDefinedWorkflow-B90-xFxX.js → findDefinedWorkflow-BNZgYIww.js} +2 -2
  8. package/dist/{findDefinedWorkflow-B90-xFxX.js.map → findDefinedWorkflow-BNZgYIww.js.map} +1 -1
  9. package/dist/index.cjs +87 -19
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +19 -3
  12. package/dist/index.d.ts +19 -3
  13. package/dist/index.js +87 -19
  14. package/dist/index.js.map +1 -1
  15. package/dist/{run-run-C-dDD9Dc.js → run-run-CuBSygku.js} +5 -5
  16. package/dist/{run-run-C-dDD9Dc.js.map → run-run-CuBSygku.js.map} +1 -1
  17. package/dist/{run-serve-CsEYPGm9.js → run-serve-COk_G0Qz.js} +4 -4
  18. package/dist/{run-serve-CsEYPGm9.js.map → run-serve-COk_G0Qz.js.map} +1 -1
  19. package/dist/{run-tui-bsmja4hi.js → run-tui-CB6i_x2y.js} +4 -4
  20. package/dist/{run-tui-bsmja4hi.js.map → run-tui-CB6i_x2y.js.map} +1 -1
  21. package/dist/{schemaDrift-DaWsE-mt.js → schemaDrift-CHDVYlaj.js} +32 -19
  22. package/dist/{schemaDrift-DaWsE-mt.js.map → schemaDrift-CHDVYlaj.js.map} +1 -1
  23. package/dist/web.d.ts +19 -3
  24. package/dist/web.js +87 -19
  25. package/dist/web.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/host/ComfyHost.ts +21 -0
  28. package/src/host/leastBusy.ts +37 -0
  29. package/src/state.ts +6 -0
  30. package/src/vars/DefinedWorkflow.ts +38 -21
  31. package/dist/exampleAssets-yBLaKXLq.js.map +0 -1
@@ -2038,37 +2038,50 @@ var DefinedWorkflow = class {
2038
2038
  * the graph is built against (TUI host override): node/model availability
2039
2039
  * there surfaces as workflow.problems / server validation, by design.
2040
2040
  * `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.
2041
+ * `p.values` builds from a snapshot taken earlier (run() takes it at the call).
2041
2042
  */
2042
2043
  async build(p = {}) {
2043
2044
  const wf = (p.host ?? this.host).workflow({ id: this.spec.id });
2044
2045
  wf.dry = p.dry === true;
2045
- const values = varValues(this.vars);
2046
- if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
2046
+ const values = p.values ?? this.snapshot({ advance: p.advance === true });
2047
2047
  await this.spec.build(wf.builder, values, wf);
2048
2048
  if (wf.dry) return wf;
2049
2049
  this.lastWorkflow = wf;
2050
2050
  return wf;
2051
2051
  }
2052
- /** build a fresh graph from the current var values, send it, wait for outputs.
2052
+ /** the current var values; `advance` then moves each var to its next run (the seed) */
2053
+ snapshot(p) {
2054
+ const values = varValues(this.vars);
2055
+ if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
2056
+ return values;
2057
+ }
2058
+ /** build a fresh graph from the var values AT THE CALL, send it, wait for outputs:
2059
+ * set a var, call run(), set it again, and each run keeps its own values.
2053
2060
  * connects first (idempotent) — modules can import offline from the schema cache.
2054
2061
  * `settings.host` runs against THAT host instead of the defining one. */
2055
2062
  async run(settings = {}) {
2056
2063
  const host = settings.host ?? this.host;
2057
- await host.connect();
2058
- const execution = await (await this.build({
2059
- advance: true,
2060
- host
2061
- })).run({
2062
- save: settings.save,
2063
- ephemeral: settings.ephemeral,
2064
- scrubHistory: settings.scrubHistory,
2065
- idMode: settings.idMode,
2066
- log: settings.log,
2067
- onProgress: settings.onProgress,
2068
- onPreview: settings.onPreview
2069
- });
2070
- this.lastExecution = execution;
2071
- return execution;
2064
+ const values = this.snapshot({ advance: true });
2065
+ host.runsInFlight++;
2066
+ try {
2067
+ await host.connect();
2068
+ const execution = await (await this.build({
2069
+ host,
2070
+ values
2071
+ })).run({
2072
+ save: settings.save,
2073
+ ephemeral: settings.ephemeral,
2074
+ scrubHistory: settings.scrubHistory,
2075
+ idMode: settings.idMode,
2076
+ log: settings.log,
2077
+ onProgress: settings.onProgress,
2078
+ onPreview: settings.onPreview
2079
+ });
2080
+ this.lastExecution = execution;
2081
+ return execution;
2082
+ } finally {
2083
+ host.runsInFlight--;
2084
+ }
2072
2085
  }
2073
2086
  };
2074
2087
  //#endregion
@@ -2174,4 +2187,4 @@ function summarizeDrift(d) {
2174
2187
  //#endregion
2175
2188
  export { DEFAULT_MEDIA_EXTENSIONS as $, reloadLoraInfoCache as A, lmFileSize as B, getLoraTriggers as C, readLoraMirror as D, lorasMissingFromMirror as E, fetchLoraList as F, lmTags as G, lmModelName as H, fetchLoraPreviewBytes as I, loraKey as J, lmTrainedWords as K, lmBaseModel as L, fetchLoraCivitai as M, fetchLoraDescription as N, recordCivitaiMiss as O, fetchLoraExampleImages as P, stripAnsi as Q, lmCivitai as R, getLoraTriggerWords as S, loraMirrorEntries as T, lmNotes as U, lmFolder as V, lmSha256 as W, ansi as X, loraPreviewMapFrom as Y, colorsAvailable as Z, buildLoraMirror as _, DefinedWorkflow as a, isRecord as at, getLoraInfo as b, isLoraLanes as c, resolveComfyStorage as ct, isLoraStrength as d, logInfo as dt, MEDIA_KINDS as et, clearLoraKeywordOverride as f, logSuccess as ft, setLoraKeyword as g, loraKeywordFromMirror as h, extractErrorMessage as ht, summarizeDrift as i, hashArrayBuffer as it, writeLoraMirror as j, refreshLoraInfoCacheIfChanged as k, isLorasInput as l, isQuiet as lt, isLoraKeywordFromMirror as m, sha1HexOfString as mt, diffSchemas as n, isVideoFilename as nt, LorasVar as o, bang as ot, getLoraKeyword as p, statelessRegex as pt, loraBasename as q, driftChanged as r, mediaMime as rt, PromptVar as s, getComfyStorage as st, MODEL_LISTS as t, extensionOf as tt, isPromptInput as u, logError as ut, getLoraAddedAt as v, loraMatchesFilter as w, getLoraPreviewUrl as x, getLoraDisplayName as y, lmFilePath as z };
2176
2189
 
2177
- //# sourceMappingURL=schemaDrift-DaWsE-mt.js.map
2190
+ //# sourceMappingURL=schemaDrift-CHDVYlaj.js.map