comfy-ts 2.19.0 → 2.20.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.
- package/README.md +9 -4
- package/claude-code/skills/setup/SKILL.md +1 -1
- package/dist/{ServeApp-qXcQfdgT.js → ServeApp-B469W26E.js} +5 -5
- package/dist/{ServeApp-qXcQfdgT.js.map → ServeApp-B469W26E.js.map} +1 -1
- package/dist/cli.js +12 -8
- package/dist/cli.js.map +1 -1
- package/dist/{exampleAssets-CE4PUy3n.js → exampleAssets-8MycEthF.js} +141 -55
- package/dist/exampleAssets-8MycEthF.js.map +1 -0
- package/dist/{findDefinedWorkflow-0lG-VTEd.js → findDefinedWorkflow-B90-xFxX.js} +2 -2
- package/dist/{findDefinedWorkflow-0lG-VTEd.js.map → findDefinedWorkflow-B90-xFxX.js.map} +1 -1
- package/dist/index.cjs +87 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +87 -6
- package/dist/index.js.map +1 -1
- package/dist/{run-run-C_yXY0vl.js → run-run-BslhZ0Qm.js} +5 -5
- package/dist/{run-run-C_yXY0vl.js.map → run-run-BslhZ0Qm.js.map} +1 -1
- package/dist/{run-serve-DaXzoVTS.js → run-serve-CsEYPGm9.js} +4 -4
- package/dist/{run-serve-DaXzoVTS.js.map → run-serve-CsEYPGm9.js.map} +1 -1
- package/dist/{run-tui-B3dsftdB.js → run-tui-Cxa8ksav.js} +9 -14
- package/dist/run-tui-Cxa8ksav.js.map +1 -0
- package/dist/{schemaDrift-CbsABBuk.js → schemaDrift-DaWsE-mt.js} +15 -15
- package/dist/{schemaDrift-CbsABBuk.js.map → schemaDrift-DaWsE-mt.js.map} +1 -1
- package/dist/serve-web.js +28 -28
- package/dist/web.d.ts +12 -2
- package/dist/web.js +87 -6
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -1
- package/examples/rvion/01-txt2img.cflow.ts +1 -1
- package/examples/rvion/02-img2img-upload.cflow.ts +1 -1
- package/examples/rvion/03-export-workflow-json.cflow.ts +1 -1
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
- package/examples/rvion/06-qwen-image-edit.cflow.ts +1 -1
- package/examples/rvion/07-local-llm-text-gen.cflow.ts +1 -1
- package/examples/rvion/08-qwen-image-21-t2i.cflow.ts +1 -1
- package/examples/rvion/09-qwen-image-21-edit.cflow.ts +1 -1
- package/examples/rvion/10-anima-t2i.cflow.ts +1 -1
- package/examples/rvion/11-yue2-t2a.cflow.ts +1 -1
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +1 -1
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +1 -1
- package/examples/rvion/14-video-soundtrack.cflow.ts +1 -1
- package/examples/rvion/15-tts-voice-clone.cflow.ts +1 -1
- package/examples/rvion/16-tts-voice-design.cflow.ts +1 -1
- package/guide-for-agents.md +4 -4
- package/package.json +7 -6
- package/src/cli/comfy-ts-cli.ts +4 -2
- package/src/cli/gen.ts +6 -1
- package/src/cli/serve/ServeApp.ts +4 -4
- package/src/cli/serve/web/api.ts +1 -1
- package/src/cli/serve/web/state/RunSt.poll.test.ts +38 -0
- package/src/cli/serve/web/state/RunSt.ts +6 -2
- package/src/cli/tui/components/Header.tsx +1 -4
- package/src/cli/tui/components/HostPanel.tsx +1 -4
- package/src/cli/tui/state/HostSt.ts +2 -2
- package/src/host/ComfyHost.ts +37 -5
- package/src/host/hostFile.ts +57 -0
- package/src/state.ts +15 -9
- package/dist/exampleAssets-CE4PUy3n.js.map +0 -1
- package/dist/run-tui-B3dsftdB.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as readableStringify, c as writeHostFile, l as renderHttpBase, n as comfyTsPackageDir, r as ComfyTS, s as ComfySchema } from "./exampleAssets-8MycEthF.js";
|
|
3
|
+
import { D as readLoraMirror, F as fetchLoraList, H as lmModelName, K as lmTrainedWords, _ as buildLoraMirror, j as writeLoraMirror } from "./schemaDrift-DaWsE-mt.js";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { constants, homedir } from "node:os";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -96,10 +96,12 @@ async function runGen(args) {
|
|
|
96
96
|
};
|
|
97
97
|
const spec = await fetchJSON("/object_info");
|
|
98
98
|
const embeddings = await fetchJSON("/embeddings").catch(() => []);
|
|
99
|
-
const dir =
|
|
99
|
+
const dir = host.cacheFolder;
|
|
100
100
|
mkdirSync(dir, { recursive: true });
|
|
101
101
|
writeFileSync(join(dir, "object_info.json"), readableStringify(spec, 4), "utf8");
|
|
102
102
|
writeFileSync(join(dir, "embeddings.json"), JSON.stringify(embeddings), "utf8");
|
|
103
|
+
const hostFile = writeHostFile(comfy.storage, dir, { url: renderHttpBase(host.base) });
|
|
104
|
+
console.log(`[comfy-ts gen] 🟢 ${hostFile}: comfy.host({ id: '${id}' }) now finds this host`);
|
|
103
105
|
const parsed = new ComfySchema({
|
|
104
106
|
spec,
|
|
105
107
|
embeddings
|
|
@@ -487,8 +489,10 @@ const HELP = `comfy-ts — typed SDK codegen for ComfyUI
|
|
|
487
489
|
Usage:
|
|
488
490
|
comfy-ts gen --id <host-id> [--host http://127.0.0.1:8188] [--api-key <key>] [--out <sdk-path>]
|
|
489
491
|
fetch object_info + embeddings from a live ComfyUI host and write
|
|
490
|
-
.comfy-ts/hosts/<host-id>/{object_info.json,embeddings.json,sdk.d.ts}
|
|
491
|
-
(
|
|
492
|
+
.comfy-ts/hosts/<host-id>/{object_info.json,embeddings.json,sdk.d.ts,host.json}
|
|
493
|
+
(host.json saves the address: code then names the host by id alone,
|
|
494
|
+
comfy.host({ id: '<host-id>' }); the api key is never written;
|
|
495
|
+
--api-key or COMFY_CLOUD_API_KEY authenticates via X-API-Key;
|
|
492
496
|
--out relocates ONLY the sdk.d.ts, e.g. a committed cloud catalog)
|
|
493
497
|
|
|
494
498
|
comfy-ts outline [file] [--lines N] [--section Name]
|
|
@@ -550,14 +554,14 @@ async function main() {
|
|
|
550
554
|
}
|
|
551
555
|
armHopChild();
|
|
552
556
|
if (cmd === "run") {
|
|
553
|
-
const { runRun } = await import("./run-run-
|
|
557
|
+
const { runRun } = await import("./run-run-BslhZ0Qm.js");
|
|
554
558
|
return runRun(rest);
|
|
555
559
|
}
|
|
556
560
|
if (cmd === "serve") {
|
|
557
|
-
const { runServe } = await import("./run-serve-
|
|
561
|
+
const { runServe } = await import("./run-serve-CsEYPGm9.js");
|
|
558
562
|
return runServe(rest);
|
|
559
563
|
}
|
|
560
|
-
const { runTui } = await import("./run-tui-
|
|
564
|
+
const { runTui } = await import("./run-tui-Cxa8ksav.js");
|
|
561
565
|
return runTui(rest);
|
|
562
566
|
}
|
|
563
567
|
console.log(HELP);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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/skill.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","// `comfy-ts skill install`: copy the Claude Code skills of claude-code/skills/ into a skills folder.\n// the record file holds the hash of every file the install wrote: it is what tells an untouched\n// file (safe to update) from one the user edited (never overwritten without --force)\nimport { createHash } from 'node:crypto'\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, statSync, writeFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, relative, resolve } from 'pathe'\nimport { comfyTsPackageDir } from 'src/exampleAssets.ts'\n\nexport const SKILL_PREFIX = 'comfy-ts-'\nexport const SKILL_RECORD_FILE = '.comfy-ts-skills.json'\n\nexport const SKILL_USAGE = `comfy-ts skill install [--user | --dir <skills-dir>] [--force]\n copy the comfy-ts Claude Code skills into .claude/skills/ of the cwd (--user: your personal\n skills folder, --dir: that folder): /comfy-ts-guide, /comfy-ts-setup, /comfy-ts-workflow,\n /comfy-ts-convert, /comfy-ts-run. A rerun updates what it wrote; a file you edited is never\n overwritten without --force. The same skills ship as a Claude Code plugin:\n /plugin marketplace add rvion/comfy-ts, then /plugin install comfy-ts@comfy-ts`\n\nexport type SkillAction = 'created' | 'unchanged' | 'updated' | 'overwritten' | 'removed' | 'kept' | 'conflict'\nexport type SkillLine = { action: SkillAction; file: string }\nexport type SkillReport = { ok: boolean; lines: SkillLine[]; commands: string[] }\ntype SkillRecord = { version: string; files: Record<string, string> }\n\n/** claude-code/skills/ of the installed package, resolved from this module, never from the cwd */\nexport function skillSourceDir(): string {\n const pkgDir = comfyTsPackageDir(import.meta.url)\n if (pkgDir == null) throw new Error('cannot find the comfy-ts package this command runs from')\n const dir = join(pkgDir, 'claude-code', 'skills')\n if (!existsSync(dir)) throw new Error(`the comfy-ts package has no skills folder at ${dir}`)\n return dir\n}\n\nconst sha256 = (bytes: Buffer): string => createHash('sha256').update(bytes).digest('hex')\n\n/** every file under a skill folder, as paths relative to it */\nfunction filesUnder(dir: string, prefix = ''): string[] {\n const out: string[] = []\n for (const name of readdirSync(dir).sort()) {\n const abs = join(dir, name)\n if (statSync(abs).isDirectory()) out.push(...filesUnder(abs, `${prefix}${name}/`))\n else out.push(`${prefix}${name}`)\n }\n return out\n}\n\nfunction readRecord(path: string): SkillRecord | null {\n if (!existsSync(path)) return null\n let parsed: unknown\n try {\n parsed = JSON.parse(readFileSync(path, 'utf8'))\n } catch (e) {\n throw new Error(`${path} is not valid json (${e instanceof Error ? e.message : String(e)}): fix or delete it`, {\n cause: e,\n })\n }\n if (typeof parsed !== 'object' || parsed == null || !('files' in parsed)) {\n throw new Error(`${path} has no \"files\" map: fix or delete it`)\n }\n const files = parsed.files\n if (typeof files !== 'object' || files == null) throw new Error(`${path} has no \"files\" map: fix or delete it`)\n const out: Record<string, string> = {}\n for (const [k, v] of Object.entries(files)) if (typeof v === 'string') out[k] = v\n const version = 'version' in parsed && typeof parsed.version === 'string' ? parsed.version : ''\n return { version, files: out }\n}\n\nfunction packageVersion(pkgDir: string): string {\n const parsed: unknown = JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf8'))\n if (typeof parsed === 'object' && parsed != null && 'version' in parsed && typeof parsed.version === 'string') {\n return parsed.version\n }\n throw new Error(`${join(pkgDir, 'package.json')} has no version`)\n}\n\n/**\n * plan, then write only when nothing conflicts (or `force`): a conflict anywhere writes nothing,\n * so a refused install never leaves half an update behind\n */\nexport function installSkills(p: { from: string; to: string; force: boolean; version: string }): SkillReport {\n const recordPath = join(p.to, SKILL_RECORD_FILE)\n const record = readRecord(recordPath)\n const source = new Map<string, Buffer>()\n const commands: string[] = []\n for (const skill of readdirSync(p.from).sort()) {\n if (!statSync(join(p.from, skill)).isDirectory()) continue\n commands.push(`/${SKILL_PREFIX}${skill}`)\n for (const f of filesUnder(join(p.from, skill))) {\n source.set(`${SKILL_PREFIX}${skill}/${f}`, readFileSync(join(p.from, skill, f)))\n }\n }\n\n const lines: SkillLine[] = []\n const writes: string[] = []\n const removals: string[] = []\n for (const [rel, bytes] of source) {\n const abs = join(p.to, rel)\n if (!existsSync(abs)) {\n lines.push({ action: 'created', file: abs })\n writes.push(rel)\n continue\n }\n const onDisk = readFileSync(abs)\n if (onDisk.equals(bytes)) lines.push({ action: 'unchanged', file: abs })\n else if (record?.files[rel] === sha256(onDisk)) {\n lines.push({ action: 'updated', file: abs })\n writes.push(rel)\n } else if (p.force) {\n lines.push({ action: 'overwritten', file: abs })\n writes.push(rel)\n } else lines.push({ action: 'conflict', file: abs })\n }\n for (const [rel, hash] of Object.entries(record?.files ?? {})) {\n const abs = join(p.to, rel)\n if (source.has(rel) || !existsSync(abs)) continue\n if (sha256(readFileSync(abs)) === hash) {\n lines.push({ action: 'removed', file: abs })\n removals.push(rel)\n } else lines.push({ action: 'kept', file: abs })\n }\n\n if (lines.some((l) => l.action === 'conflict')) return { ok: false, lines, commands }\n\n for (const rel of writes) {\n const abs = join(p.to, rel)\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, source.get(rel) ?? Buffer.alloc(0))\n }\n for (const rel of removals) {\n const abs = join(p.to, rel)\n rmSync(abs)\n // the skill folder goes too once it is empty, so no dead slash command stays listed\n const dir = dirname(abs)\n if (readdirSync(dir).length === 0) rmdirSync(dir)\n }\n const files: Record<string, string> = {}\n for (const [rel, bytes] of source) files[rel] = sha256(bytes)\n mkdirSync(p.to, { recursive: true })\n writeFileSync(recordPath, `${JSON.stringify({ version: p.version, files }, null, 3)}\\n`)\n return { ok: true, lines, commands }\n}\n\nconst MARK: Record<SkillAction, string> = {\n created: '+',\n unchanged: '=',\n updated: '~',\n overwritten: '!',\n removed: '-',\n kept: '?',\n conflict: '✗',\n}\n\nexport function runSkill(\n args: string[],\n p: { cwd?: string; env?: Record<string, string | undefined>; log?: (line: string) => void } = {},\n): number {\n const log = p.log ?? console.log\n const cwd = p.cwd ?? process.cwd()\n const env = p.env ?? process.env\n const sub = args[0]\n const rest = args.slice(1)\n if (sub == null || sub === 'help' || sub === '--help' || rest.includes('--help')) {\n log(SKILL_USAGE)\n return 0\n }\n if (sub !== 'install') throw new Error(`unknown skill command \"${sub}\"\\n${SKILL_USAGE}`)\n\n let user = false\n let force = false\n let dir: string | null = null\n for (let i = 0; i < rest.length; i++) {\n const a = rest[i]\n if (a === '--user') user = true\n else if (a === '--force') force = true\n else if (a === '--dir') {\n const v = rest[++i]\n if (v == null || v.startsWith('--')) throw new Error('--dir needs a value')\n dir = v\n } else throw new Error(`unknown argument \"${a}\"\\n${SKILL_USAGE}`)\n }\n if (user && dir != null) throw new Error('--user and --dir name two targets: pass one')\n\n const configDir = env.CLAUDE_CONFIG_DIR ?? join(env.HOME ?? homedir(), '.claude')\n const to = dir != null ? resolve(cwd, dir) : user ? join(configDir, 'skills') : join(cwd, '.claude', 'skills')\n const from = skillSourceDir()\n const version = packageVersion(dirname(dirname(from)))\n const show = (abs: string): string => {\n const rel = relative(cwd, abs)\n return rel.startsWith('..') ? abs : rel\n }\n\n const report = installSkills({ from, to, force, version })\n log(`[comfy-ts skill] comfy-ts ${version} skills → ${show(to)}`)\n for (const l of report.lines) log(` ${MARK[l.action]} ${l.action.padEnd(11)} ${show(l.file)}`)\n if (!report.ok) {\n const n = report.lines.filter((l) => l.action === 'conflict').length\n log(\n `[comfy-ts skill] 🔴 ${n} file(s) changed since comfy-ts wrote them (✗ above): nothing was written. Keep your edits, or rerun with --force to overwrite them`,\n )\n return 1\n }\n const kept = report.lines.filter((l) => l.action === 'kept').length\n if (kept > 0) log(`[comfy-ts skill] ${kept} file(s) no longer shipped were kept because you edited them (? above)`)\n log(`[comfy-ts skill] 🟢 Claude Code commands: ${report.commands.join(' ')}`)\n log(`[comfy-ts skill] a session started before this skills folder existed needs /reload-skills`)\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'\nimport { runSkill } from 'src/cli/skill.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 skill install [--user | --dir <skills-dir>] [--force]\n copy the comfy-ts Claude Code skills into .claude/skills/ of the cwd\n (--user: your personal skills folder): /comfy-ts-guide, -setup,\n -workflow, -convert, -run. A file you edited is never overwritten\n without --force. \\`comfy-ts skill --help\\` says more\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 === 'skill') return runSkill(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,GAAG,QAAQ;KAA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,IAAI;CAC7C,IAAI,QAAQ,SAAS,OAAO,SAAS,IAAI;CACzC,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"}
|
|
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/skill.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 { writeHostFile } from 'src/host/hostFile.ts'\nimport { renderHttpBase } from 'src/host/hostUrl.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 = host.cacheFolder\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 // the address, so code names this host by id alone: comfy.host({ id })\n const hostFile = writeHostFile(comfy.storage, dir, { url: renderHttpBase(host.base) })\n console.log(`[comfy-ts gen] 🟢 ${hostFile}: comfy.host({ id: '${id}' }) now finds this host`)\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","// `comfy-ts skill install`: copy the Claude Code skills of claude-code/skills/ into a skills folder.\n// the record file holds the hash of every file the install wrote: it is what tells an untouched\n// file (safe to update) from one the user edited (never overwritten without --force)\nimport { createHash } from 'node:crypto'\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, statSync, writeFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, relative, resolve } from 'pathe'\nimport { comfyTsPackageDir } from 'src/exampleAssets.ts'\n\nexport const SKILL_PREFIX = 'comfy-ts-'\nexport const SKILL_RECORD_FILE = '.comfy-ts-skills.json'\n\nexport const SKILL_USAGE = `comfy-ts skill install [--user | --dir <skills-dir>] [--force]\n copy the comfy-ts Claude Code skills into .claude/skills/ of the cwd (--user: your personal\n skills folder, --dir: that folder): /comfy-ts-guide, /comfy-ts-setup, /comfy-ts-workflow,\n /comfy-ts-convert, /comfy-ts-run. A rerun updates what it wrote; a file you edited is never\n overwritten without --force. The same skills ship as a Claude Code plugin:\n /plugin marketplace add rvion/comfy-ts, then /plugin install comfy-ts@comfy-ts`\n\nexport type SkillAction = 'created' | 'unchanged' | 'updated' | 'overwritten' | 'removed' | 'kept' | 'conflict'\nexport type SkillLine = { action: SkillAction; file: string }\nexport type SkillReport = { ok: boolean; lines: SkillLine[]; commands: string[] }\ntype SkillRecord = { version: string; files: Record<string, string> }\n\n/** claude-code/skills/ of the installed package, resolved from this module, never from the cwd */\nexport function skillSourceDir(): string {\n const pkgDir = comfyTsPackageDir(import.meta.url)\n if (pkgDir == null) throw new Error('cannot find the comfy-ts package this command runs from')\n const dir = join(pkgDir, 'claude-code', 'skills')\n if (!existsSync(dir)) throw new Error(`the comfy-ts package has no skills folder at ${dir}`)\n return dir\n}\n\nconst sha256 = (bytes: Buffer): string => createHash('sha256').update(bytes).digest('hex')\n\n/** every file under a skill folder, as paths relative to it */\nfunction filesUnder(dir: string, prefix = ''): string[] {\n const out: string[] = []\n for (const name of readdirSync(dir).sort()) {\n const abs = join(dir, name)\n if (statSync(abs).isDirectory()) out.push(...filesUnder(abs, `${prefix}${name}/`))\n else out.push(`${prefix}${name}`)\n }\n return out\n}\n\nfunction readRecord(path: string): SkillRecord | null {\n if (!existsSync(path)) return null\n let parsed: unknown\n try {\n parsed = JSON.parse(readFileSync(path, 'utf8'))\n } catch (e) {\n throw new Error(`${path} is not valid json (${e instanceof Error ? e.message : String(e)}): fix or delete it`, {\n cause: e,\n })\n }\n if (typeof parsed !== 'object' || parsed == null || !('files' in parsed)) {\n throw new Error(`${path} has no \"files\" map: fix or delete it`)\n }\n const files = parsed.files\n if (typeof files !== 'object' || files == null) throw new Error(`${path} has no \"files\" map: fix or delete it`)\n const out: Record<string, string> = {}\n for (const [k, v] of Object.entries(files)) if (typeof v === 'string') out[k] = v\n const version = 'version' in parsed && typeof parsed.version === 'string' ? parsed.version : ''\n return { version, files: out }\n}\n\nfunction packageVersion(pkgDir: string): string {\n const parsed: unknown = JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf8'))\n if (typeof parsed === 'object' && parsed != null && 'version' in parsed && typeof parsed.version === 'string') {\n return parsed.version\n }\n throw new Error(`${join(pkgDir, 'package.json')} has no version`)\n}\n\n/**\n * plan, then write only when nothing conflicts (or `force`): a conflict anywhere writes nothing,\n * so a refused install never leaves half an update behind\n */\nexport function installSkills(p: { from: string; to: string; force: boolean; version: string }): SkillReport {\n const recordPath = join(p.to, SKILL_RECORD_FILE)\n const record = readRecord(recordPath)\n const source = new Map<string, Buffer>()\n const commands: string[] = []\n for (const skill of readdirSync(p.from).sort()) {\n if (!statSync(join(p.from, skill)).isDirectory()) continue\n commands.push(`/${SKILL_PREFIX}${skill}`)\n for (const f of filesUnder(join(p.from, skill))) {\n source.set(`${SKILL_PREFIX}${skill}/${f}`, readFileSync(join(p.from, skill, f)))\n }\n }\n\n const lines: SkillLine[] = []\n const writes: string[] = []\n const removals: string[] = []\n for (const [rel, bytes] of source) {\n const abs = join(p.to, rel)\n if (!existsSync(abs)) {\n lines.push({ action: 'created', file: abs })\n writes.push(rel)\n continue\n }\n const onDisk = readFileSync(abs)\n if (onDisk.equals(bytes)) lines.push({ action: 'unchanged', file: abs })\n else if (record?.files[rel] === sha256(onDisk)) {\n lines.push({ action: 'updated', file: abs })\n writes.push(rel)\n } else if (p.force) {\n lines.push({ action: 'overwritten', file: abs })\n writes.push(rel)\n } else lines.push({ action: 'conflict', file: abs })\n }\n for (const [rel, hash] of Object.entries(record?.files ?? {})) {\n const abs = join(p.to, rel)\n if (source.has(rel) || !existsSync(abs)) continue\n if (sha256(readFileSync(abs)) === hash) {\n lines.push({ action: 'removed', file: abs })\n removals.push(rel)\n } else lines.push({ action: 'kept', file: abs })\n }\n\n if (lines.some((l) => l.action === 'conflict')) return { ok: false, lines, commands }\n\n for (const rel of writes) {\n const abs = join(p.to, rel)\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, source.get(rel) ?? Buffer.alloc(0))\n }\n for (const rel of removals) {\n const abs = join(p.to, rel)\n rmSync(abs)\n // the skill folder goes too once it is empty, so no dead slash command stays listed\n const dir = dirname(abs)\n if (readdirSync(dir).length === 0) rmdirSync(dir)\n }\n const files: Record<string, string> = {}\n for (const [rel, bytes] of source) files[rel] = sha256(bytes)\n mkdirSync(p.to, { recursive: true })\n writeFileSync(recordPath, `${JSON.stringify({ version: p.version, files }, null, 3)}\\n`)\n return { ok: true, lines, commands }\n}\n\nconst MARK: Record<SkillAction, string> = {\n created: '+',\n unchanged: '=',\n updated: '~',\n overwritten: '!',\n removed: '-',\n kept: '?',\n conflict: '✗',\n}\n\nexport function runSkill(\n args: string[],\n p: { cwd?: string; env?: Record<string, string | undefined>; log?: (line: string) => void } = {},\n): number {\n const log = p.log ?? console.log\n const cwd = p.cwd ?? process.cwd()\n const env = p.env ?? process.env\n const sub = args[0]\n const rest = args.slice(1)\n if (sub == null || sub === 'help' || sub === '--help' || rest.includes('--help')) {\n log(SKILL_USAGE)\n return 0\n }\n if (sub !== 'install') throw new Error(`unknown skill command \"${sub}\"\\n${SKILL_USAGE}`)\n\n let user = false\n let force = false\n let dir: string | null = null\n for (let i = 0; i < rest.length; i++) {\n const a = rest[i]\n if (a === '--user') user = true\n else if (a === '--force') force = true\n else if (a === '--dir') {\n const v = rest[++i]\n if (v == null || v.startsWith('--')) throw new Error('--dir needs a value')\n dir = v\n } else throw new Error(`unknown argument \"${a}\"\\n${SKILL_USAGE}`)\n }\n if (user && dir != null) throw new Error('--user and --dir name two targets: pass one')\n\n const configDir = env.CLAUDE_CONFIG_DIR ?? join(env.HOME ?? homedir(), '.claude')\n const to = dir != null ? resolve(cwd, dir) : user ? join(configDir, 'skills') : join(cwd, '.claude', 'skills')\n const from = skillSourceDir()\n const version = packageVersion(dirname(dirname(from)))\n const show = (abs: string): string => {\n const rel = relative(cwd, abs)\n return rel.startsWith('..') ? abs : rel\n }\n\n const report = installSkills({ from, to, force, version })\n log(`[comfy-ts skill] comfy-ts ${version} skills → ${show(to)}`)\n for (const l of report.lines) log(` ${MARK[l.action]} ${l.action.padEnd(11)} ${show(l.file)}`)\n if (!report.ok) {\n const n = report.lines.filter((l) => l.action === 'conflict').length\n log(\n `[comfy-ts skill] 🔴 ${n} file(s) changed since comfy-ts wrote them (✗ above): nothing was written. Keep your edits, or rerun with --force to overwrite them`,\n )\n return 1\n }\n const kept = report.lines.filter((l) => l.action === 'kept').length\n if (kept > 0) log(`[comfy-ts skill] ${kept} file(s) no longer shipped were kept because you edited them (? above)`)\n log(`[comfy-ts skill] 🟢 Claude Code commands: ${report.commands.join(' ')}`)\n log(`[comfy-ts skill] a session started before this skills folder existed needs /reload-skills`)\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'\nimport { runSkill } from 'src/cli/skill.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,host.json}\n (host.json saves the address: code then names the host by id alone,\n comfy.host({ id: '<host-id>' }); the api key is never written;\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 skill install [--user | --dir <skills-dir>] [--force]\n copy the comfy-ts Claude Code skills into .claude/skills/ of the cwd\n (--user: your personal skills folder): /comfy-ts-guide, -setup,\n -workflow, -convert, -run. A file you edited is never overwritten\n without --force. \\`comfy-ts skill --help\\` says more\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 === 'skill') return runSkill(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,GAAG,QAAQ;KAAM,iBAAiB,OAAO,QAAQ,GAAG;GAAE;EAChE,CAAC;EACD,MAAM,WAAW,WAAiC;GAC/C,MAAM,KAAK,MAAM;EACpB;EACA,KAAK,MAAM,UAAU,WAAW,QAAQ,GAAG,QAAQ,OAAO;EAC1D,MAAM,QAAQ,MAAiD;GAC5D,KAAK,MAAM,UAAU,WAAW,QAAQ,IAAI,QAAQ,OAAO;GAC3D,QAAQ,CAAC;EACZ;EACA,MAAM,KAAK,UAAU,UAAU,KAAK,EAAE,MAAM,CAAC,CAAC;EAC9C,MAAM,KAAK,SAAS,MAAM,WAAW;GAClC,IAAI,QAAQ,MAAM,OAAO,KAAK,EAAE,KAAK,CAAC;GACtC,KAAK,EAAE,MAAM,UAAU,OAAO,IAAI,OAAO,UAAU,QAAQ,WAAW,GAAG,CAAC;EAC7E,CAAC;CACJ,CAAC;AACJ;;;;;AAMA,SAAgB,YAAY,IAA6B,CAAC,GAAS;CAChE,IAAI,QAAQ,IAAI,mBAAmB,MAAM;CAEzC,QAAQ,eAAe,QAAQ,KAAK,cAAc;CAClD,MAAM,SAAS,QAAQ;CACvB,kBAAkB;EACf,IAAI,QAAQ,SAAS,QAA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,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,10 +1,109 @@
|
|
|
1
|
-
import { X as ansi, a as DefinedWorkflow, at as
|
|
1
|
+
import { X as ansi, a as DefinedWorkflow, at as isRecord$1, ct as resolveComfyStorage, dt as logInfo, ft as logSuccess, ht as extractErrorMessage, it as hashArrayBuffer, lt as isQuiet, mt as sha1HexOfString, n as diffSchemas, nt as isVideoFilename, ot as bang, pt as statelessRegex, rt as mediaMime, st as getComfyStorage, t as MODEL_LISTS, ut as logError } from "./schemaDrift-DaWsE-mt.js";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, join } from "pathe";
|
|
5
5
|
import { scope, type } from "arktype";
|
|
6
6
|
import { nanoid } from "nanoid";
|
|
7
7
|
import { imageMeta } from "image-meta";
|
|
8
|
+
//#region src/host/hostUrl.ts
|
|
9
|
+
/** exactly ONE of `url` or the legacy `host`+`port` (+`https?`) spelling */
|
|
10
|
+
function parseHostBase(p) {
|
|
11
|
+
const hasLegacy = p.host != null || p.port != null || p.https != null;
|
|
12
|
+
if (p.url != null && hasLegacy) throw new Error(`host '${p.id}': give either url OR host/port/https, not both spellings at once`);
|
|
13
|
+
if (p.url == null) {
|
|
14
|
+
if (p.host == null || p.port == null) throw new Error(`host '${p.id}': needs either url, or host AND port (got host=${p.host}, port=${p.port})`);
|
|
15
|
+
return {
|
|
16
|
+
scheme: p.https ? "https" : "http",
|
|
17
|
+
host: p.host,
|
|
18
|
+
port: p.port,
|
|
19
|
+
basePath: ""
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
let parsed;
|
|
23
|
+
try {
|
|
24
|
+
parsed = new URL(p.url);
|
|
25
|
+
} catch {
|
|
26
|
+
throw new Error(`host '${p.id}': unparseable url '${p.url}'`);
|
|
27
|
+
}
|
|
28
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error(`host '${p.id}': url scheme must be http or https, got '${parsed.protocol}' in '${p.url}'`);
|
|
29
|
+
if (parsed.search !== "" || parsed.hash !== "") throw new Error(`host '${p.id}': url must be a plain base (no ?query or #hash), got '${p.url}'`);
|
|
30
|
+
const scheme = parsed.protocol === "https:" ? "https" : "http";
|
|
31
|
+
const port = parsed.port !== "" ? Number(parsed.port) : scheme === "https" ? 443 : 80;
|
|
32
|
+
const basePath = parsed.pathname.replace(/\/+$/, "");
|
|
33
|
+
return {
|
|
34
|
+
scheme,
|
|
35
|
+
host: parsed.hostname,
|
|
36
|
+
port,
|
|
37
|
+
basePath
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** http(s) base, port omitted when it is the scheme default */
|
|
41
|
+
function renderHttpBase(p) {
|
|
42
|
+
return `${p.scheme}://${p.host}${renderPort(p)}${p.basePath}`;
|
|
43
|
+
}
|
|
44
|
+
/** ws(s) endpoint; auth rides the upgrade headers — EXCEPT headerless
|
|
45
|
+
* transports (browser), where the ws client remaps X-API-Key to ?token= */
|
|
46
|
+
function renderWsUrl(p) {
|
|
47
|
+
return `${p.scheme === "https" ? "wss" : "ws"}://${p.host}${renderPort(p)}${p.basePath}/ws`;
|
|
48
|
+
}
|
|
49
|
+
function renderPort(p) {
|
|
50
|
+
const schemeDefault = p.scheme === "https" ? 443 : 80;
|
|
51
|
+
return p.port === schemeDefault ? "" : `:${p.port}`;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/host/hostFile.ts
|
|
55
|
+
const HOST_FILE_NAME = "host.json";
|
|
56
|
+
/** true when the caller gave no address at all: the id alone asks for the saved one */
|
|
57
|
+
function namesNoAddress(p) {
|
|
58
|
+
return p.url == null && p.host == null && p.port == null && p.https == null;
|
|
59
|
+
}
|
|
60
|
+
function hostFilePath(hostFolder) {
|
|
61
|
+
return join(hostFolder, HOST_FILE_NAME);
|
|
62
|
+
}
|
|
63
|
+
function writeHostFile(storage, hostFolder, file) {
|
|
64
|
+
const path = hostFilePath(hostFolder);
|
|
65
|
+
storage.writeText(path, `${JSON.stringify(file, null, 3)}\n`);
|
|
66
|
+
return path;
|
|
67
|
+
}
|
|
68
|
+
/** the saved address of `id`, parsed; when there is none, the error text names the command that writes it */
|
|
69
|
+
function readHostFile(storage, hostFolder, id) {
|
|
70
|
+
const path = hostFilePath(hostFolder);
|
|
71
|
+
const gen = `\`comfy-ts gen --host <url> --id ${id}\``;
|
|
72
|
+
const text = storage.readTextIfExists(path);
|
|
73
|
+
if (text == null) return {
|
|
74
|
+
base: null,
|
|
75
|
+
error: `host '${id}': no address given and no ${path}. ${storage.kind === "node" ? `run ${gen} once from this project (it saves the address), or pass the address: host({ id: '${id}', url: '<url>' })` : `this runtime has no saved hosts (${storage.kind} storage): pass the address, host({ id: '${id}', url: '<url>' })`}`
|
|
76
|
+
};
|
|
77
|
+
let json;
|
|
78
|
+
try {
|
|
79
|
+
json = JSON.parse(text);
|
|
80
|
+
} catch {
|
|
81
|
+
return {
|
|
82
|
+
base: null,
|
|
83
|
+
error: `host '${id}': ${path} is not valid json. Write it again with ${gen}`
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const url = json != null && typeof json === "object" && "url" in json ? json.url : null;
|
|
87
|
+
if (typeof url !== "string" || url === "") return {
|
|
88
|
+
base: null,
|
|
89
|
+
error: `host '${id}': ${path} has no "url" string. Write it again with ${gen}`
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
return {
|
|
93
|
+
base: parseHostBase({
|
|
94
|
+
id,
|
|
95
|
+
url
|
|
96
|
+
}),
|
|
97
|
+
error: null
|
|
98
|
+
};
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return {
|
|
101
|
+
base: null,
|
|
102
|
+
error: `${extractErrorMessage(e)} (read from ${path})`
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
8
107
|
//#region src/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.ts
|
|
9
108
|
/** having a bunch of sensible default will help slightly */
|
|
10
109
|
function getUnionNameBasedOnFirstFoundEnumName(enumName, hash, hashContent) {
|
|
@@ -904,7 +1003,7 @@ var ComfySchema = class {
|
|
|
904
1003
|
};
|
|
905
1004
|
//#endregion
|
|
906
1005
|
//#region package.json
|
|
907
|
-
var version = "2.
|
|
1006
|
+
var version = "2.20.1";
|
|
908
1007
|
//#endregion
|
|
909
1008
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
910
1009
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -4673,52 +4772,6 @@ var ComfyUploader = class {
|
|
|
4673
4772
|
}
|
|
4674
4773
|
};
|
|
4675
4774
|
//#endregion
|
|
4676
|
-
//#region src/host/hostUrl.ts
|
|
4677
|
-
/** exactly ONE of `url` or the legacy `host`+`port` (+`https?`) spelling */
|
|
4678
|
-
function parseHostBase(p) {
|
|
4679
|
-
const hasLegacy = p.host != null || p.port != null || p.https != null;
|
|
4680
|
-
if (p.url != null && hasLegacy) throw new Error(`host '${p.id}': give either url OR host/port/https, not both spellings at once`);
|
|
4681
|
-
if (p.url == null) {
|
|
4682
|
-
if (p.host == null || p.port == null) throw new Error(`host '${p.id}': needs either url, or host AND port (got host=${p.host}, port=${p.port})`);
|
|
4683
|
-
return {
|
|
4684
|
-
scheme: p.https ? "https" : "http",
|
|
4685
|
-
host: p.host,
|
|
4686
|
-
port: p.port,
|
|
4687
|
-
basePath: ""
|
|
4688
|
-
};
|
|
4689
|
-
}
|
|
4690
|
-
let parsed;
|
|
4691
|
-
try {
|
|
4692
|
-
parsed = new URL(p.url);
|
|
4693
|
-
} catch {
|
|
4694
|
-
throw new Error(`host '${p.id}': unparseable url '${p.url}'`);
|
|
4695
|
-
}
|
|
4696
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error(`host '${p.id}': url scheme must be http or https, got '${parsed.protocol}' in '${p.url}'`);
|
|
4697
|
-
if (parsed.search !== "" || parsed.hash !== "") throw new Error(`host '${p.id}': url must be a plain base (no ?query or #hash), got '${p.url}'`);
|
|
4698
|
-
const scheme = parsed.protocol === "https:" ? "https" : "http";
|
|
4699
|
-
const port = parsed.port !== "" ? Number(parsed.port) : scheme === "https" ? 443 : 80;
|
|
4700
|
-
const basePath = parsed.pathname.replace(/\/+$/, "");
|
|
4701
|
-
return {
|
|
4702
|
-
scheme,
|
|
4703
|
-
host: parsed.hostname,
|
|
4704
|
-
port,
|
|
4705
|
-
basePath
|
|
4706
|
-
};
|
|
4707
|
-
}
|
|
4708
|
-
/** http(s) base, port omitted when it is the scheme default */
|
|
4709
|
-
function renderHttpBase(p) {
|
|
4710
|
-
return `${p.scheme}://${p.host}${renderPort(p)}${p.basePath}`;
|
|
4711
|
-
}
|
|
4712
|
-
/** ws(s) endpoint; auth rides the upgrade headers — EXCEPT headerless
|
|
4713
|
-
* transports (browser), where the ws client remaps X-API-Key to ?token= */
|
|
4714
|
-
function renderWsUrl(p) {
|
|
4715
|
-
return `${p.scheme === "https" ? "wss" : "ws"}://${p.host}${renderPort(p)}${p.basePath}/ws`;
|
|
4716
|
-
}
|
|
4717
|
-
function renderPort(p) {
|
|
4718
|
-
const schemeDefault = p.scheme === "https" ? 443 : 80;
|
|
4719
|
-
return p.port === schemeDefault ? "" : `:${p.port}`;
|
|
4720
|
-
}
|
|
4721
|
-
//#endregion
|
|
4722
4775
|
//#region src/host/ResilientWebsocket.ts
|
|
4723
4776
|
let transportPromise = null;
|
|
4724
4777
|
/** node: the ws package (headers on the upgrade). browser: native WebSocket. */
|
|
@@ -4909,9 +4962,30 @@ var ComfyHostAuthError = class extends Error {
|
|
|
4909
4962
|
}
|
|
4910
4963
|
};
|
|
4911
4964
|
var ComfyHost = class {
|
|
4965
|
+
/** parsed ONCE from data (url-first, legacy host/port/https, or the address `gen` saved for
|
|
4966
|
+
* the id alone): the url ground truth. Throws the noAddress text when there is none */
|
|
4967
|
+
get base() {
|
|
4968
|
+
this.readSavedAddress();
|
|
4969
|
+
if (this._base == null) throw new Error(this.noAddress ?? `host '${this.data.id}': no address`);
|
|
4970
|
+
return this._base;
|
|
4971
|
+
}
|
|
4972
|
+
/** `host:port` for labels, or a short note when there is no address; never throws */
|
|
4973
|
+
get addressLabel() {
|
|
4974
|
+
return this._base == null ? "no saved address" : `${this._base.host}:${this._base.port}`;
|
|
4975
|
+
}
|
|
4976
|
+
/** read again at each use until found: a `comfy-ts gen` run after the import (a TUI or a
|
|
4977
|
+
* serve that stays up) makes the host usable without a restart */
|
|
4978
|
+
readSavedAddress() {
|
|
4979
|
+
if (this._base != null || !namesNoAddress(this.data)) return;
|
|
4980
|
+
const saved = readHostFile(getComfyStorage(), this.cacheFolder, this.data.id);
|
|
4981
|
+
this._base = saved.base;
|
|
4982
|
+
this.noAddress = saved.error;
|
|
4983
|
+
}
|
|
4912
4984
|
constructor(data) {
|
|
4913
4985
|
this.data = data;
|
|
4914
4986
|
this.uploader = new ComfyUploader(this);
|
|
4987
|
+
this._base = null;
|
|
4988
|
+
this.noAddress = null;
|
|
4915
4989
|
this.matchRequirements = (requirements) => this.manager.matchRequirements(requirements);
|
|
4916
4990
|
this.checkRequirements = (requirements) => this.manager.checkRequirements(requirements);
|
|
4917
4991
|
this.serverLogs = [];
|
|
@@ -5021,6 +5095,8 @@ var ComfyHost = class {
|
|
|
5021
5095
|
this._schemaStrategy = "auto";
|
|
5022
5096
|
this._schemaMaxAgeMs = 24 * 36e5;
|
|
5023
5097
|
this.connect = (p = {}) => {
|
|
5098
|
+
this.readSavedAddress();
|
|
5099
|
+
if (this.noAddress != null) return Promise.reject(new Error(this.noAddress));
|
|
5024
5100
|
if (this._ready == null) {
|
|
5025
5101
|
this._schemaStrategy = p.schema ?? "auto";
|
|
5026
5102
|
this._schemaMaxAgeMs = p.maxAgeMs ?? 24 * 36e5;
|
|
@@ -5116,6 +5192,10 @@ var ComfyHost = class {
|
|
|
5116
5192
|
};
|
|
5117
5193
|
this.checkSchemaDrift = async (p) => {
|
|
5118
5194
|
const loaded = this.schema.data.spec;
|
|
5195
|
+
if (Object.keys(loaded).length === 0) return {
|
|
5196
|
+
nodes: null,
|
|
5197
|
+
models: []
|
|
5198
|
+
};
|
|
5119
5199
|
const live = {};
|
|
5120
5200
|
if (p.full) Object.assign(live, await this.fetchJSON_("/object_info"));
|
|
5121
5201
|
else for (const m of MODEL_LISTS) if (loaded[m.node] != null) Object.assign(live, await this.fetchJSON_(`/object_info/${m.node}`));
|
|
@@ -5180,10 +5260,13 @@ var ComfyHost = class {
|
|
|
5180
5260
|
this._unknownWsEventTypes = /* @__PURE__ */ new Set();
|
|
5181
5261
|
this.status = null;
|
|
5182
5262
|
this.lastWsMessageAt = null;
|
|
5183
|
-
this.base = parseHostBase(this.data);
|
|
5184
5263
|
/** folder where file related to the host config will be cached */
|
|
5185
5264
|
this.cacheFolder = comfyts.resolveFromHosts(this.data.id);
|
|
5186
5265
|
const storage = getComfyStorage();
|
|
5266
|
+
if (namesNoAddress(this.data)) {
|
|
5267
|
+
this.readSavedAddress();
|
|
5268
|
+
if (this.noAddress != null) logError(this.noAddress);
|
|
5269
|
+
} else this._base = parseHostBase(this.data);
|
|
5187
5270
|
if (!storage.exists(this.cacheFolder)) {
|
|
5188
5271
|
console.log("🟢 creating folder", this.cacheFolder);
|
|
5189
5272
|
storage.mkdirp(this.cacheFolder);
|
|
@@ -6085,11 +6168,14 @@ var ComfyTS = class ComfyTS {
|
|
|
6085
6168
|
host(data) {
|
|
6086
6169
|
const existing = this.hosts.get(data.id);
|
|
6087
6170
|
if (existing != null) {
|
|
6088
|
-
const incoming = parseHostBase(data);
|
|
6089
|
-
const cur = existing.base;
|
|
6090
|
-
const sameBase = cur.scheme === incoming.scheme && cur.host === incoming.host && cur.port === incoming.port && cur.basePath === incoming.basePath;
|
|
6171
|
+
const incoming = namesNoAddress(data) ? null : parseHostBase(data);
|
|
6172
|
+
const cur = existing.noAddress == null ? existing.base : null;
|
|
6173
|
+
const sameBase = incoming == null || cur != null && cur.scheme === incoming.scheme && cur.host === incoming.host && cur.port === incoming.port && cur.basePath === incoming.basePath;
|
|
6091
6174
|
const sameAuth = existing.data.apiKey == null === (data.apiKey == null);
|
|
6092
|
-
if (!sameBase || !sameAuth)
|
|
6175
|
+
if (!sameBase || !sameAuth) {
|
|
6176
|
+
const authed = (p) => p.apiKey != null ? " (authed)" : "";
|
|
6177
|
+
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)}`);
|
|
6178
|
+
}
|
|
6093
6179
|
return existing;
|
|
6094
6180
|
}
|
|
6095
6181
|
const created = new ComfyHost(data);
|
|
@@ -6175,6 +6261,6 @@ function comfyTsPackageDir(moduleUrl = import.meta.url) {
|
|
|
6175
6261
|
throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
|
|
6176
6262
|
}
|
|
6177
6263
|
//#endregion
|
|
6178
|
-
export { readableStringify as a, settingsPathFor as i, comfyTsPackageDir as n, importSharp as o, ComfyTS as r, ComfySchema as s, bundledExamplesDir as t };
|
|
6264
|
+
export { readableStringify as a, writeHostFile as c, settingsPathFor as i, renderHttpBase as l, comfyTsPackageDir as n, importSharp as o, ComfyTS as r, ComfySchema as s, bundledExamplesDir as t };
|
|
6179
6265
|
|
|
6180
|
-
//# sourceMappingURL=exampleAssets-
|
|
6266
|
+
//# sourceMappingURL=exampleAssets-8MycEthF.js.map
|