comfy-ts 2.16.0 → 2.17.1

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 (71) hide show
  1. package/README.md +23 -0
  2. package/dist/{run-serve-C78hD7t9.js → ServeApp-qXcQfdgT.js} +18 -445
  3. package/dist/ServeApp-qXcQfdgT.js.map +1 -0
  4. package/dist/cli.js +72 -9
  5. package/dist/cli.js.map +1 -1
  6. package/dist/exampleAssets-BfWzygoM.js +38 -0
  7. package/dist/exampleAssets-BfWzygoM.js.map +1 -0
  8. package/dist/{LogsSt-Ct7Le0S_.js → findDefinedWorkflow-0lG-VTEd.js} +201 -201
  9. package/dist/findDefinedWorkflow-0lG-VTEd.js.map +1 -0
  10. package/dist/index.cjs +182 -69
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +61 -8
  13. package/dist/index.d.ts +61 -8
  14. package/dist/index.js +182 -69
  15. package/dist/index.js.map +1 -1
  16. package/dist/run-run-tg82jUIk.js +450 -0
  17. package/dist/run-run-tg82jUIk.js.map +1 -0
  18. package/dist/run-serve-DaXzoVTS.js +464 -0
  19. package/dist/run-serve-DaXzoVTS.js.map +1 -0
  20. package/dist/{run-tui-nPETFRmk.js → run-tui-Bw7BA75d.js} +7 -38
  21. package/dist/run-tui-Bw7BA75d.js.map +1 -0
  22. package/dist/{schemaDrift-wb5XkrHV.js → schemaDrift-CbsABBuk.js} +3 -2
  23. package/dist/{schemaDrift-wb5XkrHV.js.map → schemaDrift-CbsABBuk.js.map} +1 -1
  24. package/dist/serve-web.js +56 -48
  25. package/dist/{state-BMW57_M0.js → state-zTow5ucI.js} +182 -70
  26. package/dist/state-zTow5ucI.js.map +1 -0
  27. package/dist/web.d.ts +61 -8
  28. package/dist/web.js +182 -69
  29. package/dist/web.js.map +1 -1
  30. package/examples/README.md +1 -0
  31. package/examples/rvion/15-tts-voice-clone.cflow.ts +8 -8
  32. package/examples/rvion/16-tts-voice-design.cflow.ts +71 -0
  33. package/guide-for-agents.md +3 -0
  34. package/package.json +2 -2
  35. package/src/cli/bunHop.ts +49 -0
  36. package/src/cli/comfy-ts-cli.ts +18 -5
  37. package/src/cli/run/findModules.ts +36 -0
  38. package/src/cli/run/flagValue.ts +61 -0
  39. package/src/cli/run/outputPaths.ts +41 -0
  40. package/src/cli/run/pickModule.ts +41 -0
  41. package/src/cli/run/run-run.ts +250 -0
  42. package/src/cli/run/runArgs.ts +61 -0
  43. package/src/cli/run/sidecar.ts +27 -0
  44. package/src/cli/serve/ServeApp.ts +13 -39
  45. package/src/cli/serve/run-serve.ts +51 -13
  46. package/src/cli/serve/web/components/App.tsx +2 -0
  47. package/src/cli/serve/web/components/DialogLayer.tsx +55 -0
  48. package/src/cli/serve/web/components/DraftTabs.tsx +16 -5
  49. package/src/cli/serve/web/components/PromptEnhancer.tsx +15 -9
  50. package/src/cli/serve/web/components/SideMenu.tsx +16 -8
  51. package/src/cli/serve/web/state/WebSt.ts +10 -1
  52. package/src/cli/serve/web/state/dialog.ts +59 -0
  53. package/src/cli/serve/web/state/draftTabs.ts +12 -0
  54. package/src/cli/serve/web/state/keptLines.ts +1 -1
  55. package/src/cli/serve/web/state/shortcutCatalog.ts +1 -0
  56. package/src/cli/serve/web/styles.ts +8 -0
  57. package/src/coreExports.ts +2 -0
  58. package/src/host/ComfyHost.ts +73 -40
  59. package/src/host/previewMethod.ts +29 -0
  60. package/src/litegraph/convertFlowToLiteGraphJSON.ts +38 -20
  61. package/src/promptEnhancers.ts +1 -1
  62. package/src/runner/ComfyExecution.ts +45 -1
  63. package/src/runner/ComfyWorkflow.ts +6 -1
  64. package/src/runner/ComfyWsApi.ts +1 -1
  65. package/src/runner/wsBinaryFrame.ts +48 -25
  66. package/src/vars/ComfyVars.ts +3 -0
  67. package/src/vars/DefinedWorkflow.ts +1 -0
  68. package/dist/LogsSt-Ct7Le0S_.js.map +0 -1
  69. package/dist/run-serve-C78hD7t9.js.map +0 -1
  70. package/dist/run-tui-nPETFRmk.js.map +0 -1
  71. package/dist/state-BMW57_M0.js.map +0 -1
package/dist/cli.js CHANGED
@@ -1,10 +1,59 @@
1
1
  #!/usr/bin/env node
2
- import { D as readLoraMirror, F as fetchLoraList, H as lmModelName, K as lmTrainedWords, _ as buildLoraMirror, j as writeLoraMirror } from "./schemaDrift-wb5XkrHV.js";
3
- import { a as ComfySchema, r as readableStringify, t as ComfyTS } from "./state-BMW57_M0.js";
4
- import { spawnSync } from "node:child_process";
2
+ import { D as readLoraMirror, F as fetchLoraList, H as lmModelName, K as lmTrainedWords, _ as buildLoraMirror, j as writeLoraMirror } from "./schemaDrift-CbsABBuk.js";
3
+ import { a as ComfySchema, r as readableStringify, t as ComfyTS } from "./state-zTow5ucI.js";
4
+ import { spawn } from "node:child_process";
5
+ import { constants } from "node:os";
5
6
  import { fileURLToPath } from "node:url";
6
7
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmdirSync, writeFileSync } from "node:fs";
7
8
  import { dirname, join, resolve } from "pathe";
9
+ //#region src/cli/bunHop.ts
10
+ const HOP_PARENT_ENV = "COMFY_TS_HOP_PARENT";
11
+ const FORWARDED = [
12
+ "SIGINT",
13
+ "SIGTERM",
14
+ "SIGHUP"
15
+ ];
16
+ /** runs `bun <argv>` with the terminal inherited, forwarding the stop signals;
17
+ * resolves the child's exit code, or `error` when bun cannot start */
18
+ function hopToBun(argv) {
19
+ return new Promise((resolve) => {
20
+ const child = spawn("bun", argv, {
21
+ stdio: "inherit",
22
+ env: {
23
+ ...process.env,
24
+ [HOP_PARENT_ENV]: String(process.pid)
25
+ }
26
+ });
27
+ const forward = (signal) => {
28
+ child.kill(signal);
29
+ };
30
+ for (const signal of FORWARDED) process.on(signal, forward);
31
+ const done = (r) => {
32
+ for (const signal of FORWARDED) process.off(signal, forward);
33
+ resolve(r);
34
+ };
35
+ child.once("error", (error) => done({ error }));
36
+ child.once("exit", (code, signal) => {
37
+ if (code != null) return done({ code });
38
+ done({ code: signal == null ? 1 : 128 + (constants.signals[signal] ?? 0) });
39
+ });
40
+ });
41
+ }
42
+ /** in the bun child: exit once the process that started it is gone. A SIGKILL to
43
+ * the wrapper reaches no handler, so the child polls its own ppid, which changes
44
+ * (to 1, or a subreaper) when its parent dies. It watches the ppid it started
45
+ * with, not the wrapper pid: a version manager shim may sit between the two */
46
+ function armHopChild(p = {}) {
47
+ if (process.env[HOP_PARENT_ENV] == null) return;
48
+ Reflect.deleteProperty(process.env, HOP_PARENT_ENV);
49
+ const parent = process.ppid;
50
+ setInterval(() => {
51
+ if (process.ppid === parent) return;
52
+ console.error(`[comfy-ts] the process that started this one (pid ${parent}) is gone: exiting`);
53
+ process.exit(1);
54
+ }, p.intervalMs ?? 1e3).unref();
55
+ }
56
+ //#endregion
8
57
  //#region src/cli/flags.ts
9
58
  /**
10
59
  * the CLI's one flag reader: `--name value`.
@@ -260,6 +309,15 @@ Usage:
260
309
  panel. No bundled examples, no auth, and any origin may call it: use
261
310
  --host beyond localhost only on a network you trust.
262
311
 
312
+ comfy-ts run <name | module.cflow.ts> [--draft <name>] [--<var> <value>…] [--out <path>] [--json]
313
+ ONE generation, headless, with live progress: the module is found in cwd,
314
+ then in the examples bundled with comfy-ts, by its key (10-anima-t2i), its
315
+ key without the number (anima-t2i) or a unique part (anima). Each var is a
316
+ flag (--prompt "…" --seed 7 --image in.png), --<var>-file reads a text var
317
+ from a file, --out writes the output there (several: a-1.png, a-2.png; a
318
+ dir keeps the server's names). \`comfy-ts run <name> --help\` lists the vars,
319
+ \`comfy-ts run\` lists the modules. --json prints one line with the paths
320
+
263
321
  comfy-ts help
264
322
  `;
265
323
  async function main() {
@@ -267,21 +325,26 @@ async function main() {
267
325
  if (cmd === "gen") return runGen(rest);
268
326
  if (cmd === "outline") return runOutline(rest);
269
327
  if (cmd === "loras") return runLoras(rest);
270
- if (cmd === "tui" || cmd === "serve") {
328
+ if (cmd === "tui" || cmd === "serve" || cmd === "run") {
271
329
  if (process.versions.bun == null) {
272
- const res = spawnSync("bun", [
330
+ const res = await hopToBun([
273
331
  fileURLToPath(import.meta.url),
274
332
  cmd,
275
333
  ...rest
276
- ], { stdio: "inherit" });
277
- if (res.error == null) return res.status ?? 1;
334
+ ]);
335
+ if ("code" in res) return res.code;
278
336
  console.error(`[comfy-ts ${cmd}] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`);
279
337
  }
338
+ armHopChild();
339
+ if (cmd === "run") {
340
+ const { runRun } = await import("./run-run-tg82jUIk.js");
341
+ return runRun(rest);
342
+ }
280
343
  if (cmd === "serve") {
281
- const { runServe } = await import("./run-serve-C78hD7t9.js");
344
+ const { runServe } = await import("./run-serve-DaXzoVTS.js");
282
345
  return runServe(rest);
283
346
  }
284
- const { runTui } = await import("./run-tui-nPETFRmk.js");
347
+ const { runTui } = await import("./run-tui-Bw7BA75d.js");
285
348
  return runTui(rest);
286
349
  }
287
350
  console.log(HELP);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/cli/flags.ts","../src/cli/gen.ts","../src/cli/loras.ts","../src/cli/outline.ts","../src/cli/comfy-ts-cli.ts"],"sourcesContent":["/**\n * the CLI's one flag reader: `--name value`.\n * A flag written with no value after it is a TYPO, never a request for the\n * default — silently falling back would run against the wrong host.\n */\nexport function flagReader(args: string[]): (name: string) => string | null {\n return (name: string): string | null => {\n const ix = args.indexOf(`--${name}`)\n if (ix < 0) return null\n const value = args[ix + 1]\n if (value == null || value.startsWith('--')) throw new Error(`--${name} needs a value`)\n return value\n }\n}\n","// fetch a live host's schema and generate its typed sdk\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, join, resolve } from 'pathe'\nimport { flagReader } from 'src/cli/flags.ts'\nimport { ComfySchema } from 'src/sdk-generator/ComfySchema.ts'\nimport type { ComfySchemaJSON } from 'src/sdk-generator/ComfyUIObjectInfoTypes.ts'\nimport { ComfyTS } from 'src/state.ts'\nimport { readableStringify } from 'src/utils/stringifyReadable.ts'\n\nexport async function runGen(args: string[]): Promise<number> {\n const getFlag = flagReader(args)\n const hostUrl = getFlag('host') ?? 'http://127.0.0.1:8188'\n const id = getFlag('id')\n if (id == null) {\n console.error('[comfy-ts gen] 🔴 --id <host-id> is required (it names .comfy-ts/hosts/<id>/)')\n return 1\n }\n\n // the lib's own authed host.fetch does the /api-first probing + X-API-Key\n const comfy = ComfyTS.create()\n const apiKey = getFlag('api-key') ?? process.env.COMFY_CLOUD_API_KEY\n const host = comfy.host({ id, url: hostUrl, apiKey: apiKey ?? undefined })\n\n const fetchJSON = async <T>(route: string): Promise<T> => {\n console.log(`[comfy-ts gen] fetching ${hostUrl} ${route} …`)\n const res = await host.fetch(route)\n if (!res.ok) throw new Error(`GET ${route} failed on ${hostUrl}: ${res.status}`)\n if (!(res.headers.get('content-type') ?? '').includes('json'))\n throw new Error(`GET ${route} on ${hostUrl} did not answer json`)\n return (await res.json()) as T\n }\n\n const spec = await fetchJSON<ComfySchemaJSON>('/object_info')\n const embeddings = await fetchJSON<string[]>('/embeddings').catch(() => [] as string[])\n\n const dir = join(process.cwd(), '.comfy-ts', 'hosts', id)\n mkdirSync(dir, { recursive: true })\n writeFileSync(join(dir, 'object_info.json'), readableStringify(spec, 4), 'utf8')\n writeFileSync(join(dir, 'embeddings.json'), JSON.stringify(embeddings), 'utf8')\n\n const parsed = new ComfySchema({ spec, embeddings })\n const dts = parsed.codegenDTS({ hostId: id })\n // --out: explicit sdk home (the committed cloud catalog) — the json dumps\n // above still cache under .comfy-ts/hosts/<id>/, but the sdk must exist at\n // ONE tsconfig-visible path only, so it skips the hosts dir entirely\n const out = getFlag('out')\n const outPath = out != null ? resolve(process.cwd(), out) : join(dir, 'sdk.d.ts')\n if (out != null) mkdirSync(dirname(outPath), { recursive: true })\n writeFileSync(outPath, dts, 'utf8')\n console.log(`[comfy-ts gen] 🟢 ${outPath} (${parsed.nodes.length} nodes, ${(dts.length / 1024).toFixed(0)}kB)`)\n if (out == null)\n console.log(`[comfy-ts gen] add \".comfy-ts/hosts/**/sdk.d.ts\" to your tsconfig \"include\" to activate the types`)\n return 0\n}\n","// refresh the local mirror of what ComfyUI-Lora-Manager knows about a host's loras\nimport { readdirSync, rmdirSync } from 'node:fs'\nimport { join } from 'pathe'\nimport { flagReader } from 'src/cli/flags.ts'\nimport { buildLoraMirror, readLoraMirror, writeLoraMirror } from 'src/host/loraInfoCache.ts'\nimport { fetchLoraList, lmModelName, lmTrainedWords } from 'src/host/loraManagerApi.ts'\nimport { ComfyTS } from 'src/state.ts'\n\nconst DEFAULT_HOST_URL = 'http://127.0.0.1:8188'\n\n/** host ids already known on disk — `.comfy-ts/hosts/<id>/` is created by `comfy-ts gen` */\nfunction knownHostIds(): string[] {\n try {\n return readdirSync(join(process.cwd(), '.comfy-ts', 'hosts'), { withFileTypes: true })\n .filter((e) => e.isDirectory())\n .map((e) => e.name)\n .sort()\n } catch {\n return []\n }\n}\n\nexport async function runLoras(args: string[]): Promise<number> {\n const getFlag = flagReader(args)\n\n // --id: explicit, else the only host folder on disk (unambiguous), else loud\n const known = knownHostIds()\n const explicitId = getFlag('id')\n const id = explicitId ?? (known.length === 1 ? known[0] : null)\n if (id == null) {\n const hint =\n known.length === 0 ? 'none yet — run `comfy-ts gen --id <host-id> --host <url>` first' : known.join(', ')\n console.error(`[comfy-ts loras] 🔴 --id <host-id> is required (known: ${hint})`)\n return 1\n }\n // registering a host MKDIRS .comfy-ts/hosts/<id>/, so a typo used to leave a\n // junk folder that broke the `--id` default (and outline's) for good. Rather\n // than refuse unknown ids — `loras` has no real dependency on `gen` — remember\n // whether the folder pre-existed and take it back if the sweep fails.\n const hostDirExisted = known.includes(id)\n\n // ComfyTS FIRST: every .comfy-ts path, the mirror's included, resolves through the global\n const comfy = ComfyTS.create()\n\n // --host: explicit, else the url the last sync remembered for this id\n const previous = readLoraMirror(id)\n const hostUrl = getFlag('host') ?? (previous?.hostUrl !== '' ? previous?.hostUrl : null) ?? DEFAULT_HOST_URL\n\n const apiKey = getFlag('api-key') ?? process.env.COMFY_CLOUD_API_KEY\n const host = comfy.host({ id, url: hostUrl, apiKey: apiKey ?? undefined })\n\n /** a sweep that never produced a mirror must leave no trace of this run */\n const abandon = (): void => {\n if (hostDirExisted) return\n const dir = join(process.cwd(), '.comfy-ts', 'hosts', id)\n try {\n if (readdirSync(dir).length === 0) rmdirSync(dir)\n } catch {\n // best effort: a non-empty or vanished dir is not this command's business\n }\n }\n\n console.log(`[comfy-ts loras] sweeping ${hostUrl} /api/lm/loras/list …`)\n const sweep = await fetchLoraList(host)\n if (sweep.status === 'absent') {\n console.error(\n `[comfy-ts loras] 🔴 ${hostUrl} has no ComfyUI-Lora-Manager: the extension is not installed there. Mirror left untouched.`,\n )\n abandon()\n return 1\n }\n if (sweep.status === 'unreachable') {\n console.error(`[comfy-ts loras] 🔴 ${hostUrl} unreachable — ${sweep.reason}. Mirror left untouched.`)\n abandon()\n return 1\n }\n if (sweep.status === 'partial') {\n // writing this would DELETE loras from the mirror that are alive on the\n // host, and every surface would then quietly not know them\n console.error(\n `[comfy-ts loras] 🔴 the sweep broke off after ${sweep.items.length} loras (${sweep.reason}). Writing that would drop every lora past it, so the mirror is left untouched. Re-run when the host is healthy.`,\n )\n abandon()\n return 1\n }\n\n const mirror = buildLoraMirror({ hostId: id, hostUrl, fetchedAt: new Date().toISOString(), items: sweep.items })\n const path = writeLoraMirror(mirror)\n\n // what actually moved since the last sync — the whole point of running it again\n const before = previous?.loras ?? {}\n const added: string[] = []\n const changed: string[] = []\n let withWords = 0\n for (const [key, item] of Object.entries(mirror.loras)) {\n const words = lmTrainedWords(item)\n if (words.length > 0) withWords++\n const old = before[key]\n if (old == null) {\n if (words.length > 0) added.push(`${key} → ${words.join(', ')}`)\n else added.push(key)\n } else if (lmTrainedWords(old).join('\\0') !== words.join('\\0')) {\n changed.push(`${key} → ${words.length === 0 ? '(cleared)' : words.join(', ')}`)\n }\n }\n const removed = Object.keys(before).filter((k) => mirror.loras[k] == null)\n\n const sample = (label: string, lines: string[]): void => {\n if (lines.length === 0) return\n console.log(`[comfy-ts loras] ${label} (${lines.length}):`)\n for (const line of lines.slice(0, 10)) console.log(` ${line}`)\n if (lines.length > 10) console.log(` … +${lines.length - 10} more`)\n }\n sample('added', added)\n sample('trigger words changed', changed)\n sample('gone from the host', removed)\n\n const named = Object.values(mirror.loras).filter((i) => lmModelName(i) != null).length\n console.log(\n `[comfy-ts loras] 🟢 ${path} — ${mirror.count} loras, ${withWords} with trigger words, ${named} with a model name`,\n )\n if (previous == null) console.log(`[comfy-ts loras] next time: \\`comfy-ts loras --id ${id}\\` (url remembered)`)\n return 0\n}\n","// outline a generated sdk.d.ts without reading 2MB blind\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'pathe'\n\ntype Section = { name: string; kind: string; start: number; end: number; depth: number }\n\nfunction findDefaultSdk(): string | null {\n const hostsDir = join(process.cwd(), '.comfy-ts', 'hosts')\n if (!existsSync(hostsDir)) return null\n for (const id of readdirSync(hostsDir)) {\n const p = join(hostsDir, id, 'sdk.d.ts')\n if (existsSync(p)) return p\n }\n return null\n}\n\nexport function runOutline(args: string[]): number {\n const linesFlagIx = args.indexOf('--lines')\n const maxLines = linesFlagIx >= 0 ? Number(args[linesFlagIx + 1] ?? 10) : null\n const sectionFlagIx = args.indexOf('--section')\n const wantedSection = sectionFlagIx >= 0 ? args[sectionFlagIx + 1] : null\n const flagValueIxs = new Set([linesFlagIx + 1, sectionFlagIx + 1].filter((ix) => ix > 0))\n const fileArg = args.find((a, ix) => !a.startsWith('--') && !flagValueIxs.has(ix))\n\n const file = fileArg ?? findDefaultSdk()\n if (file == null || !existsSync(file)) {\n console.error('[sdk-outline] 🔴 no sdk.d.ts found; pass a path explicitly')\n return 1\n }\n\n const lines = readFileSync(file, 'utf8').split('\\n')\n\n // scan: track brace depth, record interface/type/namespace declarations up to depth 3\n const sections: Section[] = []\n const stack: Section[] = []\n let depth = 0\n const declRe = /^\\s*(?:export\\s+)?(interface|namespace|type)\\s+([A-Za-z0-9_$]+)/\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] ?? ''\n const m = depth <= 3 ? declRe.exec(line) : null\n const opens = (line.match(/{/g) ?? []).length\n const closes = (line.match(/}/g) ?? []).length\n if (m && (opens > 0 || m[1] === 'type')) {\n const sec: Section = { name: m[2] ?? '?', kind: m[1] ?? '?', start: i + 1, end: i + 1, depth }\n sections.push(sec)\n if (opens > closes) stack.push(sec)\n }\n depth += opens - closes\n while (stack.length > 0 && depth <= (stack[stack.length - 1]?.depth ?? 0)) {\n const closed = stack.pop()\n if (closed) closed.end = i + 1\n }\n // type aliases (no braces): extend until next decl at same depth\n const last = sections[sections.length - 1]\n if (last && last.kind === 'type' && stack[stack.length - 1] !== last) last.end = Math.max(last.end, i)\n }\n\n if (wantedSection) {\n const sec = sections.find((s) => s.name === wantedSection)\n if (sec == null) {\n console.error(\n `[sdk-outline] 🔴 section \"${wantedSection}\" not found. Available: ${sections.map((s) => s.name).join(', ')}`,\n )\n return 1\n }\n const body = lines.slice(sec.start - 1, maxLines ? Math.min(sec.end, sec.start - 1 + maxLines) : sec.end)\n console.log(body.join('\\n'))\n if (maxLines && sec.end - sec.start + 1 > maxLines)\n console.log(`… (${sec.end - sec.start + 1 - maxLines} more lines, ends at line ${sec.end})`)\n } else {\n console.log(`${file} — ${lines.length} lines\\n`)\n for (const s of sections) {\n const indent = ' '.repeat(s.depth)\n console.log(`${indent}${s.kind} ${s.name} [${s.start}-${s.end}] (${s.end - s.start + 1} lines)`)\n if (maxLines) {\n const body = lines.slice(s.start - 1, s.start - 1 + maxLines)\n console.log(body.map((l) => `${indent} │ ${l.trim()}`).join('\\n'))\n }\n }\n }\n return 0\n}\n","#!/usr/bin/env node\n// sidekick CLI: `bunx comfy-ts <command>` — codegen without writing any code\nimport { spawnSync } from 'node:child_process'\nimport { fileURLToPath } from 'node:url'\nimport { runGen } from 'src/cli/gen.ts'\nimport { runLoras } from 'src/cli/loras.ts'\nimport { runOutline } from 'src/cli/outline.ts'\n\nconst HELP = `comfy-ts — typed SDK codegen for ComfyUI\n\nUsage:\n comfy-ts gen --id <host-id> [--host http://127.0.0.1:8188] [--api-key <key>] [--out <sdk-path>]\n fetch object_info + embeddings from a live ComfyUI host and write\n .comfy-ts/hosts/<host-id>/{object_info.json,embeddings.json,sdk.d.ts}\n (--api-key or COMFY_CLOUD_API_KEY authenticates via X-API-Key;\n --out relocates ONLY the sdk.d.ts, e.g. a committed cloud catalog)\n\n comfy-ts outline [file] [--lines N] [--section Name]\n outline a generated sdk.d.ts (defaults to the first one in .comfy-ts/hosts/)\n\n comfy-ts loras [--id <host-id>] [--host http://…] [--api-key <key>]\n mirror what the optional ComfyUI-Lora-Manager extension knows about\n every lora into .comfy-ts/hosts/<id>/loras.json: real model names,\n civitai trigger words, tags, base model, preview urls. The TUI then\n fuzzy-matches loras by their human name and auto-injects their trigger\n words into v.prompt (⌃K still overrides, per lora). --id defaults to\n the only host folder on disk, --host to the url the last sync used\n\n comfy-ts tui [dir | workflow-module.ts]\n interactive tweak & re-run over **/*.cflow.ts modules (exporting\n host.defineWorkflow(...)); no arg scans cwd + the examples bundled\n with comfy-ts, an explicit dir/file limits to it (file preselected)\n\n comfy-ts serve [dir | workflow-module.ts] [--port 8288] [--host 127.0.0.1]\n drafts as a local HTTP generation API: POST /generate/<module>/<draft>\n with { ...vars } overriding the draft's values (blocking; raw image\n bytes under Accept: image/*), GET /drafts self-describes every var,\n GET /outputs/... serves the results. Open / in a browser for the web\n panel. No bundled examples, no auth, and any origin may call it: use\n --host beyond localhost only on a network you trust.\n\n comfy-ts help\n`\n\nasync function main(): Promise<number> {\n const [cmd, ...rest] = process.argv.slice(2)\n if (cmd === 'gen') return runGen(rest)\n if (cmd === 'outline') return runOutline(rest)\n if (cmd === 'loras') return runLoras(rest)\n if (cmd === 'tui' || cmd === 'serve') {\n // .cflow.ts workflow modules need bun: node refuses to strip types under\n // node_modules, exactly where the packaged examples live — and the bin's\n // node shebang means `bunx comfy-ts tui|serve` lands here under NODE. Hop\n // to bun when we are not already in it; without bun, degrade loudly.\n if (process.versions.bun == null) {\n const self = fileURLToPath(import.meta.url)\n const res = spawnSync('bun', [self, cmd, ...rest], { stdio: 'inherit' })\n if (res.error == null) return res.status ?? 1\n console.error(\n `[comfy-ts ${cmd}] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`,\n )\n }\n if (cmd === 'serve') {\n const { runServe } = await import('src/cli/serve/run-serve.ts')\n return runServe(rest)\n }\n // lazy import: keeps ink/react out of the codegen paths\n const { runTui } = await import('src/cli/tui/run-tui.tsx')\n return runTui(rest)\n }\n console.log(HELP)\n return cmd == null || cmd === 'help' ? 0 : 1\n}\n\n// a thrown command (a flag with no value, an unreadable path) must print ONE\n// clear line and exit non-zero, never a raw unhandled-rejection stack\nprocess.exitCode = await main().catch((e: unknown) => {\n console.error(`[comfy-ts] 🔴 ${e instanceof Error ? e.message : String(e)}`)\n return 1\n})\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAgB,WAAW,MAAiD;CACzE,QAAQ,SAAgC;EACrC,MAAM,KAAK,KAAK,QAAQ,KAAK,MAAM;EACnC,IAAI,KAAK,GAAG,OAAO;EACnB,MAAM,QAAQ,KAAK,KAAK;EACxB,IAAI,SAAS,QAAQ,MAAM,WAAW,IAAI,GAAG,MAAM,IAAI,MAAM,KAAK,KAAK,eAAe;EACtF,OAAO;CACV;AACH;;;ACJA,eAAsB,OAAO,MAAiC;CAC3D,MAAM,UAAU,WAAW,IAAI;CAC/B,MAAM,UAAU,QAAQ,MAAM,KAAK;CACnC,MAAM,KAAK,QAAQ,IAAI;CACvB,IAAI,MAAM,MAAM;EACb,QAAQ,MAAM,+EAA+E;EAC7F,OAAO;CACV;CAGA,MAAM,QAAQ,QAAQ,OAAO;CAC7B,MAAM,SAAS,QAAQ,SAAS,KAAK,QAAQ,IAAI;CACjD,MAAM,OAAO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KnC,IAAI,QAAQ,SAAS,OAAO,MAAM;GAE/B,MAAM,MAAM,UAAU,OAAO;IADhB,cAAc,OAAO,KAAK,GACN;IAAG;IAAK,GAAG;GAAI,GAAG,EAAE,OAAO,UAAU,CAAC;GACvE,IAAI,IAAI,SAAS,MAAM,OAAO,IAAI,UAAU;GAC5C,QAAQ,MACL,aAAa,IAAI,mBAAmB,IAAI,MAAM,QAAQ,gJACzD;EACH;EACA,IAAI,QAAQ,SAAS;GAClB,MAAM,EAAE,aAAa,MAAM,OAAO;GAClC,OAAO,SAAS,IAAI;EACvB;EAEA,MAAM,EAAE,WAAW,MAAM,OAAO;EAChC,OAAO,OAAO,IAAI;CACrB;CACA,QAAQ,IAAI,IAAI;CAChB,OAAO,OAAO,QAAQ,QAAQ,SAAS,IAAI;AAC9C;AAIA,QAAQ,WAAW,MAAM,KAAK,CAAC,CAAC,OAAO,MAAe;CACnD,QAAQ,MAAM,iBAAiB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,GAAG;CAC3E,OAAO;AACV,CAAC"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli/bunHop.ts","../src/cli/flags.ts","../src/cli/gen.ts","../src/cli/loras.ts","../src/cli/outline.ts","../src/cli/comfy-ts-cli.ts"],"sourcesContent":["// `tui`, `serve` and `run` import .cflow.ts modules, which need bun: the bin's\n// node shebang re-execs the same command line through it. The wrapper is the pid\n// a terminal, a supervisor or an agent holds and stops, so the child must never\n// outlive it (agent/architecture.md item 10)\nimport { spawn } from 'node:child_process'\nimport { constants } from 'node:os'\n\nconst HOP_PARENT_ENV = 'COMFY_TS_HOP_PARENT'\nconst FORWARDED: NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGHUP']\n\n/** runs `bun <argv>` with the terminal inherited, forwarding the stop signals;\n * resolves the child's exit code, or `error` when bun cannot start */\nexport function hopToBun(argv: string[]): Promise<{ code: number } | { error: Error }> {\n return new Promise((resolve) => {\n const child = spawn('bun', argv, {\n stdio: 'inherit',\n env: { ...process.env, [HOP_PARENT_ENV]: String(process.pid) },\n })\n const forward = (signal: NodeJS.Signals): void => {\n child.kill(signal)\n }\n for (const signal of FORWARDED) process.on(signal, forward)\n const done = (r: { code: number } | { error: Error }): void => {\n for (const signal of FORWARDED) process.off(signal, forward)\n resolve(r)\n }\n child.once('error', (error) => done({ error }))\n child.once('exit', (code, signal) => {\n if (code != null) return done({ code })\n done({ code: signal == null ? 1 : 128 + (constants.signals[signal] ?? 0) })\n })\n })\n}\n\n/** in the bun child: exit once the process that started it is gone. A SIGKILL to\n * the wrapper reaches no handler, so the child polls its own ppid, which changes\n * (to 1, or a subreaper) when its parent dies. It watches the ppid it started\n * with, not the wrapper pid: a version manager shim may sit between the two */\nexport function armHopChild(p: { intervalMs?: number } = {}): void {\n if (process.env[HOP_PARENT_ENV] == null) return\n // a grandchild has another parent: it must never inherit the watch\n Reflect.deleteProperty(process.env, HOP_PARENT_ENV)\n const parent = process.ppid\n setInterval(() => {\n if (process.ppid === parent) return\n console.error(`[comfy-ts] the process that started this one (pid ${parent}) is gone: exiting`)\n process.exit(1)\n }, p.intervalMs ?? 1000).unref()\n}\n","/**\n * the CLI's one flag reader: `--name value`.\n * A flag written with no value after it is a TYPO, never a request for the\n * default — silently falling back would run against the wrong host.\n */\nexport function flagReader(args: string[]): (name: string) => string | null {\n return (name: string): string | null => {\n const ix = args.indexOf(`--${name}`)\n if (ix < 0) return null\n const value = args[ix + 1]\n if (value == null || value.startsWith('--')) throw new Error(`--${name} needs a value`)\n return value\n }\n}\n","// fetch a live host's schema and generate its typed sdk\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, join, resolve } from 'pathe'\nimport { flagReader } from 'src/cli/flags.ts'\nimport { ComfySchema } from 'src/sdk-generator/ComfySchema.ts'\nimport type { ComfySchemaJSON } from 'src/sdk-generator/ComfyUIObjectInfoTypes.ts'\nimport { ComfyTS } from 'src/state.ts'\nimport { readableStringify } from 'src/utils/stringifyReadable.ts'\n\nexport async function runGen(args: string[]): Promise<number> {\n const getFlag = flagReader(args)\n const hostUrl = getFlag('host') ?? 'http://127.0.0.1:8188'\n const id = getFlag('id')\n if (id == null) {\n console.error('[comfy-ts gen] 🔴 --id <host-id> is required (it names .comfy-ts/hosts/<id>/)')\n return 1\n }\n\n // the lib's own authed host.fetch does the /api-first probing + X-API-Key\n const comfy = ComfyTS.create()\n const apiKey = getFlag('api-key') ?? process.env.COMFY_CLOUD_API_KEY\n const host = comfy.host({ id, url: hostUrl, apiKey: apiKey ?? undefined })\n\n const fetchJSON = async <T>(route: string): Promise<T> => {\n console.log(`[comfy-ts gen] fetching ${hostUrl} ${route} …`)\n const res = await host.fetch(route)\n if (!res.ok) throw new Error(`GET ${route} failed on ${hostUrl}: ${res.status}`)\n if (!(res.headers.get('content-type') ?? '').includes('json'))\n throw new Error(`GET ${route} on ${hostUrl} did not answer json`)\n return (await res.json()) as T\n }\n\n const spec = await fetchJSON<ComfySchemaJSON>('/object_info')\n const embeddings = await fetchJSON<string[]>('/embeddings').catch(() => [] as string[])\n\n const dir = join(process.cwd(), '.comfy-ts', 'hosts', id)\n mkdirSync(dir, { recursive: true })\n writeFileSync(join(dir, 'object_info.json'), readableStringify(spec, 4), 'utf8')\n writeFileSync(join(dir, 'embeddings.json'), JSON.stringify(embeddings), 'utf8')\n\n const parsed = new ComfySchema({ spec, embeddings })\n const dts = parsed.codegenDTS({ hostId: id })\n // --out: explicit sdk home (the committed cloud catalog) — the json dumps\n // above still cache under .comfy-ts/hosts/<id>/, but the sdk must exist at\n // ONE tsconfig-visible path only, so it skips the hosts dir entirely\n const out = getFlag('out')\n const outPath = out != null ? resolve(process.cwd(), out) : join(dir, 'sdk.d.ts')\n if (out != null) mkdirSync(dirname(outPath), { recursive: true })\n writeFileSync(outPath, dts, 'utf8')\n console.log(`[comfy-ts gen] 🟢 ${outPath} (${parsed.nodes.length} nodes, ${(dts.length / 1024).toFixed(0)}kB)`)\n if (out == null)\n console.log(`[comfy-ts gen] add \".comfy-ts/hosts/**/sdk.d.ts\" to your tsconfig \"include\" to activate the types`)\n return 0\n}\n","// refresh the local mirror of what ComfyUI-Lora-Manager knows about a host's loras\nimport { readdirSync, rmdirSync } from 'node:fs'\nimport { join } from 'pathe'\nimport { flagReader } from 'src/cli/flags.ts'\nimport { buildLoraMirror, readLoraMirror, writeLoraMirror } from 'src/host/loraInfoCache.ts'\nimport { fetchLoraList, lmModelName, lmTrainedWords } from 'src/host/loraManagerApi.ts'\nimport { ComfyTS } from 'src/state.ts'\n\nconst DEFAULT_HOST_URL = 'http://127.0.0.1:8188'\n\n/** host ids already known on disk — `.comfy-ts/hosts/<id>/` is created by `comfy-ts gen` */\nfunction knownHostIds(): string[] {\n try {\n return readdirSync(join(process.cwd(), '.comfy-ts', 'hosts'), { withFileTypes: true })\n .filter((e) => e.isDirectory())\n .map((e) => e.name)\n .sort()\n } catch {\n return []\n }\n}\n\nexport async function runLoras(args: string[]): Promise<number> {\n const getFlag = flagReader(args)\n\n // --id: explicit, else the only host folder on disk (unambiguous), else loud\n const known = knownHostIds()\n const explicitId = getFlag('id')\n const id = explicitId ?? (known.length === 1 ? known[0] : null)\n if (id == null) {\n const hint =\n known.length === 0 ? 'none yet — run `comfy-ts gen --id <host-id> --host <url>` first' : known.join(', ')\n console.error(`[comfy-ts loras] 🔴 --id <host-id> is required (known: ${hint})`)\n return 1\n }\n // registering a host MKDIRS .comfy-ts/hosts/<id>/, so a typo used to leave a\n // junk folder that broke the `--id` default (and outline's) for good. Rather\n // than refuse unknown ids — `loras` has no real dependency on `gen` — remember\n // whether the folder pre-existed and take it back if the sweep fails.\n const hostDirExisted = known.includes(id)\n\n // ComfyTS FIRST: every .comfy-ts path, the mirror's included, resolves through the global\n const comfy = ComfyTS.create()\n\n // --host: explicit, else the url the last sync remembered for this id\n const previous = readLoraMirror(id)\n const hostUrl = getFlag('host') ?? (previous?.hostUrl !== '' ? previous?.hostUrl : null) ?? DEFAULT_HOST_URL\n\n const apiKey = getFlag('api-key') ?? process.env.COMFY_CLOUD_API_KEY\n const host = comfy.host({ id, url: hostUrl, apiKey: apiKey ?? undefined })\n\n /** a sweep that never produced a mirror must leave no trace of this run */\n const abandon = (): void => {\n if (hostDirExisted) return\n const dir = join(process.cwd(), '.comfy-ts', 'hosts', id)\n try {\n if (readdirSync(dir).length === 0) rmdirSync(dir)\n } catch {\n // best effort: a non-empty or vanished dir is not this command's business\n }\n }\n\n console.log(`[comfy-ts loras] sweeping ${hostUrl} /api/lm/loras/list …`)\n const sweep = await fetchLoraList(host)\n if (sweep.status === 'absent') {\n console.error(\n `[comfy-ts loras] 🔴 ${hostUrl} has no ComfyUI-Lora-Manager: the extension is not installed there. Mirror left untouched.`,\n )\n abandon()\n return 1\n }\n if (sweep.status === 'unreachable') {\n console.error(`[comfy-ts loras] 🔴 ${hostUrl} unreachable — ${sweep.reason}. Mirror left untouched.`)\n abandon()\n return 1\n }\n if (sweep.status === 'partial') {\n // writing this would DELETE loras from the mirror that are alive on the\n // host, and every surface would then quietly not know them\n console.error(\n `[comfy-ts loras] 🔴 the sweep broke off after ${sweep.items.length} loras (${sweep.reason}). Writing that would drop every lora past it, so the mirror is left untouched. Re-run when the host is healthy.`,\n )\n abandon()\n return 1\n }\n\n const mirror = buildLoraMirror({ hostId: id, hostUrl, fetchedAt: new Date().toISOString(), items: sweep.items })\n const path = writeLoraMirror(mirror)\n\n // what actually moved since the last sync — the whole point of running it again\n const before = previous?.loras ?? {}\n const added: string[] = []\n const changed: string[] = []\n let withWords = 0\n for (const [key, item] of Object.entries(mirror.loras)) {\n const words = lmTrainedWords(item)\n if (words.length > 0) withWords++\n const old = before[key]\n if (old == null) {\n if (words.length > 0) added.push(`${key} → ${words.join(', ')}`)\n else added.push(key)\n } else if (lmTrainedWords(old).join('\\0') !== words.join('\\0')) {\n changed.push(`${key} → ${words.length === 0 ? '(cleared)' : words.join(', ')}`)\n }\n }\n const removed = Object.keys(before).filter((k) => mirror.loras[k] == null)\n\n const sample = (label: string, lines: string[]): void => {\n if (lines.length === 0) return\n console.log(`[comfy-ts loras] ${label} (${lines.length}):`)\n for (const line of lines.slice(0, 10)) console.log(` ${line}`)\n if (lines.length > 10) console.log(` … +${lines.length - 10} more`)\n }\n sample('added', added)\n sample('trigger words changed', changed)\n sample('gone from the host', removed)\n\n const named = Object.values(mirror.loras).filter((i) => lmModelName(i) != null).length\n console.log(\n `[comfy-ts loras] 🟢 ${path} — ${mirror.count} loras, ${withWords} with trigger words, ${named} with a model name`,\n )\n if (previous == null) console.log(`[comfy-ts loras] next time: \\`comfy-ts loras --id ${id}\\` (url remembered)`)\n return 0\n}\n","// outline a generated sdk.d.ts without reading 2MB blind\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'pathe'\n\ntype Section = { name: string; kind: string; start: number; end: number; depth: number }\n\nfunction findDefaultSdk(): string | null {\n const hostsDir = join(process.cwd(), '.comfy-ts', 'hosts')\n if (!existsSync(hostsDir)) return null\n for (const id of readdirSync(hostsDir)) {\n const p = join(hostsDir, id, 'sdk.d.ts')\n if (existsSync(p)) return p\n }\n return null\n}\n\nexport function runOutline(args: string[]): number {\n const linesFlagIx = args.indexOf('--lines')\n const maxLines = linesFlagIx >= 0 ? Number(args[linesFlagIx + 1] ?? 10) : null\n const sectionFlagIx = args.indexOf('--section')\n const wantedSection = sectionFlagIx >= 0 ? args[sectionFlagIx + 1] : null\n const flagValueIxs = new Set([linesFlagIx + 1, sectionFlagIx + 1].filter((ix) => ix > 0))\n const fileArg = args.find((a, ix) => !a.startsWith('--') && !flagValueIxs.has(ix))\n\n const file = fileArg ?? findDefaultSdk()\n if (file == null || !existsSync(file)) {\n console.error('[sdk-outline] 🔴 no sdk.d.ts found; pass a path explicitly')\n return 1\n }\n\n const lines = readFileSync(file, 'utf8').split('\\n')\n\n // scan: track brace depth, record interface/type/namespace declarations up to depth 3\n const sections: Section[] = []\n const stack: Section[] = []\n let depth = 0\n const declRe = /^\\s*(?:export\\s+)?(interface|namespace|type)\\s+([A-Za-z0-9_$]+)/\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] ?? ''\n const m = depth <= 3 ? declRe.exec(line) : null\n const opens = (line.match(/{/g) ?? []).length\n const closes = (line.match(/}/g) ?? []).length\n if (m && (opens > 0 || m[1] === 'type')) {\n const sec: Section = { name: m[2] ?? '?', kind: m[1] ?? '?', start: i + 1, end: i + 1, depth }\n sections.push(sec)\n if (opens > closes) stack.push(sec)\n }\n depth += opens - closes\n while (stack.length > 0 && depth <= (stack[stack.length - 1]?.depth ?? 0)) {\n const closed = stack.pop()\n if (closed) closed.end = i + 1\n }\n // type aliases (no braces): extend until next decl at same depth\n const last = sections[sections.length - 1]\n if (last && last.kind === 'type' && stack[stack.length - 1] !== last) last.end = Math.max(last.end, i)\n }\n\n if (wantedSection) {\n const sec = sections.find((s) => s.name === wantedSection)\n if (sec == null) {\n console.error(\n `[sdk-outline] 🔴 section \"${wantedSection}\" not found. Available: ${sections.map((s) => s.name).join(', ')}`,\n )\n return 1\n }\n const body = lines.slice(sec.start - 1, maxLines ? Math.min(sec.end, sec.start - 1 + maxLines) : sec.end)\n console.log(body.join('\\n'))\n if (maxLines && sec.end - sec.start + 1 > maxLines)\n console.log(`… (${sec.end - sec.start + 1 - maxLines} more lines, ends at line ${sec.end})`)\n } else {\n console.log(`${file} — ${lines.length} lines\\n`)\n for (const s of sections) {\n const indent = ' '.repeat(s.depth)\n console.log(`${indent}${s.kind} ${s.name} [${s.start}-${s.end}] (${s.end - s.start + 1} lines)`)\n if (maxLines) {\n const body = lines.slice(s.start - 1, s.start - 1 + maxLines)\n console.log(body.map((l) => `${indent} │ ${l.trim()}`).join('\\n'))\n }\n }\n }\n return 0\n}\n","#!/usr/bin/env node\n// sidekick CLI: `bunx comfy-ts <command>` — codegen without writing any code\nimport { armHopChild, hopToBun } from 'src/cli/bunHop.ts'\nimport { fileURLToPath } from 'node:url'\nimport { runGen } from 'src/cli/gen.ts'\nimport { runLoras } from 'src/cli/loras.ts'\nimport { runOutline } from 'src/cli/outline.ts'\n\nconst HELP = `comfy-ts — typed SDK codegen for ComfyUI\n\nUsage:\n comfy-ts gen --id <host-id> [--host http://127.0.0.1:8188] [--api-key <key>] [--out <sdk-path>]\n fetch object_info + embeddings from a live ComfyUI host and write\n .comfy-ts/hosts/<host-id>/{object_info.json,embeddings.json,sdk.d.ts}\n (--api-key or COMFY_CLOUD_API_KEY authenticates via X-API-Key;\n --out relocates ONLY the sdk.d.ts, e.g. a committed cloud catalog)\n\n comfy-ts outline [file] [--lines N] [--section Name]\n outline a generated sdk.d.ts (defaults to the first one in .comfy-ts/hosts/)\n\n comfy-ts loras [--id <host-id>] [--host http://…] [--api-key <key>]\n mirror what the optional ComfyUI-Lora-Manager extension knows about\n every lora into .comfy-ts/hosts/<id>/loras.json: real model names,\n civitai trigger words, tags, base model, preview urls. The TUI then\n fuzzy-matches loras by their human name and auto-injects their trigger\n words into v.prompt (⌃K still overrides, per lora). --id defaults to\n the only host folder on disk, --host to the url the last sync used\n\n comfy-ts tui [dir | workflow-module.ts]\n interactive tweak & re-run over **/*.cflow.ts modules (exporting\n host.defineWorkflow(...)); no arg scans cwd + the examples bundled\n with comfy-ts, an explicit dir/file limits to it (file preselected)\n\n comfy-ts serve [dir | workflow-module.ts] [--port 8288] [--host 127.0.0.1]\n drafts as a local HTTP generation API: POST /generate/<module>/<draft>\n with { ...vars } overriding the draft's values (blocking; raw image\n bytes under Accept: image/*), GET /drafts self-describes every var,\n GET /outputs/... serves the results. Open / in a browser for the web\n panel. No bundled examples, no auth, and any origin may call it: use\n --host beyond localhost only on a network you trust.\n\n comfy-ts run <name | module.cflow.ts> [--draft <name>] [--<var> <value>…] [--out <path>] [--json]\n ONE generation, headless, with live progress: the module is found in cwd,\n then in the examples bundled with comfy-ts, by its key (10-anima-t2i), its\n key without the number (anima-t2i) or a unique part (anima). Each var is a\n flag (--prompt \"…\" --seed 7 --image in.png), --<var>-file reads a text var\n from a file, --out writes the output there (several: a-1.png, a-2.png; a\n dir keeps the server's names). \\`comfy-ts run <name> --help\\` lists the vars,\n \\`comfy-ts run\\` lists the modules. --json prints one line with the paths\n\n comfy-ts help\n`\n\nasync function main(): Promise<number> {\n const [cmd, ...rest] = process.argv.slice(2)\n if (cmd === 'gen') return runGen(rest)\n if (cmd === 'outline') return runOutline(rest)\n if (cmd === 'loras') return runLoras(rest)\n if (cmd === 'tui' || cmd === 'serve' || cmd === 'run') {\n // .cflow.ts workflow modules need bun: node refuses to strip types under\n // node_modules, exactly where the packaged examples live — and the bin's\n // node shebang means `bunx comfy-ts tui|serve` lands here under NODE. Hop\n // to bun when we are not already in it; without bun, degrade loudly.\n if (process.versions.bun == null) {\n const res = await hopToBun([fileURLToPath(import.meta.url), cmd, ...rest])\n if ('code' in res) return res.code\n console.error(\n `[comfy-ts ${cmd}] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`,\n )\n }\n armHopChild()\n if (cmd === 'run') {\n const { runRun } = await import('src/cli/run/run-run.ts')\n return runRun(rest)\n }\n if (cmd === 'serve') {\n const { runServe } = await import('src/cli/serve/run-serve.ts')\n return runServe(rest)\n }\n // lazy import: keeps ink/react out of the codegen paths\n const { runTui } = await import('src/cli/tui/run-tui.tsx')\n return runTui(rest)\n }\n console.log(HELP)\n return cmd == null || cmd === 'help' ? 0 : 1\n}\n\n// a thrown command (a flag with no value, an unreadable path) must print ONE\n// clear line and exit non-zero, never a raw unhandled-rejection stack\nprocess.exitCode = await main().catch((e: unknown) => {\n console.error(`[comfy-ts] 🔴 ${e instanceof Error ? e.message : String(e)}`)\n return 1\n})\n"],"mappings":";;;;;;;;;AAOA,MAAM,iBAAiB;AACvB,MAAM,YAA8B;CAAC;CAAU;CAAW;AAAQ;;;AAIlE,SAAgB,SAAS,MAA8D;CACpF,OAAO,IAAI,SAAS,YAAY;EAC7B,MAAM,QAAQ,MAAM,OAAO,MAAM;GAC9B,OAAO;GACP,KAAK;IAAE,GA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,GAAG,QAAQ,QAAQ,KAAK,MAAM,CAAC;CAC3C,IAAI,QAAQ,OAAO,OAAO,OAAO,IAAI;CACrC,IAAI,QAAQ,WAAW,OAAO,WAAW,IAAI;CAC7C,IAAI,QAAQ,SAAS,OAAO,SAAS,IAAI;CACzC,IAAI,QAAQ,SAAS,QAAQ,WAAW,QAAQ,OAAO;EAKpD,IAAI,QAAQ,SAAS,OAAO,MAAM;GAC/B,MAAM,MAAM,MAAM,SAAS;IAAC,cAAc,OAAO,KAAK,GAAG;IAAG;IAAK,GAAG;GAAI,CAAC;GACzE,IAAI,UAAU,KAAK,OAAO,IAAI;GAC9B,QAAQ,MACL,aAAa,IAAI,mBAAmB,IAAI,MAAM,QAAQ,gJACzD;EACH;EACA,YAAY;EACZ,IAAI,QAAQ,OAAO;GAChB,MAAM,EAAE,WAAW,MAAM,OAAO;GAChC,OAAO,OAAO,IAAI;EACrB;EACA,IAAI,QAAQ,SAAS;GAClB,MAAM,EAAE,aAAa,MAAM,OAAO;GAClC,OAAO,SAAS,IAAI;EACvB;EAEA,MAAM,EAAE,WAAW,MAAM,OAAO;EAChC,OAAO,OAAO,IAAI;CACrB;CACA,QAAQ,IAAI,IAAI;CAChB,OAAO,OAAO,QAAQ,QAAQ,SAAS,IAAI;AAC9C;AAIA,QAAQ,WAAW,MAAM,KAAK,CAAC,CAAC,OAAO,MAAe;CACnD,QAAQ,MAAM,iBAAiB,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,GAAG;CAC3E,OAAO;AACV,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { dirname, join } from "pathe";
4
+ //#region src/exampleAssets.ts
5
+ /**
6
+ * the examples/ folder shipped in the npm tarball, resolved from THIS module's
7
+ * own location (NEVER cwd): walking up to the nearest NAMED package.json finds
8
+ * <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from
9
+ * this repo's src/. Returns null when the examples are absent (a consumer may
10
+ * prune the folder) or when the nearest named package is not comfy-ts (the lib
11
+ * was inlined into someone else's bundle — its examples are not on disk); no
12
+ * package.json all the way up is a broken install and throws.
13
+ */
14
+ function bundledExamplesDir(moduleUrl = import.meta.url) {
15
+ let dir = dirname(fileURLToPath(moduleUrl));
16
+ let prev = "";
17
+ while (dir !== prev) {
18
+ const pkgPath = join(dir, "package.json");
19
+ if (existsSync(pkgPath)) {
20
+ let pkg = {};
21
+ try {
22
+ pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
23
+ } catch {}
24
+ if (pkg.name === "comfy-ts") {
25
+ const examples = join(dir, "examples");
26
+ return existsSync(examples) ? examples : null;
27
+ }
28
+ if (pkg.name != null) return null;
29
+ }
30
+ prev = dir;
31
+ dir = dirname(dir);
32
+ }
33
+ throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
34
+ }
35
+ //#endregion
36
+ export { bundledExamplesDir as t };
37
+
38
+ //# sourceMappingURL=exampleAssets-BfWzygoM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exampleAssets-BfWzygoM.js","names":[],"sources":["../src/exampleAssets.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { dirname, join } from 'pathe'\n\n/**\n * the examples/ folder shipped in the npm tarball, resolved from THIS module's\n * own location (NEVER cwd): walking up to the nearest NAMED package.json finds\n * <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from\n * this repo's src/. Returns null when the examples are absent (a consumer may\n * prune the folder) or when the nearest named package is not comfy-ts (the lib\n * was inlined into someone else's bundle — its examples are not on disk); no\n * package.json all the way up is a broken install and throws.\n */\nexport function bundledExamplesDir(moduleUrl: string = import.meta.url): string | null {\n let dir = dirname(fileURLToPath(moduleUrl))\n let prev = ''\n while (dir !== prev) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) {\n let pkg: { name?: string } = {}\n try {\n pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))\n } catch {\n // a malformed package.json on the walk (someone's broken fixture\n // dir) must not take the whole TUI down; treat as unnamed\n }\n if (pkg.name === 'comfy-ts') {\n const examples = join(dir, 'examples')\n return existsSync(examples) ? examples : null\n }\n if (pkg.name != null) return null\n }\n prev = dir\n dir = dirname(dir)\n }\n throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`)\n}\n\n/**\n * absolute path of a bundled `examples/images/` input image, e.g.\n * `exampleImagePath('bear_1024x1024.jpg')` — the out-of-the-box default for\n * i2i/i2v example image vars, valid from this repo AND from a consumer's\n * node_modules/comfy-ts/. Loud throw naming the path when the file is missing\n * or the package's examples/ folder was pruned.\n */\nexport function exampleImagePath(name: string): string {\n return bundledExampleFile('images', name)\n}\n\n/** the same for a bundled `examples/media/` audio or video file, e.g.\n * `exampleMediaPath('sine_440hz_3s.flac')` — the default of audio and video example vars */\nexport function exampleMediaPath(name: string): string {\n return bundledExampleFile('media', name)\n}\n\nfunction bundledExampleFile(folder: 'images' | 'media', name: string): string {\n const examples = bundledExamplesDir()\n if (examples == null) {\n throw new Error(\n `[comfy-ts] cannot resolve bundled example file '${name}': the package's examples/ folder is not on disk`,\n )\n }\n const abs = join(examples, folder, name)\n if (!existsSync(abs)) throw new Error(`[comfy-ts] bundled example file not found: ${abs}`)\n return abs\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,YAAoB,OAAO,KAAK,KAAoB;CACpF,IAAI,MAAM,QAAQ,cAAc,SAAS,CAAC;CAC1C,IAAI,OAAO;CACX,OAAO,QAAQ,MAAM;EAClB,MAAM,UAAU,KAAK,KAAK,cAAc;EACxC,IAAI,WAAW,OAAO,GAAG;GACtB,IAAI,MAAyB,CAAC;GAC9B,IAAI;IACD,MAAM,KAAK,MAAM,aAAa,SAAS,MAAM,CAAC;GACjD,QAAQ,CAGR;GACA,IAAI,IAAI,SAAS,YAAY;IAC1B,MAAM,WAAW,KAAK,KAAK,UAAU;IACrC,OAAO,WAAW,QAAQ,IAAI,WAAW;GAC5C;GACA,IAAI,IAAI,QAAQ,MAAM,OAAO;EAChC;EACA,OAAO;EACP,MAAM,QAAQ,GAAG;CACpB;CACA,MAAM,IAAI,MAAM,oDAAoD,cAAc,SAAS,GAAG;AACjG"}