comfy-ts 2.20.2 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +17 -1
  2. package/dist/{ServeApp-B469W26E.js → ServeApp-DuxYdaZZ.js} +142 -7
  3. package/dist/ServeApp-DuxYdaZZ.js.map +1 -0
  4. package/dist/cli.js +5 -5
  5. package/dist/{exampleAssets-yBLaKXLq.js → exampleAssets-1NHndnNB.js} +59 -17
  6. package/dist/exampleAssets-1NHndnNB.js.map +1 -0
  7. package/dist/{findDefinedWorkflow-B90-xFxX.js → findDefinedWorkflow-CRsBTTJK.js} +2 -2
  8. package/dist/{findDefinedWorkflow-B90-xFxX.js.map → findDefinedWorkflow-CRsBTTJK.js.map} +1 -1
  9. package/dist/index.cjs +118 -19
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +90 -9
  12. package/dist/index.d.ts +90 -9
  13. package/dist/index.js +117 -20
  14. package/dist/index.js.map +1 -1
  15. package/dist/{run-run-C-dDD9Dc.js → run-run-Y5ZI48vV.js} +5 -5
  16. package/dist/{run-run-C-dDD9Dc.js.map → run-run-Y5ZI48vV.js.map} +1 -1
  17. package/dist/{run-serve-CsEYPGm9.js → run-serve-CICU_wTL.js} +4 -4
  18. package/dist/{run-serve-CsEYPGm9.js.map → run-serve-CICU_wTL.js.map} +1 -1
  19. package/dist/{run-tui-bsmja4hi.js → run-tui-CViJXsHL.js} +4 -4
  20. package/dist/{run-tui-bsmja4hi.js.map → run-tui-CViJXsHL.js.map} +1 -1
  21. package/dist/{schemaDrift-DaWsE-mt.js → schemaDrift-CzjaIwZX.js} +53 -20
  22. package/dist/schemaDrift-CzjaIwZX.js.map +1 -0
  23. package/dist/serve-web.js +204 -47
  24. package/dist/web.d.ts +90 -9
  25. package/dist/web.js +117 -20
  26. package/dist/web.js.map +1 -1
  27. package/examples/README.md +2 -0
  28. package/examples/depth-explorer/models.ts +722 -0
  29. package/examples/depth-explorer/serve.ts +140 -0
  30. package/examples/depth-explorer/thumbs/bae.webp +0 -0
  31. package/examples/depth-explorer/thumbs/da3-mono-large.webp +0 -0
  32. package/examples/depth-explorer/thumbs/dav1-vitl.webp +0 -0
  33. package/examples/depth-explorer/thumbs/dav2-vitl.webp +0 -0
  34. package/examples/depth-explorer/thumbs/dsine.webp +0 -0
  35. package/examples/depth-explorer/thumbs/iid-albedo.webp +0 -0
  36. package/examples/depth-explorer/thumbs/iid-metalness.webp +0 -0
  37. package/examples/depth-explorer/thumbs/iid-roughness.webp +0 -0
  38. package/examples/depth-explorer/thumbs/iid-shading.webp +0 -0
  39. package/examples/depth-explorer/thumbs/iid-specular.webp +0 -0
  40. package/examples/depth-explorer/thumbs/leres.webp +0 -0
  41. package/examples/depth-explorer/thumbs/lotus-depth.webp +0 -0
  42. package/examples/depth-explorer/thumbs/marigold2-albedo.webp +0 -0
  43. package/examples/depth-explorer/thumbs/marigold2-depth.webp +0 -0
  44. package/examples/depth-explorer/thumbs/marigold2-normal.webp +0 -0
  45. package/examples/depth-explorer/thumbs/metric3d-depth.webp +0 -0
  46. package/examples/depth-explorer/thumbs/metric3d-normal.webp +0 -0
  47. package/examples/depth-explorer/thumbs/midas-normal.webp +0 -0
  48. package/examples/depth-explorer/thumbs/midas.webp +0 -0
  49. package/examples/depth-explorer/thumbs/moge2-depth.webp +0 -0
  50. package/examples/depth-explorer/thumbs/moge2-normal.webp +0 -0
  51. package/examples/depth-explorer/thumbs/zoe-da.webp +0 -0
  52. package/examples/depth-explorer/thumbs/zoe.webp +0 -0
  53. package/examples/depth-explorer/web/App.tsx +457 -0
  54. package/examples/depth-explorer/web/gl.ts +202 -0
  55. package/examples/depth-explorer/web/index.html +14 -0
  56. package/examples/depth-explorer/web/main.tsx +19 -0
  57. package/examples/depth-explorer/web/pixels.ts +86 -0
  58. package/examples/depth-explorer/web/state.ts +329 -0
  59. package/examples/depth-explorer/web/styles.css +366 -0
  60. package/examples/depth-explorer/web/tsconfig.json +16 -0
  61. package/examples/rvion/17-relight.cflow.ts +110 -0
  62. package/package.json +3 -2
  63. package/src/cli/serve/ServeApp.ts +79 -4
  64. package/src/cli/serve/describeVar.ts +12 -1
  65. package/src/cli/serve/resultHistory.ts +6 -1
  66. package/src/cli/serve/thumbs.ts +66 -0
  67. package/src/cli/serve/web/api.ts +5 -1
  68. package/src/cli/serve/web/components/Gallery.tsx +2 -0
  69. package/src/cli/serve/web/components/controls/BasicControls.tsx +14 -17
  70. package/src/cli/serve/web/components/controls/MediaControl.tsx +62 -9
  71. package/src/cli/serve/web/components/controls/RichSelect.tsx +262 -0
  72. package/src/cli/serve/web/state/RunSt.poll.test.ts +4 -1
  73. package/src/cli/serve/web/state/choiceButtons.ts +26 -2
  74. package/src/cli/serve/web/styles.ts +39 -0
  75. package/src/cli/serve/web/widgets/OutputWidgets.tsx +19 -0
  76. package/src/cli/serve/web/widgets/RelightSt.ts +113 -0
  77. package/src/cli/serve/web/widgets/RelightWidget.tsx +305 -0
  78. package/src/cli/serve/web/widgets/relightGl.ts +305 -0
  79. package/src/cli/serve/web/widgets/widgetStyles.ts +19 -0
  80. package/src/coreExports.ts +9 -0
  81. package/src/host/ComfyHost.ts +21 -0
  82. package/src/host/leastBusy.ts +37 -0
  83. package/src/state.ts +6 -0
  84. package/src/vars/ComfyVars.ts +32 -2
  85. package/src/vars/DefinedWorkflow.ts +42 -21
  86. package/src/vars/outputWidgets.ts +47 -0
  87. package/dist/ServeApp-B469W26E.js.map +0 -1
  88. package/dist/exampleAssets-yBLaKXLq.js.map +0 -1
  89. package/dist/schemaDrift-DaWsE-mt.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemaDrift-DaWsE-mt.js","names":["g"],"sources":["../src/utils/extractErrorMessage.ts","../src/utils/sha1.ts","../src/utils/matchesRegex.ts","../src/utils/log.ts","../src/storage/ComfyStorage.ts","../src/utils/bang.ts","../src/utils/isRecord.ts","../src/utils/hashArrayBuffer.ts","../src/runner/mediaKinds.ts","../src/utils/ansi.ts","../src/host/loraManagerApi.ts","../src/host/loraInfoCache.ts","../src/vars/loraKeywords.ts","../src/vars/loraEntry.ts","../src/vars/lanes.ts","../src/vars/promptSyntax.ts","../src/vars/presets.ts","../src/vars/ComfyVars.ts","../src/vars/DefinedWorkflow.ts","../src/host/schemaDrift.ts"],"sourcesContent":["/** Extracts an error message from an exception stuff. */\nexport const extractErrorMessage = (error: unknown): string => {\n if (error instanceof Error) return error.message\n if (error === null) return 'null'\n if (typeof error === 'string') return error\n if (typeof error === 'object') {\n if ('message' in error && typeof error.message === 'string') return error.message\n return JSON.stringify(error)\n }\n return String(error)\n}\n","// pure-JS SHA-1, browser-safe (architecture item 13): replaces node:crypto in\n// the core path. Output matches node's createHash('sha1') byte-for-byte —\n// upload-dedupe names and preview-cache keys stay identical across the swap\n// (vector-tested against node:crypto in tests/sha1.test.ts).\n\nexport function sha1Hex(data: Uint8Array): string {\n const ml = data.length\n const total = Math.ceil((ml + 1 + 8) / 64) * 64\n const bytes = new Uint8Array(total)\n bytes.set(data)\n bytes[ml] = 0x80\n const dv = new DataView(bytes.buffer)\n const bitLen = ml * 8\n dv.setUint32(total - 8, Math.floor(bitLen / 2 ** 32))\n dv.setUint32(total - 4, bitLen >>> 0)\n\n let h0 = 0x67452301\n let h1 = 0xefcdab89\n let h2 = 0x98badcfe\n let h3 = 0x10325476\n let h4 = 0xc3d2e1f0\n const w = new Uint32Array(80)\n\n for (let i = 0; i < total; i += 64) {\n for (let j = 0; j < 16; j++) w[j] = dv.getUint32(i + j * 4)\n for (let j = 16; j < 80; j++) {\n const n = (w[j - 3] ?? 0) ^ (w[j - 8] ?? 0) ^ (w[j - 14] ?? 0) ^ (w[j - 16] ?? 0)\n w[j] = (n << 1) | (n >>> 31)\n }\n let a = h0\n let b = h1\n let c = h2\n let d = h3\n let e = h4\n for (let j = 0; j < 80; j++) {\n let f: number\n let k: number\n if (j < 20) {\n f = (b & c) | (~b & d)\n k = 0x5a827999\n } else if (j < 40) {\n f = b ^ c ^ d\n k = 0x6ed9eba1\n } else if (j < 60) {\n f = (b & c) | (b & d) | (c & d)\n k = 0x8f1bbcdc\n } else {\n f = b ^ c ^ d\n k = 0xca62c1d6\n }\n const temp = (((a << 5) | (a >>> 27)) + f + e + k + (w[j] ?? 0)) >>> 0\n e = d\n d = c\n c = (b << 30) | (b >>> 2)\n b = a\n a = temp\n }\n h0 = (h0 + a) >>> 0\n h1 = (h1 + b) >>> 0\n h2 = (h2 + c) >>> 0\n h3 = (h3 + d) >>> 0\n h4 = (h4 + e) >>> 0\n }\n return [h0, h1, h2, h3, h4].map((x) => x.toString(16).padStart(8, '0')).join('')\n}\n\nexport function sha1HexOfString(s: string): string {\n return sha1Hex(new TextEncoder().encode(s))\n}\n","// RegExp.test on a /g or /y regex advances lastIndex, so the same pattern answers differently\n// on consecutive calls. A user-supplied filter is shared by several call sites.\nexport function statelessRegex(re: RegExp): RegExp {\n if (!re.global && !re.sticky) return re\n // sticky means \"match AT lastIndex\": dropping the flag would drop the anchoring too, and a\n // filter written as /krea/y would silently widen from starts-with to contains\n const source = re.sticky ? `^(?:${re.source})` : re.source\n return new RegExp(source, re.flags.replace(/[gy]/g, ''))\n}\n\nexport function matchesRegex(re: RegExp, value: string): boolean {\n return statelessRegex(re).test(value)\n}\n","// loud console logging; errors must be observable to human AND LLM.\n// COMFY_TS_QUIET=1 (set by drivers like the TUI) silences INFO chatter only —\n// errors always print.\nexport const isQuiet = (): boolean => process.env.COMFY_TS_QUIET === '1'\nexport const logInfo = (msg: string): void => {\n if (!isQuiet()) console.log(msg)\n}\nexport const logError = (msg: string): void => console.error(`[comfy-ts] 🔴 ${msg}`)\nexport const logSuccess = (msg: string): void => console.log(`[comfy-ts] 🟢 ${msg}`)\n","// the storage seam (architecture item 13): ONE sync fs-subset interface the\n// core path talks to. Node gets the real fs, the web entry an in-memory Map.\n// This file must stay browser-safe: no node imports, ever.\n\nexport type ComfyStorage = {\n /** backend name, for error messages */\n kind: string\n /** throws when missing */\n readText(path: string): string\n readTextIfExists(path: string): string | null\n /** throws when missing */\n readBytes(path: string): Uint8Array\n /** parents are created (mkdirp implied) */\n writeText(path: string, text: string): void\n /** parents are created (mkdirp implied) */\n writeBytes(path: string, bytes: Uint8Array): void\n exists(path: string): boolean\n mkdirp(path: string): void\n /** file mtime in ms; null when missing */\n mtimeMs(path: string): number | null\n homedir(): string\n cwd(): string\n}\n\n/** the fs/os surface createNodeStorageFrom needs — structural, so this file\n * never imports node types into the web graph */\nexport type NodeFsLike = {\n readFileSync(path: string, encoding?: 'utf8'): string | Uint8Array\n writeFileSync(path: string, data: string | Uint8Array): void\n existsSync(path: string): boolean\n mkdirSync(path: string, opts: { recursive: boolean }): unknown\n statSync(path: string): { mtimeMs: number; isFile(): boolean }\n}\nexport type NodeOsLike = { homedir(): string }\n\nfunction dirnameOf(path: string): string {\n const ix = path.lastIndexOf('/')\n return ix <= 0 ? '/' : path.slice(0, ix)\n}\n\n/** node backend built from INJECTED modules: nodeStorage.ts passes its static\n * imports, the autodetect below passes process.getBuiltinModule results */\nexport function createNodeStorageFrom(fs: NodeFsLike, os: NodeOsLike): ComfyStorage {\n return {\n kind: 'node',\n readText: (p) => fs.readFileSync(p, 'utf8') as string,\n readTextIfExists: (p) => (fs.existsSync(p) ? (fs.readFileSync(p, 'utf8') as string) : null),\n readBytes: (p) => new Uint8Array(fs.readFileSync(p) as Uint8Array),\n writeText: (p, text) => {\n fs.mkdirSync(dirnameOf(p), { recursive: true })\n fs.writeFileSync(p, text)\n },\n writeBytes: (p, bytes) => {\n fs.mkdirSync(dirnameOf(p), { recursive: true })\n fs.writeFileSync(p, bytes)\n },\n exists: (p) => fs.existsSync(p),\n mkdirp: (p) => void fs.mkdirSync(p, { recursive: true }),\n mtimeMs: (p) => (fs.existsSync(p) ? fs.statSync(p).mtimeMs : null),\n homedir: () => os.homedir(),\n cwd: () => process.cwd(),\n }\n}\n\n/** in-memory backend: the web default, also handy for hermetic tests.\n * Paths are LITERAL keys (no normalization — core callers resolve through\n * pathe/comfyts already). exists() knows written files and EXPLICIT mkdirp\n * dirs only, never implicit parents. Bytes are copied in AND out so neither\n * side can mutate the store. */\nexport function createMemoryStorage(p: { homedir?: string; cwd?: string } = {}): ComfyStorage {\n const files = new Map<string, Uint8Array>()\n const mtimes = new Map<string, number>()\n const dirs = new Set<string>()\n const td = new TextDecoder()\n const te = new TextEncoder()\n const write = (path: string, bytes: Uint8Array): void => {\n files.set(path, bytes.slice())\n mtimes.set(path, Date.now())\n }\n return {\n kind: 'memory',\n readText: (path) => {\n const hit = files.get(path)\n if (hit == null) throw new Error(`[memory storage] no such file: ${path}`)\n return td.decode(hit)\n },\n readTextIfExists: (path) => {\n const hit = files.get(path)\n return hit == null ? null : td.decode(hit)\n },\n readBytes: (path) => {\n const hit = files.get(path)\n if (hit == null) throw new Error(`[memory storage] no such file: ${path}`)\n return hit.slice()\n },\n writeText: (path, text) => write(path, te.encode(text)),\n writeBytes: write,\n exists: (path) => files.has(path) || dirs.has(path),\n mkdirp: (path) => void dirs.add(path),\n mtimeMs: (path) => mtimes.get(path) ?? null,\n homedir: () => p.homedir ?? '/home/web',\n cwd: () => p.cwd ?? '/',\n }\n}\n\n// ---- default resolution (architecture item 13) ------------------------------\n// explicit ComfyTS.create({storage}) → entry-installed default → node builtins\n// autodetect (node 22+/bun: no static import needed) → loud throw.\n\nlet installedDefault: ComfyStorage | null = null\n\n/** entries call this at import time: index.ts installs node, web.ts memory */\nexport function setDefaultComfyStorage(storage: ComfyStorage): void {\n installedDefault = storage\n}\n\nfunction autodetectNodeStorage(): ComfyStorage | null {\n const get = globalThis.process?.getBuiltinModule\n if (typeof get !== 'function') return null\n const fs = get('node:fs') as NodeFsLike | undefined\n const os = get('node:os') as NodeOsLike | undefined\n if (fs == null || os == null) return null\n return createNodeStorageFrom(fs, os)\n}\n\nexport function resolveComfyStorage(explicit?: ComfyStorage): ComfyStorage {\n if (explicit != null) return explicit\n if (installedDefault != null) return installedDefault\n const detected = autodetectNodeStorage()\n if (detected != null) {\n installedDefault = detected\n return detected\n }\n throw new Error(\n `no ComfyStorage available — import 'comfy-ts' (node) or 'comfy-ts/web' (browser) before creating ComfyTS, or pass ComfyTS.create({ storage })`,\n )\n}\n\n/** the ONE accessor call sites use: the instance's storage when the global\n * exists, the resolved default otherwise (vars constructed before create()) */\nexport function getComfyStorage(): ComfyStorage {\n const g = globalThis as { comfyts?: { storage?: ComfyStorage } }\n return g.comfyts?.storage ?? resolveComfyStorage()\n}\n","import type { Maybe } from 'src/types/index.ts'\n\n/** assertNotNull */\nexport const bang = <T>(x: Maybe<T>, msg: string = ''): T => {\n if (x == null) {\n console.error(`[🔴] BANG FAILED`, msg)\n throw new Error('bang: ' + (msg ?? 'no message'))\n }\n return x\n}\n\n/** soft assertNotNull — LIES on failure: logs then returns the null as T. Prefer bang(). */\nexport const bong = <T>(x: Maybe<T>, msg: string = ''): T => {\n if (x == null) {\n console.error(`[🔴] BONG FAILED`, msg)\n return x as T\n }\n return x\n}\n\nexport function ASSERT_ARRAY(a: unknown): a is unknown[] {\n if (!Array.isArray(a)) throw new Error('❌ not an array')\n return true\n}\n\nexport function ASSERT_EQUAL(a: unknown, b: unknown): a is unknown[] {\n if (a !== b) throw new Error('❌ not equal')\n return true\n}\n\n// ----------\nexport function ASSERT_STRING(a: unknown): a is string {\n if (typeof a !== 'string') throw new Error('❌ not a string')\n return true\n}\nexport function asSTRING_orCrash(a: unknown, errMsg: string = '❌ not a string'): string {\n if (typeof a !== 'string') throw new Error(errMsg)\n return a\n}\n","/** narrows unknown wire json to an indexable object (arrays and null excluded) */\nexport function isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n}\n","import { sha1Hex } from 'src/utils/sha1.ts'\n\nexport const hashArrayBuffer = (buffer: Uint8Array): string => {\n return sha1Hex(buffer)\n}\n","// the three media a var can take and an output can be. PURE + dependency-free: the web bundle\n// imports it to decide which var a dropped output may land on\n\nexport type MediaKind = 'image' | 'audio' | 'video'\n\nexport const MEDIA_KINDS: readonly MediaKind[] = ['image', 'audio', 'video']\n\n/** picker defaults per kind, lowercase without dots */\nexport const DEFAULT_MEDIA_EXTENSIONS: Record<MediaKind, readonly string[]> = {\n image: ['png', 'jpg', 'jpeg', 'webp', 'gif'],\n audio: ['wav', 'flac', 'mp3', 'ogg', 'opus', 'm4a'],\n video: ['mp4', 'webm', 'mov', 'mkv', 'm4v'],\n}\n\nconst MIMES: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n webp: 'image/webp',\n gif: 'image/gif',\n flac: 'audio/flac',\n mp3: 'audio/mpeg',\n opus: 'audio/ogg',\n ogg: 'audio/ogg',\n wav: 'audio/wav',\n m4a: 'audio/mp4',\n aac: 'audio/aac',\n mp4: 'video/mp4',\n m4v: 'video/mp4',\n webm: 'video/webm',\n mov: 'video/quicktime',\n mkv: 'video/x-matroska',\n avi: 'video/x-msvideo',\n}\n\n/** video containers an output node can name. An animated webp or gif is an IMAGE: the\n * extension decides, never the `animated` flag */\nconst VIDEO_EXTENSIONS = new Set(['mp4', 'm4v', 'webm', 'mov', 'mkv', 'avi'])\n\nexport function extensionOf(filename: string): string {\n const dot = filename.lastIndexOf('.')\n return dot < 0 ? '' : filename.slice(dot + 1).toLowerCase()\n}\n\nexport function isVideoFilename(filename: string): boolean {\n return VIDEO_EXTENSIONS.has(extensionOf(filename))\n}\n\nexport function mediaMime(filename: string): string {\n return MIMES[extensionOf(filename)] ?? 'application/octet-stream'\n}\n","// tiny chalk-compatible terminal styler (chainable), keeps chalk out of the deps\nconst codes = {\n bold: [1, 22],\n dim: [2, 22],\n underline: [4, 24],\n red: [31, 39],\n green: [32, 39],\n yellow: [33, 39],\n blue: [34, 39],\n cyan: [36, 39],\n gray: [90, 39],\n greenBright: [92, 39],\n} as const\n\ntype StyleName = keyof typeof codes\nexport type Styler = ((s: string) => string) & { [k in StyleName]: Styler }\n\nfunction styler(open: string = '', close: string = ''): Styler {\n const fn = (s: string): string => open + s + close\n return new Proxy(fn, {\n get(_target, prop: string) {\n const c = codes[prop as StyleName]\n if (c == null) throw new Error(`unknown ansi style: ${prop}`)\n return styler(`${open}\\x1b[${c[0]}m`, `\\x1b[${c[1]}m${close}`)\n },\n }) as Styler\n}\n\nexport const ansi: Styler = styler()\n\n// CSI sequences + lone ESC-letter escapes (server logs re-rendered inside ink)\nconst ANSI_RE = /\\x1b\\[[0-9;?]*[A-Za-z]|\\x1b[A-Za-z]/g\n\nexport function stripAnsi(s: string): string {\n return s.replace(ANSI_RE, '')\n}\n\n/** colors only where they can be seen: a real terminal, NO_COLOR unset, TERM not 'dumb'.\n * A piped or redirected stdout gets plain text, so `serve > log` stays greppable */\nexport function colorsAvailable(): boolean {\n const env = globalThis.process?.env ?? {}\n if (env.NO_COLOR != null && env.NO_COLOR !== '') return false\n if (env.TERM === 'dumb') return false\n if (env.FORCE_COLOR != null && env.FORCE_COLOR !== '' && env.FORCE_COLOR !== '0') return true\n return globalThis.process?.stdout?.isTTY === true\n}\n","import { type } from 'arktype'\nimport { basename } from 'pathe'\nimport { getComfyStorage } from 'src/storage/ComfyStorage.ts'\nimport { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'\nimport { isRecord } from 'src/utils/isRecord.ts'\nimport { sha1HexOfString } from 'src/utils/sha1.ts'\nimport type { ComfyHost } from 'src/host/ComfyHost.ts'\nimport { logError } from 'src/utils/log.ts'\n\n/**\n * client for the OPTIONAL ComfyUI-Lora-Manager extension.\n * absent extension = normal condition: callers get null/empty and degrade.\n */\n\n/**\n * one lora exactly as lora-manager sent it. RAW on purpose (agent/architecture\n * item 8): the mirror on disk keeps every field, including the ones we do not\n * read yet, so adding `sha256` or `civitai.modelId` to a surface later is an\n * accessor, not a re-sync. Reading goes through the checked lm* helpers below.\n */\nexport type LmLoraItem = Record<string, unknown>\n\n/** only the ENVELOPE is schema'd — items stay unknown so nothing can strip their fields */\nconst lmLoraPage = type({\n items: 'unknown[]',\n 'total?': 'number',\n})\n\nfunction readString(item: LmLoraItem, key: string): string | null {\n const v = item[key]\n return typeof v === 'string' && v !== '' ? v : null\n}\n\nfunction readStringArray(item: LmLoraItem, key: string): string[] {\n const v = item[key]\n if (!Array.isArray(v)) return []\n return v.filter((x): x is string => typeof x === 'string' && x !== '')\n}\n\nexport function lmFileName(item: LmLoraItem): string | null {\n return readString(item, 'file_name')\n}\nexport function lmFolder(item: LmLoraItem): string {\n return readString(item, 'folder') ?? ''\n}\nexport function lmModelName(item: LmLoraItem): string | null {\n return readString(item, 'model_name')\n}\nexport function lmBaseModel(item: LmLoraItem): string | null {\n return readString(item, 'base_model')\n}\nexport function lmPreviewUrl(item: LmLoraItem): string | null {\n return readString(item, 'preview_url')\n}\n/** the file's size in bytes, when the extension reports it */\n/** the file's content hash: what the extension keys its example images by */\nexport function lmSha256(item: LmLoraItem): string | null {\n return readString(item, 'sha256')\n}\n\n/** when the file landed on the host (epoch seconds): the lora manager's own \"date added\" sort reads it */\nexport function lmModified(item: LmLoraItem): number | null {\n const raw = item['modified']\n return typeof raw === 'number' && Number.isFinite(raw) ? raw : null\n}\n\nexport function lmFileSize(item: LmLoraItem): number | null {\n const raw = item['file_size']\n return typeof raw === 'number' && Number.isFinite(raw) ? raw : null\n}\n\n/** the note YOU wrote in the lora manager, empty when there is none */\nexport function lmNotes(item: LmLoraItem): string {\n return readString(item, 'notes') ?? ''\n}\n\n/** the civitai block: what links a local file back to the page it came from */\nexport function lmCivitai(item: LmLoraItem): { modelId: number | null; name: string | null } | null {\n const civitai = item['civitai']\n if (!isRecord(civitai)) return null\n const modelId = civitai['modelId']\n return {\n modelId: typeof modelId === 'number' && Number.isFinite(modelId) ? modelId : null,\n name: readString(civitai, 'name'),\n }\n}\n\nexport function lmTags(item: LmLoraItem): string[] {\n return readStringArray(item, 'tags')\n}\n\n/** the trigger words: civitai's `trainedWords`, absent for a lora nobody published */\nexport function lmTrainedWords(item: LmLoraItem): string[] {\n const civitai = item['civitai']\n if (!isRecord(civitai)) return []\n return readStringArray(civitai, 'trainedWords')\n}\n\n/** lm's own absolute path for the file, as it exists on the HOST's disk */\nexport function lmFilePath(item: LmLoraItem): string | null {\n return readString(item, 'file_path')\n}\n\n/**\n * the ONE key space where a host's object_info spelling of a lora meets\n * lora-manager's: lowercase, forward slashes, no model extension.\n * `styles\\Aurora.safetensors` and lm's folder `styles` + file_name `aurora`\n * both become `styles/aurora`.\n */\nexport function loraKey(name: string): string {\n return name\n .replaceAll('\\\\', '/')\n .replace(/\\.(safetensors|st|pt|ckpt)$/i, '')\n .toLowerCase()\n}\n\n/** the file's own name, windows separators included (`styles\\x.safetensors` → `x.safetensors`) */\nexport function loraBasename(name: string): string {\n return basename(name.replaceAll('\\\\', '/'))\n}\n\n/** the mirror key for an lm item: its folder/file_name pair, normalized */\nexport function lmItemKey(item: LmLoraItem): string | null {\n const file = lmFileName(item)\n if (file == null) return null\n const folder = lmFolder(item)\n return loraKey(folder === '' ? file : `${folder}/${file}`)\n}\n\n/** runaway stop: 20 pages × the server's 100-per-page cap = 2000 loras */\nconst MAX_PAGES = 20\n\n/**\n * the outcome of a sweep, DISCRIMINATED. A bare `null` for \"no loras\" conflated\n * three very different situations, and callers then told the user the wrong one:\n * a host that is merely DOWN was reported as \"extension not detected\", and a\n * sweep cut short mid-collection was indistinguishable from a complete one, so\n * a partial mirror could overwrite a good one and report success.\n */\nexport type LoraSweep =\n | { status: 'ok'; items: LmLoraItem[] }\n /** the extension answered, then stopped answering: `items` is INCOMPLETE, never write it over a good mirror */\n | { status: 'partial'; items: LmLoraItem[]; reason: string }\n /** no ComfyUI-Lora-Manager on this host (404 on the first page) */\n | { status: 'absent' }\n /** the host itself could not be reached (down, refused, auth) */\n | { status: 'unreachable'; reason: string }\n\n/** asks the extension to (re)fetch civitai metadata for ONE lora file, trigger words included.\n * The reply says why when civitai has nothing for it (a private or deleted model) */\nexport async function fetchLoraCivitai(\n host: ComfyHost,\n filePath: string,\n): Promise<{ ok: true } | { ok: false; reason: string }> {\n try {\n const res = await host.fetch('/lm/loras/fetch-civitai', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ file_path: filePath }),\n })\n const raw: unknown = await res.json().catch(() => null)\n const error = isRecord(raw) && typeof raw['error'] === 'string' ? raw['error'] : null\n if (res.ok && isRecord(raw) && raw['success'] !== false) return { ok: true }\n return { ok: false, reason: error ?? `the lora manager answered ${res.status}` }\n } catch (e) {\n return { ok: false, reason: extractErrorMessage(e) }\n }\n}\n\n/** civitai's model description for ONE lora, as PLAIN TEXT. The extension answers html, and\n * html from a third party is never rendered: tags are stripped here, at the seam.\n * null = the extension has no description for it (or does not expose the route) */\nexport async function fetchLoraDescription(host: ComfyHost, filePath: string): Promise<string | null> {\n try {\n const res = await host.fetch(`/lm/loras/model-description?file_path=${encodeURIComponent(filePath)}`, {})\n // a 404 IS \"no description\", any other status is the extension failing at its job: the\n // two collapsed to the same silent null, which is the wrong-cause report the sibling\n // fetchLoraExampleImages carries a `reason` to avoid\n if (!res.ok) {\n if (res.status !== 404) logError(`[lora-manager] description ${res.status} for ${filePath}`)\n return null\n }\n const raw: unknown = await res.json()\n const description = isRecord(raw) ? raw['description'] : null\n if (typeof description !== 'string' || description === '') return null\n return htmlToText(description)\n } catch (e) {\n logError(`[lora-manager] description unreachable for ${filePath}: ${extractErrorMessage(e)}`)\n return null\n }\n}\n\n/** `<p>a</p><br>b` → `a\\n\\nb`. Deliberately dumb: this text is DISPLAYED, never parsed */\nfunction htmlToText(html: string): string {\n return html\n .replaceAll(/<\\s*br\\s*\\/?>/gi, '\\n')\n .replaceAll(/<\\/\\s*(p|div|li|h[1-6])\\s*>/gi, '\\n\\n')\n .replaceAll(/<\\s*li[^>]*>/gi, '· ')\n .replaceAll(/<[^>]+>/g, '')\n .replaceAll('&nbsp;', ' ')\n .replaceAll('&amp;', '&')\n .replaceAll('&lt;', '<')\n .replaceAll('&gt;', '>')\n .replaceAll('&quot;', '\"')\n .replaceAll('&#39;', \"'\")\n .replaceAll(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n\n/** the example images lora-manager keeps for a lora. `reason` explains an empty list rather\n * than pretending the lora has none, \"no example images path configured\" is a SETTING */\nexport async function fetchLoraExampleImages(\n host: ComfyHost,\n sha256: string,\n): Promise<{ files: string[]; reason: string | null }> {\n try {\n const res = await host.fetch(`/lm/example-image-files?model_hash=${encodeURIComponent(sha256)}`, {})\n const raw: unknown = await res.json()\n if (!isRecord(raw)) return { files: [], reason: `unexpected reply (http ${res.status})` }\n if (raw['success'] !== true) {\n const err = raw['error']\n return { files: [], reason: typeof err === 'string' ? err : `http ${res.status}` }\n }\n const files = raw['files']\n if (!Array.isArray(files)) return { files: [], reason: null }\n const out: string[] = []\n for (const f of files) {\n if (typeof f === 'string') out.push(f)\n else if (isRecord(f) && typeof f['path'] === 'string') out.push(f['path'])\n }\n return { files: out, reason: null }\n } catch (e) {\n return { files: [], reason: e instanceof Error ? e.message : String(e) }\n }\n}\n\n/**\n * every lora lora-manager knows, RAW, in one paged sweep.\n * page_size asks for 500; the server caps it at 100, so the loop follows `total`.\n */\nexport async function fetchLoraList(host: ComfyHost): Promise<LoraSweep> {\n const items: LmLoraItem[] = []\n for (let page = 1; page <= MAX_PAGES; page++) {\n let res: Response\n try {\n // the extension registers under /api — already prefixed, skip the probe\n res = await host.fetch(`/api/lm/loras/list?page=${page}&page_size=500`, {}, { apiPrefix: false })\n } catch (e) {\n const reason = `host unreachable at page ${page}: ${extractErrorMessage(e)}`\n return page === 1 ? { status: 'unreachable', reason } : partial(items, reason)\n }\n if (!res.ok) {\n // ONLY a route-not-there status means \"no extension here\". A 500 while lm\n // rescans its model db, or a 403, used to be announced to the user as\n // \"the extension is not installed\" — the same wrong-cause report the\n // discriminated status exists to prevent\n const missing = res.status === 404 || res.status === 405\n if (page === 1)\n return missing ? { status: 'absent' } : { status: 'unreachable', reason: `answered ${res.status}` }\n return partial(items, `page ${page} answered ${res.status}`)\n }\n let parsed: ReturnType<typeof lmLoraPage>\n try {\n // json() throws on an html SPA fallback or an empty body, and a THROW is\n // a fifth outcome this function promises not to have\n parsed = lmLoraPage(await res.json())\n } catch (e) {\n const reason = `page ${page} did not answer json: ${extractErrorMessage(e)}`\n return page === 1 ? { status: 'absent' } : partial(items, reason)\n }\n if (parsed instanceof type.errors) {\n // wire tolerance (agent/coding.md): lm drifts faster than our schema\n return partial(items, `page ${page} shape mismatch: ${parsed.summary}`)\n }\n const pageItems = parsed.items.filter(isRecord)\n items.push(...pageItems)\n const total = parsed.total\n if (total != null && items.length >= total) return { status: 'ok', items }\n if (pageItems.length === 0) {\n // an empty page is the END only when nothing said there was more. With a\n // `total` still ahead of us the collection is TRUNCATED, and calling that\n // `ok` let the cli overwrite a good mirror and print 🟢 while dropping loras\n return total == null || page === 1\n ? { status: 'ok', items }\n : partial(items, `page ${page} came back empty with ${items.length}/${total} fetched`)\n }\n }\n return partial(items, `stopped at the ${MAX_PAGES}-page runaway limit`)\n}\n\n/** a truncated sweep is LOUD at the source, whatever the caller then decides to do */\nfunction partial(items: LmLoraItem[], reason: string): LoraSweep {\n logError(`[loraManagerApi] lora sweep INCOMPLETE after ${items.length} loras — ${reason}`)\n return { status: 'partial', items, reason }\n}\n\n/** `loraKey` → server-relative preview_url */\nexport function loraPreviewMapFrom(items: LmLoraItem[]): Map<string, string> {\n const map = new Map<string, string>()\n for (const item of items) {\n const key = lmItemKey(item)\n const url = lmPreviewUrl(item)\n if (key != null && url != null) map.set(key, url)\n }\n return map\n}\n\n/** the bytes look like an image (magic numbers) — guards against ComfyUI's SPA index.html fallback */\nexport function looksLikeImage(bytes: Uint8Array): boolean {\n if (bytes.length < 3) return false // shortest signature (JPEG/GIF) is 3 bytes\n const b = bytes\n const is = (sig: number[], off = 0): boolean => sig.every((v, i) => b[off + i] === v)\n return (\n is([0x89, 0x50, 0x4e, 0x47]) || // PNG\n is([0xff, 0xd8, 0xff]) || // JPEG\n is([0x47, 0x49, 0x46]) || // GIF\n (is([0x52, 0x49, 0x46, 0x46]) && is([0x57, 0x45, 0x42, 0x50], 8)) // RIFF…WEBP\n )\n}\n\n/**\n * fetch a preview image's bytes from its server-relative preview_url.\n * cached on success at `.comfy-ts/cache/lora-previews/<sha1(url)>`. Returns null\n * when the file is missing: lora-manager SPA-fallbacks to index.html (HTML), so\n * a non-image content-type OR non-image magic bytes => no preview, not a crash.\n */\nexport async function fetchLoraPreviewBytes(host: ComfyHost, previewUrl: string): Promise<Uint8Array | null> {\n const storage = getComfyStorage()\n const cachePath = comfyts.resolveFromCache(`lora-previews/${sha1HexOfString(previewUrl)}`)\n if (storage.exists(cachePath)) return storage.readBytes(cachePath)\n try {\n // preview_url is already a full server-relative path — no /api probing\n const res = await host.fetch(previewUrl, {}, { apiPrefix: false })\n if (!res.ok) return null\n const ct = res.headers.get('content-type') ?? ''\n if (ct !== '' && !ct.startsWith('image/')) return null // HTML fallback etc.\n const bytes = new Uint8Array(await res.arrayBuffer())\n if (!looksLikeImage(bytes)) return null\n storage.writeBytes(cachePath, bytes)\n return bytes\n } catch {\n return null\n }\n}\n","import { join } from 'pathe'\nimport { getComfyStorage } from 'src/storage/ComfyStorage.ts'\nimport {\n type LmLoraItem,\n lmBaseModel,\n lmFileName,\n lmFilePath,\n lmFolder,\n lmItemKey,\n lmModelName,\n lmModified,\n lmPreviewUrl,\n lmSha256,\n lmTags,\n lmTrainedWords,\n loraBasename,\n loraKey,\n} from 'src/host/loraManagerApi.ts'\nimport type { AbsolutePath } from 'src/types/index.ts'\nimport { isRecord } from 'src/utils/isRecord.ts'\nimport { logError } from 'src/utils/log.ts'\n\n/**\n * the LOCAL MIRROR of what ComfyUI-Lora-Manager knows about a host's loras\n * (agent/architecture.md item 8). A ComfyUI host only ever tells us a lora's\n * file name; the model's real name, its trigger words and its tags live in the\n * extension. We sweep them once (`comfy-ts loras`) into\n * `.comfy-ts/hosts/<id>/loras.json` and every surface reads the mirror after.\n */\n\nexport type LoraMirror = {\n hostId: string\n /** remembered so a later `comfy-ts loras` re-syncs with no flags. NEVER an api key. */\n hostUrl: string\n fetchedAt: string\n count: number\n /** `loraKey` → the RAW lm item */\n loras: Record<string, LmLoraItem>\n}\n\nfunction loraMirrorPath(hostId: string): AbsolutePath {\n return comfyts.resolveFromHosts(join(hostId, 'loras.json'))\n}\n\n/** pure: the on-disk shape for a sweep. Items without a file_name are dropped (nothing to key them by). */\nexport function buildLoraMirror(p: {\n hostId: string\n hostUrl: string\n fetchedAt: string\n items: LmLoraItem[]\n}): LoraMirror {\n const loras: Record<string, LmLoraItem> = {}\n for (const item of p.items) {\n const key = lmItemKey(item)\n if (key == null) continue\n // `x.safetensors` and `x.pt` in one folder collapse here: one lora would\n // silently inherit the other's trigger words, so say it out loud\n if (loras[key] != null) logError(`[loraInfoCache] two loras share the key '${key}' — one of them is shadowed`)\n loras[key] = item\n }\n return {\n hostId: p.hostId,\n hostUrl: p.hostUrl,\n fetchedAt: p.fetchedAt,\n count: Object.keys(loras).length,\n loras,\n }\n}\n\nexport function writeLoraMirror(mirror: LoraMirror): AbsolutePath {\n const path = loraMirrorPath(mirror.hostId)\n getComfyStorage().writeText(path, JSON.stringify(mirror, null, 2))\n return path\n}\n\n/** null = never synced (or unreadable, which is LOGGED) */\nexport function readLoraMirror(hostId: string): LoraMirror | null {\n const path = loraMirrorPath(hostId)\n const text = getComfyStorage().readTextIfExists(path)\n if (text == null) return null\n try {\n const raw: unknown = JSON.parse(text)\n if (!isRecord(raw)) return null\n const rawLoras = raw['loras']\n if (!isRecord(rawLoras)) return null\n const loras: Record<string, LmLoraItem> = {}\n for (const [key, item] of Object.entries(rawLoras)) if (isRecord(item)) loras[key] = item\n const str = (key: string, fallback: string): string => {\n const v = raw[key]\n return typeof v === 'string' ? v : fallback\n }\n // count is RECOUNTED, never trusted: the file is hand-editable like every .comfy-ts json\n return {\n hostId: str('hostId', hostId),\n hostUrl: str('hostUrl', ''),\n fetchedAt: str('fetchedAt', ''),\n count: Object.keys(loras).length,\n loras,\n }\n } catch (e) {\n logError(`[loraInfoCache] unreadable ${path}: ${String(e)}`)\n return null\n }\n}\n\n/**\n * the read model: each registered host's mirror, kept PER HOST.\n *\n * Per host, not merged into one map, because the same file name on two hosts is\n * routinely a different model. A merged map served whichever host loaded first,\n * so on the other host the overlay showed the wrong model name and the prompt\n * silently received the wrong trigger words — a bad generation with no error\n * anywhere. Callers that know their host say so; the rest fall back to any host\n * that has the lora, which is still better than nothing for a display name.\n *\n * Plain (non-observable) on purpose: the loras overlay reads this from inside a\n * mobx render. The storage seam has no readdir, so the host set comes from\n * `comfyts.hosts` — exactly the hosts this process can be asked about.\n */\nconst byHost = new Map<string, Map<string, LmLoraItem>>()\n/** hosts already looked for, INCLUDING the ones with no mirror on disk → their mtime is null */\nconst loadedMtimes = new Map<string, number | null>()\n\n/** cheap: no stat, no parse — this runs inside the overlay's render for every row */\nfunction ensureLoaded(): void {\n for (const hostId of comfyts.hosts.keys()) if (!loadedMtimes.has(hostId)) loadHost(hostId)\n}\n\nfunction loadHost(hostId: string): void {\n const storage = getComfyStorage()\n const path = loraMirrorPath(hostId)\n loadedMtimes.set(hostId, storage.mtimeMs(path))\n const mirror = readLoraMirror(hostId)\n if (mirror != null) byHost.set(hostId, new Map(Object.entries(mirror.loras)))\n // a mirror that EXISTS but will not parse (a sync killed mid-write) still makes\n // this host authoritative, with an empty map: falling through to another host's\n // entries is exactly the wrong-model-name bug the per-host split removed\n else if (storage.exists(path)) byHost.set(hostId, new Map())\n else byHost.delete(hostId)\n}\n\n/**\n * re-read any mirror whose file changed (or appeared) since we loaded it.\n * `comfy-ts loras` in another terminal is the normal case, and without this a\n * TUI session kept the stale data — or kept knowing NOTHING, for a host whose\n * first sync happened while it was open. One stat per registered host, so this\n * belongs at user-initiated moments (opening the loras overlay), never in a render.\n */\nexport function refreshLoraInfoCacheIfChanged(): void {\n const storage = getComfyStorage()\n for (const hostId of comfyts.hosts.keys()) {\n const seen = loadedMtimes.get(hostId)\n const now = storage.mtimeMs(loraMirrorPath(hostId))\n // `undefined` = never looked; `null` = looked, no file. Both differ from a real mtime.\n if (!loadedMtimes.has(hostId) || seen !== now) loadHost(hostId)\n }\n}\n\n/** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */\nexport function reloadLoraInfoCache(): void {\n byHost.clear()\n loadedMtimes.clear()\n}\n\n/**\n * the lm item for a raw lora name (`styles\\x.safetensors`).\n * `hostId` picks the mirror that actually describes this host's file; without\n * it, any host that knows the name answers. null when unsynced/unknown.\n */\nexport function getLoraInfo(name: string, hostId?: string): LmLoraItem | null {\n ensureLoaded()\n const key = loraKey(name)\n if (hostId != null) {\n const own = byHost.get(hostId)\n // a host WITH a mirror is authoritative about its own loras: never fall\n // back to another host's entry for a lora it does not have\n if (own != null) return own.get(key) ?? null\n }\n for (const mirror of byHost.values()) {\n const hit = mirror.get(key)\n if (hit != null) return hit\n }\n return null\n}\n\n/** civitai trigger words for this lora, in civitai's order */\nexport function getLoraTriggerWords(name: string, hostId?: string): string[] {\n const info = getLoraInfo(name, hostId)\n return info == null ? [] : lmTrainedWords(info)\n}\n\n/** the human name (`Aurora Ink Wash`), falling back to the file's own name */\nexport function getLoraDisplayName(name: string, hostId?: string): string {\n const info = getLoraInfo(name, hostId)\n return (info == null ? null : lmModelName(info)) ?? loraBasename(name)\n}\n\n/** what the mirror knows about a lora's trigger words. The extension drops an EMPTY\n * `trainedWords` when it slims the civitai block (model_scanner.py `if trained_words:`), so a\n * block linked to civitai (an `id`) with no words means fetched and empty, while no block at\n * all means civitai was never asked. null = the lora is not in the mirror */\nexport type LoraTriggers =\n | { state: 'words'; words: string[] }\n | { state: 'none' }\n | { state: 'unfetched' }\n /** civitai was asked and has no version for this file (a private or local lora) */\n | { state: 'not-on-civitai' }\n\nexport function loraTriggersOf(item: LmLoraItem, p: { civitaiMiss?: boolean } = {}): LoraTriggers {\n const words = lmTrainedWords(item)\n if (words.length > 0) return { state: 'words', words }\n const civitai = item['civitai']\n if (isRecord(civitai) && (typeof civitai['id'] === 'number' || typeof civitai['modelId'] === 'number'))\n return { state: 'none' }\n return p.civitaiMiss === true ? { state: 'not-on-civitai' } : { state: 'unfetched' }\n}\n\nexport function getLoraTriggers(name: string, hostId?: string): LoraTriggers | null {\n const info = getLoraInfo(name, hostId)\n if (info == null) return null\n const sha = lmSha256(info)\n return loraTriggersOf(info, { civitaiMiss: hostId != null && sha != null && readCivitaiMisses(hostId)[sha] != null })\n}\n\n// the lora manager records nothing when civitai has no version for a file, so the answer is kept\n// here, keyed by content hash (a rename keeps it): without it such a lora would offer a fetch\n// that fails the same way forever\nfunction civitaiMissesPath(hostId: string): AbsolutePath {\n return comfyts.resolveFromHosts(join(hostId, 'lora-civitai-misses.json'))\n}\n\n/** sha256 → when civitai said it has no version for that file */\nexport function readCivitaiMisses(hostId: string): Record<string, string> {\n const text = getComfyStorage().readTextIfExists(civitaiMissesPath(hostId))\n if (text == null) return {}\n try {\n const raw: unknown = JSON.parse(text)\n const out: Record<string, string> = {}\n if (isRecord(raw)) for (const [sha, at] of Object.entries(raw)) if (typeof at === 'string') out[sha] = at\n return out\n } catch (e) {\n logError(`[loraInfoCache] unreadable ${civitaiMissesPath(hostId)}: ${String(e)}`)\n return {}\n }\n}\n\nexport function recordCivitaiMiss(p: { hostId: string; sha256: string; miss: boolean }): void {\n const misses = readCivitaiMisses(p.hostId)\n if (p.miss) misses[p.sha256] = new Date().toISOString()\n else delete misses[p.sha256]\n getComfyStorage().writeText(civitaiMissesPath(p.hostId), JSON.stringify(misses, null, 2))\n}\n\n/** when the lora file landed on the host (epoch seconds), null when unsynced/unknown */\nexport function getLoraAddedAt(name: string, hostId?: string): number | null {\n const info = getLoraInfo(name, hostId)\n return info == null ? null : lmModified(info)\n}\n\n/** server-relative preview url from the mirror, null when unsynced/unknown */\nexport function getLoraPreviewUrl(name: string, hostId?: string): string | null {\n const info = getLoraInfo(name, hostId)\n return info == null ? null : lmPreviewUrl(info)\n}\n\n/** the lora's NAMES: the file, and the model name a human would call it by */\n/**\n * every lora the mirror knows for a host: its normalized KEY (comparable with `loraKey(option)`,\n * never with a raw enum value, those keep their case, extension and windows separators) and the\n * NAME a ComfyUI graph would load it by, rebuilt from the manager's folder + real filename.\n * `[]` when the host was never synced.\n */\nexport function loraMirrorEntries(\n hostId: string,\n p: { separator?: '/' | '\\\\' } = {},\n): {\n key: string\n serverName: string\n}[] {\n ensureLoaded()\n const sep = p.separator ?? '/'\n const out: { key: string; serverName: string }[] = []\n for (const [key, item] of byHost.get(hostId) ?? []) {\n // file_path carries the extension the enum value needs; file_name may not\n const filePath = lmFilePath(item)\n const base = filePath == null ? null : (filePath.split(/[/\\\\]/).pop() ?? null)\n const file = base ?? lmFileName(item)\n if (file == null) continue\n const folder = lmFolder(item)\n // the manager's own `folder` can be a NESTED path with its own separators, so the whole\n // name is normalized to the host's style, never just the join (8 of 119 came out mixed)\n const joined = folder === '' ? file : `${folder}/${file}`\n out.push({ key, serverName: joined.replaceAll(/[\\\\/]/g, sep) })\n }\n return out.sort((a, b) => a.serverName.localeCompare(b.serverName))\n}\n\nexport function loraSearchNames(name: string, hostId?: string): string[] {\n const names = [loraBasename(name), name.replaceAll('\\\\', '/')]\n const info = getLoraInfo(name, hostId)\n const modelName = info == null ? null : lmModelName(info)\n if (modelName != null) names.push(modelName)\n return names\n}\n\n/** the lora's FREE TEXT: tags, base model, trigger words */\nexport function loraSearchText(name: string, hostId?: string): string[] {\n const info = getLoraInfo(name, hostId)\n if (info == null) return []\n const text = [...lmTags(info), ...lmTrainedWords(info)]\n const baseModel = lmBaseModel(info)\n if (baseModel != null) text.push(baseModel)\n return text\n}\n\n/**\n * the loras overlay filter: find a lora by its human name, not only by the file\n * name. EVERY whitespace-separated token must be a SUBSTRING of some field — order\n * free, so `aurora ink`, `ink aurora` and `styles wash` all land on the same\n * lora. NOT fuzzyMatch: a subsequence match over phrases this long matches\n * nearly everything. Measured on a real collection, filtering by each lora's\n * own file name: this rule peaks at 8 hits where fuzzyMatch matched a third of\n * every lora present.\n * Fields are matched one by one, never as a concatenated haystack, for the same\n * reason. `tests/lora-corpus.private.test.ts` keeps that measurement runnable.\n */\nexport function loraMatchesFilter(name: string, filter: string, hostId?: string): boolean {\n const tokens = filter\n .toLowerCase()\n .split(/\\s+/)\n .filter((t) => t !== '')\n if (tokens.length === 0) return true\n const fields = [...loraSearchNames(name, hostId), ...loraSearchText(name, hostId)].map((f) => f.toLowerCase())\n return tokens.every((token) => fields.some((field) => field.includes(token)))\n}\n\n/** the loras a host lists that the local copy of its lora manager list does not know yet:\n * downloaded after the last sync, so they have no name, preview or trigger words here */\nexport function lorasMissingFromMirror(hostLoras: readonly string[], inMirror: (name: string) => boolean): string[] {\n return hostLoras.filter((n) => !inMirror(n))\n}\n","import { observable, runInAction } from 'mobx'\nimport { join } from 'pathe'\nimport { getLoraTriggerWords } from 'src/host/loraInfoCache.ts'\nimport { getComfyStorage } from 'src/storage/ComfyStorage.ts'\nimport { logError } from 'src/utils/log.ts'\n\n/**\n * hand-assigned trigger keyword(s) per lora name — set via ⌃K in the TUI loras\n * overlay, consumed by PromptVar's `loraKeywordsFrom` prefixing. Persisted at\n * `.comfy-ts/lora-keywords.json` (NOT under cache/: this is hand-entered data\n * and must survive a cache wipe). Observable map: overlay rows re-render on\n * assignment. Keys are the RAW lora names (folder/file.safetensors).\n *\n * This file is the OVERRIDE layer. Below it sits the lora-manager mirror's\n * civitai trigger words (src/host/loraInfoCache.ts, refreshed by\n * `comfy-ts loras`), so most loras carry a keyword without anyone typing one.\n * The overlay renders a mirror-sourced keyword dim and a hand-typed one yellow,\n * and ⌃D drops the override to fall back to the mirror again.\n */\nconst keywords = observable.map<string, string>()\nlet loaded = false\n\nfunction filePath(): string {\n return join(comfyts.baseFolder, 'lora-keywords.json')\n}\n\nfunction loadOnce(): void {\n if (loaded) return\n loaded = true\n const path = filePath()\n const text = getComfyStorage().readTextIfExists(path)\n if (text == null) return\n try {\n const raw: unknown = JSON.parse(text)\n if (raw == null || typeof raw !== 'object') return\n runInAction(() => {\n for (const [name, kw] of Object.entries(raw)) if (typeof kw === 'string') keywords.set(name, kw)\n })\n } catch (e) {\n logError(`[loraKeywords] unreadable ${path}: ${String(e)}`)\n }\n}\n\n/** the hand keyword when this lora HAS an entry (`''` included), else the mirror's trigger words */\nexport function getLoraKeyword(name: string, hostId?: string): string {\n loadOnce()\n const hand = keywords.get(name)\n if (hand != null) return hand\n return getLoraTriggerWords(name, hostId).join(', ')\n}\n\n/** true when the keyword shown comes from the lora-manager mirror, not from ⌃K */\nexport function isLoraKeywordFromMirror(name: string, hostId?: string): boolean {\n loadOnce()\n return !keywords.has(name) && getLoraTriggerWords(name, hostId).length > 0\n}\n\n/** what `clearLoraKeywordOverride` would restore this lora to, `''` when nothing */\nexport function loraKeywordFromMirror(name: string, hostId?: string): string {\n return getLoraTriggerWords(name, hostId).join(', ')\n}\n\n/**\n * drop the hand entry entirely, so the mirror's trigger words apply again.\n * The way BACK from an empty-string tombstone: without it, clearing a keyword on\n * a lora that has trigger words was a one-way door only a text editor could undo.\n */\nexport function clearLoraKeywordOverride(name: string): void {\n loadOnce()\n if (!keywords.has(name)) return\n runInAction(() => void keywords.delete(name))\n writeKeywords()\n}\n\n/**\n * empty keyword deletes the entry — EXCEPT when the mirror has trigger words for\n * this lora: there `''` is stored as an explicit tombstone, the only way to say\n * \"inject nothing\" about a lora civitai gave words to. Every set writes the file\n * (tiny, rare).\n */\nexport function setLoraKeyword(name: string, keyword: string, hostId?: string): void {\n loadOnce()\n const trimmed = keyword.trim()\n runInAction(() => {\n if (trimmed === '' && getLoraTriggerWords(name, hostId).length === 0) keywords.delete(name)\n else keywords.set(name, trimmed)\n })\n writeKeywords()\n}\n\n/** every set writes the file: it is tiny and hand-edited rarely */\nfunction writeKeywords(): void {\n const path = filePath()\n try {\n getComfyStorage().writeText(path, JSON.stringify(Object.fromEntries([...keywords.entries()].sort()), null, 2))\n } catch (e) {\n logError(`[loraKeywords] write failed ${path}: ${String(e)}`)\n }\n}\n","// one lora's stored setting, read the same way by LorasVar, serve and the web panel. PURE and\n// dependency-free, so the browser bundle imports it without pulling ComfyVars in.\n// absent not in the palette\n// false off, not in the palette (what an untick in the TUI writes)\n// true | n on, both strengths 1 | n\n// [m, c] on, each strength\n// { strength: [m, c], off?: true, mute?: string[] }\n// the palette form: `off` pauses it without forgetting it or its strengths,\n// `mute` the parts of its prompt keyword (split at commas) left out of the\n// prompt. Grouping loras into lanes is the VAR's shape, src/vars/lanes.ts\n\nexport type LoraEntry = {\n strength: [strengthModel: number, strengthClip: number]\n off?: boolean\n mute?: string[]\n}\n\nexport type LoraStrength = boolean | number | [strengthModel: number, strengthClip: number] | LoraEntry\n\nexport function isLoraEntry(s: unknown): s is LoraEntry {\n if (typeof s !== 'object' || s == null || Array.isArray(s)) return false\n const o = s as Record<string, unknown>\n const st = o.strength\n return (\n Array.isArray(st) &&\n st.length === 2 &&\n typeof st[0] === 'number' &&\n Number.isFinite(st[0]) &&\n typeof st[1] === 'number' &&\n Number.isFinite(st[1]) &&\n (o.off == null || typeof o.off === 'boolean') &&\n (o.mute == null || (Array.isArray(o.mute) && o.mute.every((w) => typeof w === 'string')))\n )\n}\n\nexport function isLoraStrength(s: unknown): s is LoraStrength {\n if (typeof s === 'boolean') return true\n if (typeof s === 'number') return Number.isFinite(s)\n if (Array.isArray(s)) return s.length === 2 && s.every((n) => typeof n === 'number' && Number.isFinite(n))\n return isLoraEntry(s)\n}\n\n/** on = it runs */\nexport function loraIsOn(s: unknown): boolean {\n if (s == null || s === false) return false\n if (isLoraEntry(s)) return s.off !== true\n return true\n}\n\n/** in the palette = on, or paused in the palette form */\nexport function loraInPalette(s: unknown): boolean {\n return loraIsOn(s) || (isLoraEntry(s) && s.off === true)\n}\n\n/** the strengths, whatever the spelling (1/1 when there is nothing to read) */\nexport function loraStrengths(s: unknown): [number, number] {\n if (typeof s === 'number' && Number.isFinite(s)) return [s, s]\n if (Array.isArray(s) && typeof s[0] === 'number' && typeof s[1] === 'number') return [s[0], s[1]]\n if (isLoraEntry(s)) return [s.strength[0], s.strength[1]]\n return [1, 1]\n}\n\nexport function loraMuted(s: unknown): string[] {\n return isLoraEntry(s) && s.mute != null ? s.mute : []\n}\n\n/** a prompt keyword's parts, split at commas: each one can be left out on its own */\nexport function keywordParts(keyword: string): string[] {\n return [\n ...new Set(\n keyword\n .split(',')\n .map((w) => w.trim())\n .filter((w) => w !== ''),\n ),\n ]\n}\n\n/** the keyword a lora adds to the prompt once its muted parts are left out ('' = nothing) */\nexport function keptKeyword(keyword: string, muted: readonly string[]): string {\n return keywordParts(keyword)\n .filter((w) => !muted.includes(w))\n .join(', ')\n}\n\n/** rewrite one setting, keeping what the patch does not name. The result stays in the short\n * spellings while nothing needs the palette form, so a plain draft reads as it always did */\nexport function withLora(\n s: unknown,\n patch: { on?: boolean; strength?: [number, number]; mute?: readonly string[] },\n): LoraStrength {\n const strength = patch.strength ?? loraStrengths(s)\n const off = patch.on == null ? !loraIsOn(s) : !patch.on\n const mute = [...(patch.mute ?? loraMuted(s))]\n if (!off && mute.length === 0) return [strength[0], strength[1]]\n return {\n strength: [strength[0], strength[1]],\n ...(off ? { off: true } : {}),\n ...(mute.length === 0 ? {} : { mute }),\n }\n}\n","// lanes: the second value shape of a prompt or loras var. A var holds EITHER its plain value OR\n// `{ lanes: [...] }`; the build merges the active lanes in listed order. PURE and dependency-free\n// (the browser bundle imports it), every shape runtime-checked like loraEntry.ts.\nimport { isLoraStrength, loraIsOn, type LoraStrength } from 'src/vars/loraEntry.ts'\n\nexport type PromptLane = { name: string; prompt: string; active: boolean }\nexport type PromptLanes = { lanes: PromptLane[] }\nexport type PromptInput = string | PromptLanes\n\nexport type LoraRecord<T extends string = string> = Partial<Record<T, LoraStrength>>\nexport type LoraLane<T extends string = string> = { name: string; active: boolean; loras: LoraRecord<T> }\nexport type LoraLanes<T extends string = string> = { lanes: LoraLane<T>[] }\n/** a lora file is never named `lanes` (options end in .safetensors), so the plain record and the\n * lanes object can never be mistaken for each other */\nexport type LorasInput<T extends string = string> = LoraRecord<T> | LoraLanes<T>\n\nexport const FIRST_LANE = 'main'\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v != null && !Array.isArray(v)\n}\n\n// ---- prompt ----\n\nexport function isPromptLane(v: unknown): v is PromptLane {\n return isObject(v) && typeof v.name === 'string' && typeof v.prompt === 'string' && typeof v.active === 'boolean'\n}\n\nexport function isPromptLanes(v: unknown): v is PromptLanes {\n return isObject(v) && Array.isArray(v.lanes) && v.lanes.every(isPromptLane)\n}\n\nexport function isPromptInput(v: unknown): v is PromptInput {\n return typeof v === 'string' || isPromptLanes(v)\n}\n\n/** the text the build reads: the active lanes joined in order, one line break between them, so\n * `//` and `- ` lines keep working inside every lane */\nexport function promptText(v: PromptInput): string {\n if (typeof v === 'string') return v\n return v.lanes\n .filter((l) => l.active)\n .map((l) => l.prompt)\n .join('\\n')\n}\n\nexport function toPromptLanes(v: PromptInput): PromptLanes {\n return typeof v === 'string' ? { lanes: [{ name: FIRST_LANE, prompt: v, active: true }] } : v\n}\n\n/** back to one string: only when it loses nothing (a single active lane) */\nexport function promptFromLanes(v: PromptLanes): string | null {\n const only = v.lanes[0]\n return v.lanes.length === 1 && only != null && only.active ? only.prompt : null\n}\n\n// the TUI edits a prompt as text: lanes round-trip through header lines, so it never flattens\n// them. `# name` starts a lane, `# name (off)` an inactive one\nconst HEADER = /^# (.+?)( \\(off\\))?$/\n\nexport function promptLanesToText(v: PromptLanes): string {\n return v.lanes.map((l) => `# ${l.name}${l.active ? '' : ' (off)'}\\n${l.prompt}`).join('\\n')\n}\n\n/** text before the first header lands in a lane named FIRST_LANE, so no typed line is lost */\nexport function promptLanesFromText(text: string): PromptLanes {\n const lanes: PromptLane[] = []\n let current: PromptLane | null = null\n const body: string[] = []\n const close = (): void => {\n if (current != null) lanes.push({ ...current, prompt: body.join('\\n') })\n else if (body.some((l) => l.trim() !== ''))\n lanes.push({ name: FIRST_LANE, prompt: body.join('\\n'), active: true })\n body.length = 0\n }\n for (const line of text.split('\\n')) {\n const m = HEADER.exec(line)\n if (m == null) {\n body.push(line)\n continue\n }\n close()\n current = { name: (m[1] ?? '').trim(), prompt: '', active: m[2] == null }\n }\n close()\n return { lanes: lanes.length > 0 ? lanes : [{ name: FIRST_LANE, prompt: '', active: true }] }\n}\n\n// ---- loras ----\n\nfunction isLoraRecord(v: unknown): v is LoraRecord {\n return isObject(v) && !('lanes' in v) && Object.values(v).every((s) => s == null || isLoraStrength(s))\n}\n\nexport function isLoraLane(v: unknown): v is LoraLane {\n return isObject(v) && typeof v.name === 'string' && typeof v.active === 'boolean' && isLoraRecord(v.loras)\n}\n\nexport function isLoraLanes<T extends string>(v: LorasInput<T>): v is LoraLanes<T>\nexport function isLoraLanes(v: unknown): v is LoraLanes\nexport function isLoraLanes(v: unknown): v is LoraLanes {\n return isObject(v) && Array.isArray(v.lanes) && v.lanes.every(isLoraLane)\n}\n\nexport function isLorasInput(v: unknown): v is LorasInput {\n return isLoraRecord(v) || isLoraLanes(v)\n}\n\n/** one record for the build: the active lanes in order. A lora in two active lanes keeps its\n * FIRST setting, and `duplicates` names it so the caller can say so */\nexport function flattenLoras<T extends string>(v: LorasInput<T>): { record: LoraRecord<T>; duplicates: T[] } {\n if (!isLoraLanes(v)) return { record: v, duplicates: [] }\n const record: LoraRecord<T> = {}\n const duplicates: T[] = []\n for (const lane of v.lanes) {\n if (!lane.active) continue\n for (const [name, st] of Object.entries(lane.loras) as [T, LoraStrength | undefined][]) {\n if (st == null) continue\n if (name in record) duplicates.push(name)\n else record[name] = st\n }\n }\n return { record, duplicates }\n}\n\nexport function toLoraLanes<T extends string>(v: LorasInput<T>): LoraLanes<T> {\n return isLoraLanes(v) ? v : { lanes: [{ name: FIRST_LANE, active: true, loras: v }] }\n}\n\nexport function lorasFromLanes<T extends string>(v: LoraLanes<T>): LoraRecord<T> | null {\n const only = v.lanes[0]\n return v.lanes.length === 1 && only != null && only.active ? only.loras : null\n}\n\n/** where a lora lives, so an edit lands in the lane that holds it: the first ACTIVE lane that\n * has it (the one the build reads), else any lane, else -1 */\nexport function laneIndexOf<T extends string>(v: LoraLanes<T>, name: T): number {\n const active = v.lanes.findIndex((l) => l.active && l.loras[name] != null)\n return active !== -1 ? active : v.lanes.findIndex((l) => l.loras[name] != null)\n}\n\n/** rewrite one lora's setting wherever it lives (plain record, or its lane). `null` removes it.\n * A lora in no lane yet lands in the first lane */\nexport function updateLora<T extends string>(v: LorasInput<T>, name: T, next: LoraStrength | null): LorasInput<T> {\n const write = (rec: LoraRecord<T>): LoraRecord<T> => {\n const out = { ...rec }\n if (next == null) delete out[name]\n else out[name] = next\n return out\n }\n if (!isLoraLanes(v)) return write(v)\n if (v.lanes.length === 0) return { lanes: [{ name: FIRST_LANE, active: true, loras: write({}) }] }\n const found = laneIndexOf(v, name)\n const ix = found === -1 ? 0 : found\n return { lanes: v.lanes.map((l, i) => (i === ix ? { ...l, loras: write(l.loras) } : l)) }\n}\n\n// ---- lane list edits, the same for prompt and lora lanes ----\n\ntype NamedLane = { name: string; active: boolean }\n\n/** a name no other lane has: `lane 2`, `lane 3`… */\nexport function newLaneName(lanes: readonly NamedLane[]): string {\n const taken = new Set(lanes.map((l) => l.name))\n let n = lanes.length + 1\n while (taken.has(`lane ${n}`)) n++\n return `lane ${n}`\n}\n\nexport function patchLane<L extends NamedLane>(lanes: readonly L[], ix: number, patch: Partial<L>): L[] {\n return lanes.map((l, i) => (i === ix ? { ...l, ...patch } : l))\n}\n\n/** move a lane up (-1) or down (+1); out of range changes nothing */\nexport function moveLane<L>(lanes: readonly L[], ix: number, delta: number): L[] {\n const to = ix + delta\n if (ix < 0 || ix >= lanes.length || to < 0 || to >= lanes.length) return [...lanes]\n const out = [...lanes]\n const [moved] = out.splice(ix, 1)\n if (moved != null) out.splice(to, 0, moved)\n return out\n}\n\nexport function removeLane<L>(lanes: readonly L[], ix: number): L[] {\n return lanes.filter((_, i) => i !== ix)\n}\n\n/** move one lora to another lane (or another slot of its own), before `beforeName` or last */\nexport function moveLoraToLane<T extends string>(\n v: LoraLanes<T>,\n p: { from: number; name: T; to: number; beforeName?: T },\n): LoraLanes<T> {\n const src = v.lanes[p.from]\n const setting = src?.loras[p.name]\n if (src == null || setting == null || v.lanes[p.to] == null) return v\n const lanes = v.lanes.map((l) => ({ ...l, loras: { ...l.loras } }))\n const from = lanes[p.from]\n const to = lanes[p.to]\n if (from == null || to == null) return v\n delete from.loras[p.name]\n const out: LoraRecord<T> = {}\n let placed = false\n for (const [k, st] of Object.entries(to.loras) as [T, LoraStrength | undefined][]) {\n if (k === p.beforeName && !placed) {\n out[p.name] = setting\n placed = true\n }\n out[k] = st\n }\n if (!placed) out[p.name] = setting\n to.loras = out\n return { lanes }\n}\n\n/** one lora's stored setting wherever it lives, inactive lanes included (the lane an edit\n * would write to, `updateLora`), or undefined */\nexport function loraSetting<T extends string>(v: LorasInput<T>, name: T): LoraStrength | undefined {\n if (!isLoraLanes(v)) return v[name]\n return v.lanes[laneIndexOf(v, name)]?.loras[name]\n}\n\n/** every lora in the palette of either shape, each once, with whether the build runs it: a lora\n * in an inactive lane, or paused, is there but not running */\nexport function paletteLoras<T extends string>(\n v: LorasInput<T>,\n): { name: T; setting: LoraStrength; running: boolean }[] {\n const out = new Map<T, { name: T; setting: LoraStrength; running: boolean }>()\n const lanes = isLoraLanes(v) ? v.lanes : [{ name: '', active: true, loras: v }]\n for (const lane of lanes)\n for (const [name, setting] of Object.entries(lane.loras) as [T, LoraStrength | undefined][]) {\n if (setting == null || setting === false) continue\n const running = lane.active && loraIsOn(setting)\n const seen = out.get(name)\n // a running copy wins over a stopped one, as it does in the build\n if (seen == null || (!seen.running && running)) out.set(name, { name, setting, running })\n }\n return [...out.values()]\n}\n","// prompt text rules shared by the build (PromptVar.outValue) and the web editor, so the editor's\n// colors can never disagree with what a run sends. PURE and import-free: the browser bundle takes it\n\n/** a whole line that is a comment (the TUI colors these) */\nexport const COMMENT_LINE_RE = /^\\s*\\/\\//\n/** a negative prompt line: `- ` then its text */\nexport const NEGATIVE_LINE_RE = /^\\s*- (.*)$/\nconst NEGATIVE_PREFIX_RE = /^(\\s*)- /\n\n/** where a `//` comment starts on this line, -1 when none. Only at line start or after\n * whitespace, so `http://host` is never cut */\nexport function commentStart(line: string): number {\n const m = /(?:^|\\s)\\/\\//.exec(line)\n if (m == null) return -1\n return m.index + m[0].length - 2\n}\n\n/** the line without its comment, trailing whitespace dropped with it */\nfunction withoutComment(line: string): { text: string; hadComment: boolean } {\n const c = commentStart(line)\n return c < 0 ? { text: line, hadComment: false } : { text: line.slice(0, c).trimEnd(), hadComment: true }\n}\n\n/** the build's reading of a prompt: comments out, `- ` lines comma-joined into the negative */\nexport function parsePromptText(text: string): { positive: string; negative: string } {\n const pos: string[] = []\n const neg: string[] = []\n for (const raw of text.split('\\n')) {\n const cut = withoutComment(raw)\n if (cut.hadComment && cut.text.trim() === '') continue\n const m = NEGATIVE_PREFIX_RE.exec(raw)\n if (m != null && m[0].length <= cut.text.length + 1) {\n const body = cut.text.slice(m[0].length).trim()\n if (body !== '') neg.push(body)\n } else pos.push(cut.text)\n }\n return { positive: pos.join('\\n').trim(), negative: neg.join(', ') }\n}\n\n// #region lines ---------------------------------------------------------------\n\ntype Line = { from: number; text: string }\n\nfunction linesOf(text: string): Line[] {\n const out: Line[] = []\n let from = 0\n for (const t of text.split('\\n')) {\n out.push({ from, text: t })\n from += t.length + 1\n }\n return out\n}\n\n// #region weights --------------------------------------------------------------\n\n/** one `(text:1.2)` group on a line, offsets local to that line */\nexport type WeightGroup = {\n from: number\n to: number\n innerFrom: number\n innerTo: number\n numFrom: number\n numTo: number\n weight: number\n}\n\n/** ComfyUI weight groups, innermost only (no nested parens inside), `\\(` `\\)` skipped as literal */\nexport function findWeights(line: string): WeightGroup[] {\n const out: WeightGroup[] = []\n const re = /(?<!\\\\)\\(((?:\\\\[()]|[^()])*?):\\s*(-?\\d*\\.?\\d+)\\s*(?<!\\\\)\\)/g\n for (let m = re.exec(line); m != null; m = re.exec(line)) {\n const inner = m[1] ?? ''\n const num = m[2] ?? '1'\n const from = m.index\n const to = from + m[0].length\n const numFrom = from + m[0].lastIndexOf(num)\n out.push({\n from,\n to,\n innerFrom: from + 1,\n innerTo: from + 1 + inner.length,\n numFrom,\n numTo: numFrom + num.length,\n weight: Number(num),\n })\n }\n return out\n}\n\nconst round2 = (n: number): number => Math.round(n * 100) / 100\nexport const formatWeight = (w: number): string => String(round2(w))\n\nexport type TextChange = { from: number; to: number; insert: string }\nexport type EditResult = { changes: TextChange[]; selection: { anchor: number; head: number } }\n\n/** the comma-separated chunk around `col`, trimmed, never reaching into a comment */\nfunction tagAround(line: string, col: number): { from: number; to: number } | null {\n const c = commentStart(line)\n const end = c < 0 ? line.length : c\n if (col > end) return null\n let from = col\n while (from > 0 && line[from - 1] !== ',') from--\n let to = col\n while (to < end && line[to] !== ',') to++\n const neg = NEGATIVE_PREFIX_RE.exec(line)\n if (neg != null && from < neg[0].length) from = neg[0].length\n while (from < to && /\\s/.test(line[from] ?? '')) from++\n while (to > from && /\\s/.test(line[to - 1] ?? '')) to--\n return from < to ? { from, to } : null\n}\n\n/** weight ± delta on the selection, or on the tag under the cursor when nothing is selected.\n * Inside a group its number moves, and reaching 1 unwraps it; plain text gets wrapped. null when\n * there is nothing to weigh (an empty chunk, a comment, a selection over several lines) */\nexport function adjustWeight(text: string, from: number, to: number, delta: number): EditResult | null {\n const line = linesOf(text).find((l) => from >= l.from && from <= l.from + l.text.length)\n if (line == null || to > line.from + line.text.length) return null\n const f = from - line.from\n const t = to - line.from\n const c = commentStart(line.text)\n if (c >= 0 && f >= c) return null\n const enclosing = findWeights(line.text)\n .filter((g) => f >= g.from && t <= g.to)\n .sort((a, b) => a.to - a.from - (b.to - b.from))[0]\n if (enclosing != null) {\n const w = round2(enclosing.weight + delta)\n const inner = line.text.slice(enclosing.innerFrom, enclosing.innerTo)\n if (w === 1) {\n const at = line.from + enclosing.from\n return {\n changes: [{ from: at, to: line.from + enclosing.to, insert: inner }],\n selection: { anchor: at, head: at + inner.length },\n }\n }\n return {\n changes: [{ from: line.from + enclosing.numFrom, to: line.from + enclosing.numTo, insert: formatWeight(w) }],\n selection: { anchor: line.from + enclosing.innerFrom, head: line.from + enclosing.innerTo },\n }\n }\n let span: { from: number; to: number } | null\n if (f === t) span = tagAround(line.text, f)\n else {\n let a = f\n let b = t\n while (a < b && /\\s/.test(line.text[a] ?? '')) a++\n while (b > a && /\\s/.test(line.text[b - 1] ?? '')) b--\n span = a < b ? { from: a, to: b } : null\n }\n if (span == null) return null\n const w = round2(1 + delta)\n const at = line.from + span.from\n const end = line.from + span.to\n return {\n changes: [\n { from: at, to: at, insert: '(' },\n { from: end, to: end, insert: `:${formatWeight(w)})` },\n ],\n selection: { anchor: at + 1, head: end + 1 },\n }\n}\n\n// #region line toggles -------------------------------------------------------\n\n/** the lines a selection touches; a selection ending at column 0 leaves that last line out */\nfunction touchedLines(text: string, from: number, to: number): Line[] {\n const all = linesOf(text)\n const endAt = to > from && all.some((l) => l.from === to) ? to - 1 : to\n return all.filter((l) => l.from + l.text.length >= from && l.from <= endAt)\n}\n\n/** ⌘/ — comment the touched lines, or uncomment them when every non-empty one already is */\nexport function toggleComment(text: string, from: number, to: number): TextChange[] {\n const lines = touchedLines(text, from, to).filter((l) => l.text.trim() !== '')\n if (lines.length === 0) return []\n if (lines.every((l) => COMMENT_LINE_RE.test(l.text)))\n return lines.map((l) => {\n const at = l.text.indexOf('//')\n const len = l.text[at + 2] === ' ' ? 3 : 2\n return { from: l.from + at, to: l.from + at + len, insert: '' }\n })\n return lines\n .filter((l) => !COMMENT_LINE_RE.test(l.text))\n .map((l) => {\n const at = l.from + (/^\\s*/.exec(l.text)?.[0].length ?? 0)\n return { from: at, to: at, insert: '// ' }\n })\n}\n\n/** ⌘⇧- — move the touched lines into the negative prompt, or back out when all already are.\n * Comment lines are left alone */\nexport function toggleNegative(text: string, from: number, to: number): TextChange[] {\n const lines = touchedLines(text, from, to).filter((l) => l.text.trim() !== '' && !COMMENT_LINE_RE.test(l.text))\n if (lines.length === 0) return []\n if (lines.every((l) => NEGATIVE_PREFIX_RE.test(l.text)))\n return lines.map((l) => {\n const indent = NEGATIVE_PREFIX_RE.exec(l.text)?.[1]?.length ?? 0\n return { from: l.from + indent, to: l.from + indent + 2, insert: '' }\n })\n return lines\n .filter((l) => !NEGATIVE_PREFIX_RE.test(l.text))\n .map((l) => {\n const at = l.from + (/^\\s*/.exec(l.text)?.[0].length ?? 0)\n return { from: at, to: at, insert: '- ' }\n })\n}\n\n// #region highlighting -------------------------------------------------------\n\nexport type PromptMarkKind = 'comment' | 'negative' | 'negative-dash' | 'weight-paren' | 'weight-num'\nexport type PromptMark = { from: number; to: number; kind: PromptMarkKind }\n\n/** what the editor colors, in document order */\nexport function promptMarks(text: string): PromptMark[] {\n const out: PromptMark[] = []\n for (const l of linesOf(text)) {\n const c = commentStart(l.text)\n const end = c < 0 ? l.text.length : c\n const neg = NEGATIVE_PREFIX_RE.exec(l.text)\n if (neg != null && neg[0].length <= end + 1) {\n const dash = l.from + neg[0].length - 2\n out.push({ from: dash, to: dash + 1, kind: 'negative-dash' })\n if (l.from + neg[0].length < l.from + end)\n out.push({ from: l.from + neg[0].length, to: l.from + end, kind: 'negative' })\n }\n for (const g of findWeights(l.text.slice(0, end))) {\n out.push({ from: l.from + g.from, to: l.from + g.innerFrom, kind: 'weight-paren' })\n out.push({ from: l.from + g.innerTo, to: l.from + g.numFrom, kind: 'weight-paren' })\n out.push({ from: l.from + g.numFrom, to: l.from + g.numTo, kind: 'weight-num' })\n out.push({ from: l.from + g.numTo, to: l.from + g.to, kind: 'weight-paren' })\n }\n if (c >= 0) out.push({ from: l.from + c, to: l.from + l.text.length, kind: 'comment' })\n }\n return out.sort((a, b) => a.from - b.from || a.to - b.to)\n}\n\n// #region tag issues ---------------------------------------------------------\n\n/** the form two tags are compared in: weight wrapper off, literal parens unescaped, lowercase,\n * underscores as spaces */\nexport function normalizeTag(chunk: string): string {\n let s = chunk.trim()\n const whole = findWeights(s)[0]\n if (whole != null && whole.from === 0 && whole.to === s.length) s = s.slice(whole.innerFrom, whole.innerTo)\n return s\n .replace(/\\\\([()])/g, '$1')\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\nexport type TagIssue = { from: number; to: number; message: string }\n\ntype Chunk = { from: number; to: number; tag: string }\n\nfunction chunksOf(line: string, offset: number, start: number): Chunk[] {\n const out: Chunk[] = []\n let from = start\n for (let i = start; i <= line.length; i++) {\n if (i < line.length && line[i] !== ',') continue\n const raw = line.slice(from, i)\n const lead = raw.length - raw.trimStart().length\n const tag = normalizeTag(raw)\n if (tag !== '') out.push({ from: offset + from + lead, to: offset + from + raw.trimEnd().length, tag })\n from = i + 1\n }\n return out\n}\n\n/** a tag written twice, a tag a lora already adds, a tag in both prompts, and every weight when\n * the model ignores weights. Each issue carries the sentence the editor shows on hover */\nexport function tagIssues(\n text: string,\n p: { injected?: readonly { tag: string; source: string }[]; weights?: boolean } = {},\n): TagIssue[] {\n const out: TagIssue[] = []\n const positive: Chunk[] = []\n const negative: Chunk[] = []\n for (const l of linesOf(text)) {\n if (COMMENT_LINE_RE.test(l.text)) continue\n const body = withoutComment(l.text).text\n const neg = NEGATIVE_PREFIX_RE.exec(l.text)\n const isNeg = neg != null && neg[0].length <= body.length + 1\n const chunks = chunksOf(body, l.from, isNeg ? neg[0].length : 0)\n ;(isNeg ? negative : positive).push(...chunks)\n if (p.weights === false)\n for (const g of findWeights(body))\n out.push({\n from: l.from + g.from,\n to: l.from + g.to,\n message: 'this model ignores weights: the text inside is read, the number is not',\n })\n }\n const injected = new Map<string, string>()\n for (const i of p.injected ?? []) {\n const tag = normalizeTag(i.tag)\n if (tag !== '' && !injected.has(tag)) injected.set(tag, i.source)\n }\n const scan = (side: Chunk[], sideName: string): void => {\n const seen = new Set<string>()\n for (const ch of side) {\n if (seen.has(ch.tag))\n out.push({ from: ch.from, to: ch.to, message: `'${ch.tag}' is already in the ${sideName}` })\n seen.add(ch.tag)\n }\n }\n scan(positive, 'prompt')\n scan(negative, 'negative prompt')\n const negTags = new Set(negative.map((c) => c.tag))\n for (const ch of positive) {\n const source = injected.get(ch.tag)\n if (source != null)\n out.push({ from: ch.from, to: ch.to, message: `'${ch.tag}' is already added by the lora ${source}` })\n if (negTags.has(ch.tag))\n out.push({ from: ch.from, to: ch.to, message: `'${ch.tag}' is also in the negative prompt` })\n }\n return out.sort((a, b) => a.from - b.from)\n}\n\n// #region token estimate ------------------------------------------------------\n\n/** a rough CLIP token count of what the build sends as positive: one per short word, long words\n * split, one per punctuation mark. An ESTIMATE, the editor shows it with ≈ */\nexport function estimateTokens(text: string): number {\n const body = parsePromptText(text).positive\n let n = 0\n for (const m of body.matchAll(/\\p{L}+|\\p{N}|[^\\s\\p{L}\\p{N}]/gu)) {\n const w = m[0]\n n += /^\\p{L}/u.test(w) && w.length > 8 ? Math.ceil(w.length / 5) : 1\n }\n return n\n}\n\n// #region completion ------------------------------------------------------------\n\n/** the partial tag being typed at `col`: from the last `,` `(` or line start, leading spaces\n * and a negative `- ` skipped. null inside a comment */\nexport function completionWord(line: string, col: number): { from: number; text: string } | null {\n const c = commentStart(line)\n if (c >= 0 && col > c) return null\n let from = col\n while (from > 0 && !/[,(]/.test(line[from - 1] ?? '')) from--\n const neg = NEGATIVE_PREFIX_RE.exec(line)\n if (neg != null && from < neg[0].length) from = neg[0].length\n while (from < col && /\\s/.test(line[from] ?? '')) from++\n return { from, text: line.slice(from, col) }\n}\n\n/** what to search for at `col`: the whole chunk first, then its last words, longest first, so a\n * tag typed after prose or another tag with no comma between (`a girl with long ha`) still\n * completes. At most the last four word starts, an empty tail never */\nexport function completionCandidates(line: string, col: number): { from: number; text: string }[] {\n const word = completionWord(line, col)\n if (word == null) return []\n const out = [word]\n const starts: number[] = []\n for (let i = word.from + 1; i < col; i++)\n if (/\\s/.test(line[i - 1] ?? '') && !/\\s/.test(line[i] ?? '')) starts.push(i)\n for (const from of starts.slice(-4)) out.push({ from, text: line.slice(from, col) })\n return out\n}\n\nexport type TagFormat = { underscores?: boolean; weights?: boolean; artistPrefix?: string }\n\n/** a tag list name as the prompt wants it. Underscores between letters become spaces (`>_<`\n * keeps its own), parens get escaped where ComfyUI would read them as emphasis */\nexport function formatTag(name: string, category: number | null, p: TagFormat): string {\n let s = p.underscores === true ? name : name.replace(/(?<=[\\p{L}\\p{N})])_(?=[\\p{L}\\p{N}(])/gu, ' ')\n if (p.weights !== false) s = s.replace(/(?<!\\\\)([()])/g, '\\\\$1')\n if (category === TAG_CATEGORY_ARTIST && p.artistPrefix != null) s = `${p.artistPrefix}${s}`\n return s\n}\n\n/** danbooru categories as the a1111 tagcomplete csv numbers them */\nexport const TAG_CATEGORY_ARTIST = 1\nexport const TAG_CATEGORY_NAMES: Record<number, string> = {\n 0: 'general',\n 1: 'artist',\n 3: 'copyright',\n 4: 'character',\n 5: 'meta',\n}\n","// named starting texts for a text/prompt var. PURE and dependency-free on purpose: the\n// browser bundle imports it too (the web panel matches the live value against the list).\nexport type VarPreset = { label: string; text: string }\n\n/** authored shape: `{ 'terse one-liner': 'reply with one sentence…' }`. Key order is display order */\nexport type VarPresetSpec = Record<string, string>\n\nexport function toPresetList(spec: VarPresetSpec | undefined): VarPreset[] {\n if (spec == null) return []\n return Object.entries(spec).map(([label, text]) => ({ label, text }))\n}\n\n/** which preset the value still IS, or null once it was hand-edited (trailing whitespace ignored) */\nexport function activePresetLabel(presets: readonly VarPreset[], value: string): string | null {\n const v = value.trim()\n return presets.find((p) => p.text.trim() === v)?.label ?? null\n}\n","// Vars: the standard \"tweak & re-run\" contract. A workflow defined via\n// host.defineWorkflow({ vars, build }) rebuilds its graph from current var\n// values on every run — drivers (scripts, the TUI) edit vars between runs.\nimport { imageMeta } from 'image-meta'\nimport { action, makeObservable, observable } from 'mobx'\nimport { basename, isAbsolute, join, resolve } from 'pathe'\nimport { getComfyStorage } from 'src/storage/ComfyStorage.ts'\nimport { getLoraKeyword } from 'src/vars/loraKeywords.ts'\nimport {\n flattenLoras,\n isLorasInput,\n isPromptLanes,\n promptLanesFromText,\n promptLanesToText,\n promptText,\n updateLora,\n type LoraRecord,\n type LorasInput,\n type PromptInput,\n} from 'src/vars/lanes.ts'\nimport { keptKeyword, loraIsOn, loraMuted, loraStrengths, withLora, type LoraStrength } from 'src/vars/loraEntry.ts'\nimport { logError } from 'src/utils/log.ts'\nimport { COMMENT_LINE_RE, NEGATIVE_LINE_RE, parsePromptText } from 'src/vars/promptSyntax.ts'\nimport { toPresetList, type VarPreset, type VarPresetSpec } from 'src/vars/presets.ts'\nimport { DEFAULT_MEDIA_EXTENSIONS, extensionOf, mediaMime, type MediaKind } from 'src/runner/mediaKinds.ts'\nimport { hashArrayBuffer } from 'src/utils/hashArrayBuffer.ts'\nimport { statelessRegex } from 'src/utils/matchesRegex.ts'\nimport type { ComfyWorkflow } from 'src/runner/ComfyWorkflow.ts'\nimport type { NodeOf } from 'src/types/comfy-sdk.ts'\n\n/**\n * the var's CLASS, and the only safe way to discriminate one: `instanceof` compares class\n * OBJECTS, and the published package hands the same class out twice — a consumer's\n * `.cflow.ts` imports `comfy-ts` (dist/index.js) while `comfy-ts serve`/`tui` run from the\n * cli bundle, so every `instanceof XVar` across that boundary is false (observed\n * in a consumer app: \"var 'prompt' has unsupported kind 'text'\", for EVERY kind). A string tag\n * crosses bundles; a class identity does not.\n */\nexport type VarKind = 'text' | 'prompt' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size' | MediaKind\n\n/**\n * full base: T is what's STORED/edited, Out what the GRAPH consumes at build\n * time. They usually coincide — extend `ComfyVar<T>` for that. PromptVar is\n * the one Out-specialized var (string in, PromptValue out); the split keeps\n * outValue() cast-free.\n */\n/** how a var LOOKS in the panel, set by the workflow: `v.int(8).ui({ icon, color, description })`.\n * Every slot is optional, a color is any css color */\nexport type VarUi = {\n /** shown as a (?) after the label, the text is its tooltip */\n description?: string\n /** a 24×24 svg path drawn in the icon color, or a whole `<svg …>` string */\n icon?: string\n /** the icon's color */\n color?: string\n labelColor?: string\n /** the whole row, drawn without moving anything in it */\n background?: string\n /** vars that go together: consecutive vars with the same group share one tinted block */\n group?: string\n /** the block's tint, read from the first var of the group that sets it */\n groupColor?: string\n border?: string\n /** choice vars: a look per option, keyed by the option value. The lit option is filled\n * with its own color */\n options?: Record<string, { icon?: string; color?: string }>\n /** the field is shown but disabled unless every named var holds one of the listed values:\n * `{ model: ['aesthetic', 'base'] }`. Checked against the var names when the workflow loads.\n * Display only: a disabled var's value still reaches the build */\n activeWhen?: Record<string, readonly (string | number | boolean)[]>\n}\n\nexport abstract class ComfyVarBase<T, Out> {\n abstract readonly kind: VarKind\n /** the vars-spec key, stamped by DefinedWorkflow at define time — error messages name the var with it */\n name?: string\n /** panel looks, see VarUi. Never part of the value, never in a draft */\n uiOpts: VarUi = {}\n value: T\n constructor(\n public readonly defaultValue: T,\n public label?: string,\n ) {\n this.value = defaultValue\n // observable value: the TUI (mobx) re-renders when drivers mutate vars.\n // explicit makeObservable (not makeAutoObservable): base-class + subclass\n // combo. All mutators funnel through set()/reset()/parse() so they are\n // actions — subclass helpers call this.set(...) rather than assigning.\n makeObservable(this, { value: observable, set: action, reset: action, parse: action, loadJSON: action })\n }\n set(value: T): this {\n this.value = value\n return this\n }\n /** chainable: `v.choice([...], 'a').ui({ icon: 'M4 12h16', color: '#e0af68' })` */\n ui(p: VarUi): this {\n this.uiOpts = { ...this.uiOpts, ...p }\n return this\n }\n /** what drafts persist for this var (subclasses may add fields, e.g. seed mode) */\n toJSON(): unknown {\n return this.value\n }\n /** what the GRAPH consumes at build time (varValues maps these return types) */\n abstract outValue(): Out\n /**\n * restore a value produced by toJSON() (drafts). The cast is sanctioned:\n * drafts are our own round-trip, subclasses re-validate via set().\n */\n loadJSON(value: unknown): this {\n return this.set(value as T)\n }\n reset(): this {\n this.value = this.defaultValue\n return this\n }\n /** parse a raw string (TUI text input) into this var's value; returns false when invalid */\n abstract parse(raw: string): boolean\n /** how the value renders in a var list */\n display(): string {\n return String(this.value)\n }\n /** the string the inline editor starts from (round-trips through parse) */\n toEditBuffer(): string {\n return String(this.value)\n }\n /** hook run after every DefinedWorkflow.run() (default no-op; SeedVar advances) */\n afterRun(): void {}\n}\n\n/** the standard var: the graph consumes the stored value AS-IS (Out = T) */\nexport abstract class ComfyVar<T> extends ComfyVarBase<T, T> {\n outValue(): T {\n return this.value\n }\n}\n\nexport type TextVarOpts = {\n label?: string\n /** render as a box you can write paragraphs in, not a one-line field. Some text IS long by\n * nature (an llm instruction, a system prompt) and a single line hides all but its start */\n multiline?: boolean\n /** named starting texts, `{ label: text }`. The TUI and the web panel offer them behind one\n * button and picking one REPLACES the value, so a preset is a shortcut, never a mode */\n presets?: VarPresetSpec\n}\n\nexport class TextVar extends ComfyVar<string> {\n readonly kind = 'text' as const\n /** normalized `opts.presets`, in authored order */\n readonly presets: VarPreset[]\n readonly opts: TextVarOpts\n /** a bare label string was the whole second parameter before opts existed: a published\n * consumer passing one must keep working, exactly as SeedVar does */\n constructor(defaultValue: string, opts: string | TextVarOpts = {}) {\n const o = typeof opts === 'string' ? { label: opts } : opts\n super(defaultValue, o.label)\n this.opts = o\n this.presets = toPresetList(o.presets)\n }\n parse(raw: string): boolean {\n this.set(raw)\n return true\n }\n}\n\n/** what PromptVar needs from a loras var: covariant face, so LorasVar<'a'|'b'> fits.\n * `hostId` scopes the keyword lookup: the same file name on two hosts is often a\n * different model, and injecting the other host's trigger words is a silently\n * wrong generation. */\nexport type ActiveLoraSource = {\n activeNames(): string[]\n hostId?: string\n /** the parts of a lora's keyword left out of the prompt (LorasVar: the `mute` list) */\n mutedWords?(name: string): string[]\n}\n\n/** where a prompt's tag completion comes from (the serve web editor). The list is never shipped:\n * `url` is a local path (relative to the workflow file, `~/`, `file://`) or an http(s) url */\nexport type PromptTagsOpts = {\n url: string\n /** insert `long_hair` as written in the list; default inserts `long hair` */\n underscores?: boolean\n /** put in front of an artist tag on insert (Anima: `@`) */\n artistPrefix?: string\n}\n\nexport type PromptVarOpts = {\n label?: string\n loraKeywordsFrom?: ActiveLoraSource\n presets?: VarPresetSpec\n /** booru tag completion for this prompt: a tag list url, or the url with its insert rules */\n tags?: string | PromptTagsOpts\n /** false when the model's encoder ignores `(text:1.2)`: the editor then flags every weight */\n weights?: boolean\n}\n\n/** what a prompt CONTRIBUTES to build: `vars.prompt.positive` / `.negative` */\nexport type PromptValue = { positive: string; negative: string }\n\n/**\n * prompt text with editor comforts, all resolved at BUILD time (the editor and\n * drafts keep the raw text):\n * - `//` starts a COMMENT to the end of the line (src/vars/promptSyntax.ts) — stripped\n * - `- ` lines are NEGATIVE prompt lines — removed from `.positive`,\n * comma-joined into `.negative`\n * - with `loraKeywordsFrom`, the ACTIVE loras' hand-assigned keywords\n * (src/vars/loraKeywords.ts, ⌃K in the TUI) prefix `.positive` —\n * `injectedKeywords()` is public so the TUI can PREVIEW the injection.\n */\nexport class PromptVar extends ComfyVarBase<PromptInput, PromptValue> {\n readonly kind = 'prompt' as const\n /** normalized `promptOpts.presets`, in authored order (TextVarOpts.presets owns the WHY) */\n readonly presets: VarPreset[]\n constructor(\n defaultValue: PromptInput,\n public promptOpts: PromptVarOpts = {},\n ) {\n super(defaultValue, promptOpts.label)\n this.presets = toPresetList(promptOpts.presets)\n }\n /** in lanes mode the text carries `# name` headers, so a lane survives a round trip */\n parse(raw: string): boolean {\n this.set(isPromptLanes(this.value) ? promptLanesFromText(raw) : raw)\n return true\n }\n override toEditBuffer(): string {\n return isPromptLanes(this.value) ? promptLanesToText(this.value) : this.value\n }\n /** a var list shows the lanes by name, the inactive ones in parentheses */\n override display(): string {\n if (!isPromptLanes(this.value)) return super.display()\n return `${this.value.lanes.length} lanes: ${this.value.lanes.map((l) => (l.active ? l.name : `(${l.name})`)).join(', ')}`\n }\n /** the text the build reads: the plain string, or the active lanes joined in order */\n get text(): string {\n return promptText(this.value)\n }\n /** the tag list options in their one object form, null when this prompt has no completion */\n get tags(): PromptTagsOpts | null {\n const t = this.promptOpts.tags\n if (t == null) return null\n return typeof t === 'string' ? { url: t } : t\n }\n static isCommentLine(line: string): boolean {\n return COMMENT_LINE_RE.test(line)\n }\n static isNegativeLine(line: string): boolean {\n return NEGATIVE_LINE_RE.test(line)\n }\n /** the keyword prefix the flag will inject (deduped, lora-list order) — the TUI previews this */\n injectedKeywords(): string[] {\n const src = this.promptOpts.loraKeywordsFrom\n if (src == null) return []\n return [\n ...new Set(\n src\n .activeNames()\n .map((name) => keptKeyword(getLoraKeyword(name, src.hostId), src.mutedWords?.(name) ?? []))\n .filter((k) => k !== ''),\n ),\n ]\n }\n outValue(): PromptValue {\n const parsed = parsePromptText(this.text)\n const body = parsed.positive\n const keywords = this.injectedKeywords()\n const positive =\n keywords.length === 0 ? body : body === '' ? keywords.join(', ') : `${keywords.join(', ')}, ${body}`\n return { positive, negative: parsed.negative }\n }\n}\n\nexport class IntVar extends ComfyVar<number> {\n readonly kind = 'int' as const\n constructor(\n defaultValue: number,\n public opts: { min?: number; max?: number; label?: string } = {},\n ) {\n super(defaultValue, opts.label)\n }\n override set(value: number): this {\n const clamped = Math.round(Math.min(this.opts.max ?? Infinity, Math.max(this.opts.min ?? -Infinity, value)))\n return super.set(clamped)\n }\n parse(raw: string): boolean {\n const n = Number(raw)\n if (Number.isNaN(n)) return false\n this.set(n)\n return true\n }\n}\n\nexport class FloatVar extends ComfyVar<number> {\n readonly kind = 'float' as const\n constructor(\n defaultValue: number,\n public opts: { min?: number; max?: number; label?: string } = {},\n ) {\n super(defaultValue, opts.label)\n }\n override set(value: number): this {\n return super.set(Math.min(this.opts.max ?? Infinity, Math.max(this.opts.min ?? -Infinity, value)))\n }\n parse(raw: string): boolean {\n const n = Number(raw)\n if (Number.isNaN(n)) return false\n this.set(n)\n return true\n }\n}\n\n/** '=' fixed · '+' increment each run · '-' decrement each run · '?' reroll each run */\nexport type SeedMode = '=' | '+' | '-' | '?'\n\n/**\n * a seed is a MODE + a number. `value` stays a plain number (what the graph\n * consumes); `mode` decides how it advances after each run (afterRun()):\n * `= 12` fixed · `+ 0` auto-increment · `- 0` auto-decrement · `? 0` random.\n * The number shown is always the seed the NEXT run will use.\n */\nexport class SeedVar extends ComfyVar<number> {\n readonly kind = 'seed' as const\n mode: SeedMode\n /** the mode a reset() restores — the SPEC default, never the live one (introspection\n * reads this: a running mode must not masquerade as the var's default) */\n readonly defaultMode: SeedMode\n /** `opts` is the modern shape; a bare label string stays accepted, since that was the\n * signature before a workflow could declare the mode it wants to run in */\n constructor(defaultValue: number = 0, opts: string | { label?: string; mode?: SeedMode } = {}) {\n const o = typeof opts === 'string' ? { label: opts } : opts\n super(defaultValue, o.label)\n this.mode = o.mode ?? '='\n this.defaultMode = this.mode\n // subclass-owned observable field (base makeObservable already ran in super)\n makeObservable(this, { mode: observable, setMode: action, randomize: action, advance: action })\n }\n setMode(mode: SeedMode): this {\n this.mode = mode\n return this\n }\n randomize(): this {\n return this.set(Math.floor(Math.random() * 2 ** 32))\n }\n override set(value: number): this {\n // seeds are unsigned: clamp at 0 so decrement can't go negative\n return super.set(Math.max(0, Math.floor(value)))\n }\n /** move the seed to what the NEXT run should use, per mode */\n advance(): this {\n if (this.mode === '+') return this.set(this.value + 1)\n if (this.mode === '-') return this.set(this.value - 1)\n if (this.mode === '?') return this.randomize()\n return this // '=' stays fixed\n }\n override afterRun(): void {\n this.advance()\n }\n /** mode is part of the seed's state: a reset must not keep a caller's `?`/`+` alive\n * ('=' is the construction default; drafts restore their own mode via loadJSON) */\n override reset(): this {\n this.setMode(this.defaultMode)\n return super.reset()\n }\n /** parse `+` `- 12` `= 5` `?` or a bare number (=> fixed). Keeps the current number when none given */\n parse(raw: string): boolean {\n const m = raw.trim().match(/^([+\\-=?])?\\s*(\\d+)?$/)\n if (m == null) return false\n const modeChar = m[1]\n const numStr = m[2]\n if (modeChar == null && numStr == null) return false\n this.setMode(modeChar == null ? '=' : (modeChar as SeedMode))\n if (numStr != null) this.set(Number(numStr))\n return true\n }\n override display(): string {\n return `${this.mode} ${this.value}`\n }\n override toEditBuffer(): string {\n return `${this.mode} ${this.value}`\n }\n override toJSON(): unknown {\n return { mode: this.mode, value: this.value }\n }\n override loadJSON(value: unknown): this {\n if (typeof value === 'number') return this.set(value) // legacy plain-number drafts\n if (value != null && typeof value === 'object') {\n const o = value as { mode?: unknown; value?: unknown }\n if (o.mode === '=' || o.mode === '+' || o.mode === '-' || o.mode === '?') this.setMode(o.mode)\n if (typeof o.value === 'number') this.set(o.value)\n }\n return this\n }\n}\n\nexport class ToggleVar extends ComfyVar<boolean> {\n readonly kind = 'toggle' as const\n toggle(): this {\n return this.set(!this.value)\n }\n parse(raw: string): boolean {\n if (raw !== 'true' && raw !== 'false') return false\n this.set(raw === 'true')\n return true\n }\n override display(): string {\n return this.value ? 'ON' : 'OFF'\n }\n}\n\n/** how many options a choice holds: exactly one (the default), one or none, or any number */\nexport type ChoiceSelect = 'one' | 'zero-or-one' | 'many'\n\n/** where a host-bound choice reads its options: one loader input of the host's live schema,\n * optionally narrowed (`v.model`) */\nexport type HostSlotSource = { slot: string; filter?: RegExp }\n\n/** a fixed list, or the host's list for one slot once bindHost ran */\nclass ChoiceList<T extends string> {\n private resolved: readonly T[] | null = null\n constructor(readonly source: readonly T[] | HostSlotSource) {}\n get slot(): HostSlotSource | null {\n return isChoiceList(this.source) ? null : this.source\n }\n get choices(): readonly T[] {\n if (isChoiceList(this.source)) return this.source\n if (this.resolved == null)\n throw new Error(\n `v.model('${this.source.slot}') is host-bound — it only works inside defineWorkflow({ vars }) (pass a name list to v.choice otherwise)`,\n )\n return this.resolved\n }\n /** cast: whitelist family 1 (agent/coding.md) — stringValues() returns the runtime values of\n * the SAME object_info enum the generated slot union comes from */\n bind(host: LorasHost): void {\n const src = this.slot\n if (src == null) return\n const all = host.schema.stringValues(src.slot)\n const filter = src.filter == null ? null : statelessRegex(src.filter)\n this.resolved = (filter == null ? all : all.filter((n) => filter.test(n))) as T[]\n }\n}\n\nexport class ChoiceVar<T extends string> extends ComfyVar<T> {\n readonly kind = 'choice' as const\n readonly select = 'one' as const\n private list: ChoiceList<T>\n constructor(choices: readonly T[] | HostSlotSource, defaultValue: T, label?: string) {\n super(defaultValue, label)\n this.list = new ChoiceList(choices)\n }\n get choices(): readonly T[] {\n return this.list.choices\n }\n /** set for `v.model`: the loader input this choice lists */\n get hostSlot(): HostSlotSource | null {\n return this.list.slot\n }\n bindHost(host: LorasHost): void {\n this.list.bind(host)\n }\n next(delta: number = 1): this {\n const ix = this.choices.indexOf(this.value)\n const nextIx = (ix + delta + this.choices.length) % this.choices.length\n return this.set(this.choices[nextIx] ?? this.value)\n }\n parse(raw: string): boolean {\n const hit = this.choices.find((c) => c === raw)\n if (hit == null) return false\n this.set(hit)\n return true\n }\n}\n\n/** one option or none: `null` is \"nothing picked\", clicking the lit option clears it */\nexport class OptionalChoiceVar<T extends string> extends ComfyVar<T | null> {\n readonly kind = 'choice' as const\n readonly select = 'zero-or-one' as const\n private list: ChoiceList<T>\n constructor(choices: readonly T[] | HostSlotSource, defaultValue: T | null, label?: string) {\n super(defaultValue, label)\n this.list = new ChoiceList(choices)\n }\n get choices(): readonly T[] {\n return this.list.choices\n }\n get hostSlot(): HostSlotSource | null {\n return this.list.slot\n }\n bindHost(host: LorasHost): void {\n this.list.bind(host)\n }\n /** pick `c`, or clear it when it is already the one picked */\n toggle(c: T): this {\n return this.set(this.value === c ? null : c)\n }\n /** the TUI text form: a choice, or an empty line for none */\n parse(raw: string): boolean {\n if (raw.trim() === '') {\n this.set(null)\n return true\n }\n const hit = this.choices.find((c) => c === raw.trim())\n if (hit == null) return false\n this.set(hit)\n return true\n }\n override toEditBuffer(): string {\n return this.value ?? ''\n }\n /** a draft from when this was a many choice holds a list: its first known option */\n override loadJSON(value: unknown): this {\n const one = Array.isArray(value) ? value[0] : value\n return this.set(this.choices.find((c) => c === one) ?? null)\n }\n override display(): string {\n return this.value ?? 'none'\n }\n}\n\n/** any number of options, kept in the order the choices list them */\nexport class MultiChoiceVar<T extends string> extends ComfyVar<T[]> {\n readonly kind = 'choice' as const\n readonly select = 'many' as const\n constructor(\n public readonly choices: readonly T[],\n defaultValue: readonly T[],\n label?: string,\n ) {\n super([...defaultValue], label)\n }\n toggle(c: T): this {\n const on = this.value.includes(c)\n return this.set(this.choices.filter((x) => (x === c ? !on : this.value.includes(x))))\n }\n /** the TUI text form: `a, b` */\n parse(raw: string): boolean {\n const wanted = raw\n .split(',')\n .map((w) => w.trim())\n .filter((w) => w !== '')\n const picked = this.choices.filter((c) => wanted.includes(c))\n if (picked.length !== new Set(wanted).size) return false\n this.set(picked)\n return true\n }\n override toEditBuffer(): string {\n return this.value.join(', ')\n }\n /** a draft from when this was a single choice holds one value: a list of one. Unknown\n * options are dropped, the list comes back in the choices order */\n override loadJSON(value: unknown): this {\n const listed: unknown[] = Array.isArray(value) ? value : value == null ? [] : [value]\n return this.set(this.choices.filter((c) => listed.includes(c)))\n }\n override display(): string {\n return this.value.length === 0 ? 'none' : this.value.join(', ')\n }\n}\n\n/** the three choice shapes, told apart by `select` */\nexport type AnyChoiceVar<T extends string = string> = ChoiceVar<T> | OptionalChoiceVar<T> | MultiChoiceVar<T>\n\ntype ChoiceOpts<S extends ChoiceSelect> = { label?: string; select: S }\n\n/** Array.isArray does not narrow a READONLY array out of a union, this does */\nfunction isChoiceList<T extends string>(v: T | null | readonly T[] | HostSlotSource): v is readonly T[] {\n return Array.isArray(v)\n}\n\nfunction choice<const T extends string>(\n choices: readonly T[],\n defaultValue: T,\n label?: string | { label?: string; select?: 'one' },\n): ChoiceVar<T>\nfunction choice<const T extends string>(\n choices: readonly T[],\n defaultValue: T | null,\n opts: ChoiceOpts<'zero-or-one'>,\n): OptionalChoiceVar<T>\nfunction choice<const T extends string>(\n choices: readonly T[],\n defaultValue: readonly T[],\n opts: ChoiceOpts<'many'>,\n): MultiChoiceVar<T>\nfunction choice<const T extends string>(\n choices: readonly T[],\n defaultValue: T | null | readonly T[],\n opts?: string | { label?: string; select?: ChoiceSelect },\n): AnyChoiceVar<T> {\n const o = typeof opts === 'string' ? { label: opts } : (opts ?? {})\n const select = o.select ?? 'one'\n if (select === 'many') {\n if (!isChoiceList(defaultValue))\n throw new Error(`a 'many' choice takes a list as its default, got ${String(defaultValue)}`)\n return new MultiChoiceVar(choices, defaultValue, o.label)\n }\n if (isChoiceList(defaultValue)) throw new Error(`a '${select}' choice takes one value as its default, not a list`)\n if (select === 'zero-or-one') return new OptionalChoiceVar(choices, defaultValue, o.label)\n if (defaultValue == null) throw new Error(\"a 'one' choice needs a default: use { select: 'zero-or-one' } for none\")\n return new ChoiceVar(choices, defaultValue, o.label)\n}\n\nexport type ModelVarOpts<T extends string> = {\n /** narrows the host's list: `/krea/i` */\n filter?: RegExp\n label?: string\n /** a file name, or null for \"the workflow decides\" (the build then reads null) */\n default: T | null\n}\n\n/** a choice over the host's LIVE file list for one loader input (`'UNETLoader.unet_name'`),\n * resolved at define time and rebound by serve's refresh-schema: a downloaded model is picked\n * in the draft, never written into the workflow file */\nfunction model<T extends string>(slot: string, opts: ModelVarOpts<T> & { default: T }): ChoiceVar<T>\nfunction model<T extends string>(slot: string, opts: ModelVarOpts<T> & { default: null }): OptionalChoiceVar<T>\nfunction model<T extends string>(slot: string, opts: ModelVarOpts<T>): ChoiceVar<T> | OptionalChoiceVar<T> {\n const source: HostSlotSource = { slot, filter: opts.filter }\n if (opts.default == null) return new OptionalChoiceVar<T>(source, null, opts.label)\n return new ChoiceVar<T>(source, opts.default, opts.label)\n}\n\n/** per-lora setting, every spelling documented in src/vars/loraEntry.ts */\nexport type { LoraStrength } from 'src/vars/loraEntry.ts'\n\nexport type ActiveLora<T extends string> = { lora_name: T; strength_model: number; strength_clip: number }\n\n/** normalize a loras record into what a standard LoraLoader chain consumes */\nexport function activeLoras<T extends string>(loras: LorasInput<T>): ActiveLora<T>[] {\n const out: ActiveLora<T>[] = []\n for (const [lora_name, s] of Object.entries(flattenLoras(loras).record) as [T, LoraStrength | undefined][]) {\n // a paused lora ({ off: true }) is in the palette, never in the graph\n if (!loraIsOn(s)) continue\n const [strength_model, strength_clip] = loraStrengths(s)\n out.push({ lora_name, strength_model, strength_clip })\n }\n return out\n}\n\n/** what LorasVar.bindHost needs — structural, so ComfyVars never imports ComfyHost */\nexport type LorasHost = {\n data?: { id?: string }\n schema: { getLoras(filter?: RegExp): string[]; stringValues(slot: string): string[] }\n}\n\n/**\n * multi-select lora stack over a DYNAMIC options list — a RegExp resolves\n * against the host's loras at define time (DefinedWorkflow calls bindHost),\n * or feed it host discovery (`host.schema.getLoras(regex?)`) directly; never\n * a hardcoded inventory. Selection is empty by default.\n */\n/**\n * the value is EITHER a plain record OR `{ lanes: [...] }` (src/vars/lanes.ts): named groups the\n * build merges in listed order, skipping inactive ones. Every method reads the merged record and\n * writes into the lane that holds the lora, so the TUI never needs to know lanes exist\n */\nexport class LorasVar<T extends string> extends ComfyVarBase<LorasInput<T>, LoraRecord<T>> {\n readonly kind = 'loras' as const\n /** last non-false strength per lora, so untick → re-tick restores it */\n private prev: Partial<Record<T, LoraStrength>> = {}\n /** a RegExp source resolves lazily (bindHost) — null until then */\n private resolvedOptions: readonly T[] | null = null\n /** which host these loras live on, so their metadata is read from ITS mirror */\n hostId: string | undefined = undefined\n\n constructor(\n private readonly optionsSource: readonly T[] | RegExp,\n initial: LorasInput<T> = {},\n label?: string,\n ) {\n super(initial, label)\n }\n\n /** the filter the workflow declared, when it declared one (`v.loras(/krea-?2/i)`). Public so\n * a UI can SHOW it, and so serve applies the same narrowing to loras only its lora-manager\n * mirror knows, an unfiltered union would put the whole catalog back in a filtered picker */\n get optionsFilter(): RegExp | null {\n return this.optionsSource instanceof RegExp ? this.optionsSource : null\n }\n\n get options(): readonly T[] {\n if (!(this.optionsSource instanceof RegExp)) return this.optionsSource\n if (this.resolvedOptions == null)\n throw new Error(\n `v.loras(${String(this.optionsSource)}) is host-bound — it only works inside defineWorkflow({ vars }) (pass a name list otherwise)`,\n )\n return this.resolvedOptions\n }\n\n /** DefinedWorkflow binds the host at define time: a RegExp source resolves here.\n * cast: whitelist family 1 (agent/coding.md) — getLoras() returns the runtime\n * values of the SAME object_info enum the generated E_LoraName union comes from */\n bindHost(host: LorasHost): void {\n this.hostId = host.data?.id\n if (!(this.optionsSource instanceof RegExp)) return\n this.resolvedOptions = host.schema.getLoras(this.optionsSource) as T[]\n }\n\n get names(): T[] {\n return [...this.options]\n }\n\n /** the loras the build reads: the plain record, or the active lanes merged in order */\n get record(): LoraRecord<T> {\n return flattenLoras(this.value).record\n }\n\n /** what the graph consumes. A lora in two active lanes runs once, with its FIRST setting */\n outValue(): LoraRecord<T> {\n const flat = flattenLoras(this.value)\n if (flat.duplicates.length > 0)\n logError(\n `loras var '${this.name ?? this.label ?? '?'}': ${flat.duplicates.join(', ')} sit in two active lanes, the first lane's setting is used`,\n )\n return flat.record\n }\n\n /** rewrite one lora wherever it lives: the plain record, or the lane that holds it */\n private write(name: T, next: LoraStrength | null): this {\n return this.set(updateLora(this.value, name, next))\n }\n\n /** the parts of this lora's prompt keyword left out of the prompt */\n mutedWords(name: string): string[] {\n return loraMuted(this.record[name as T])\n }\n\n /** loras currently ON (PromptVar keyword prefixing consumes this) */\n activeNames(): T[] {\n return this.names.filter((n) => this.isOn(n))\n }\n\n isOn(name: T): boolean {\n return loraIsOn(this.record[name])\n }\n\n toggleItem(name: T): this {\n const cur = this.record[name]\n if (cur == null || cur === false) return this.write(name, this.prev[name] ?? true)\n // a paused palette entry resumes in place, strengths kept\n if (!loraIsOn(cur)) return this.write(name, withLora(cur, { on: true }))\n this.prev[name] = cur\n return this.write(name, false)\n }\n\n /** step both strengths by delta (true becomes 1 first); no-op when off */\n adjustItem(name: T, delta: number): this {\n const cur = this.record[name]\n if (!loraIsOn(cur)) return this\n const step = (n: number): number => Math.max(0, Math.round((n + delta) * 100) / 100)\n // the short spellings stay short: only a palette entry needs the object form\n const next: LoraStrength =\n typeof cur === 'number' || cur === true\n ? step(cur === true ? 1 : cur)\n : Array.isArray(cur)\n ? [step(cur[0]), step(cur[1])]\n : withLora(cur, { strength: [step(loraStrengths(cur)[0]), step(loraStrengths(cur)[1])] })\n return this.write(name, next)\n }\n\n /** compact per-item strength label for lists */\n strengthLabel(name: T): string {\n const s = this.record[name]\n if (!loraIsOn(s)) return ''\n const [m, c] = loraStrengths(s)\n return m === c ? m.toFixed(2) : `m:${m.toFixed(2)} c:${c.toFixed(2)}`\n }\n\n parse(raw: string): boolean {\n try {\n const parsed: unknown = JSON.parse(raw)\n if (!isLorasInput(parsed)) return false\n // cast: whitelist family 1, the names are this host's lora enum, checked by the build\n this.set(parsed as LorasInput<T>)\n return true\n } catch {\n return false\n }\n }\n\n /** short human name: subfolder + extension stripped */\n static shortName(name: string): string {\n return (name.split(/[\\\\/]/).pop() ?? name).replace(/\\.safetensors$/, '')\n }\n\n /** tick (true) or untick (false) every lora in `names` (default: all options) */\n setAll(on: boolean, names: readonly T[] = this.options): this {\n const record = this.record\n let next = this.value\n for (const name of names) {\n const cur = record[name]\n if (on) {\n if (cur == null || cur === false) next = updateLora(next, name, this.prev[name] ?? true)\n // a paused palette entry resumes in place, strengths kept\n else if (!loraIsOn(cur)) next = updateLora(next, name, withLora(cur, { on: true }))\n } else {\n if (loraIsOn(cur)) this.prev[name] = cur\n next = updateLora(next, name, false)\n }\n }\n return this.set(next)\n }\n\n override display(): string {\n const on = this.activeNames()\n if (on.length === 0) return `(0/${this.options.length}) none`\n return `(${on.length}/${this.options.length}) ${on.map((n) => LorasVar.shortName(n)).join(', ')}`\n }\n}\n\nexport type SizeValue = { width: number; height: number }\nexport type SizePreset = { label: string; width: number; height: number }\n\n/** SDXL-style ~1MP buckets, multiples of 64 — safe for most latent models */\nexport const DEFAULT_SIZE_PRESETS: SizePreset[] = [\n { label: '1:1 square', width: 1024, height: 1024 },\n { label: '4:3 landscape', width: 1152, height: 896 },\n { label: '3:4 portrait', width: 896, height: 1152 },\n { label: '3:2 landscape', width: 1216, height: 832 },\n { label: '2:3 portrait', width: 832, height: 1216 },\n { label: '16:9 widescreen', width: 1344, height: 768 },\n { label: '9:16 tall', width: 768, height: 1344 },\n]\n\n/** the same aspect ratios around 512, for SD1.5-era models trained at ~0.25MP */\nexport const SD15_SIZE_PRESETS: SizePreset[] = [\n { label: '1:1 square', width: 512, height: 512 },\n { label: '4:3 landscape', width: 576, height: 448 },\n { label: '3:4 portrait', width: 448, height: 576 },\n { label: '3:2 landscape', width: 576, height: 384 },\n { label: '2:3 portrait', width: 384, height: 576 },\n { label: '16:9 widescreen', width: 704, height: 384 },\n { label: '9:16 tall', width: 384, height: 704 },\n]\n\n/** starred presets are one click away in the panel, before the full list */\nexport const DEFAULT_STARRED_SIZES = ['1:1 square', '3:4 portrait', '4:3 landscape']\n\n/** the family that matches a workflow's own default: a 512×512 workflow is an SD1.5-era one,\n * and offering it 1024 buckets would be offering sizes it was never trained at */\nexport function sizePresetsFor(defaultValue: SizeValue | undefined): SizePreset[] {\n if (defaultValue == null) return DEFAULT_SIZE_PRESETS\n return defaultValue.width * defaultValue.height <= 600 * 600 ? SD15_SIZE_PRESETS : DEFAULT_SIZE_PRESETS\n}\n\n/** width/height picker: presets + free `WxH` entry + optionally the LIVE\n * size of a linked image var (the widget shows\n * `WxH size of image '<name>'` as a pickable row) */\nexport class SizeVar extends ComfyVar<SizeValue> {\n readonly kind = 'size' as const\n constructor(\n defaultValue: SizeValue = { width: 1024, height: 1024 },\n public readonly presets: SizePreset[] = DEFAULT_SIZE_PRESETS,\n label?: string,\n public readonly imageVar?: ImageVar,\n /** preset LABELS starred by default; a user's own stars live in the panel */\n public readonly starred: readonly string[] = DEFAULT_STARRED_SIZES,\n ) {\n super(defaultValue, label)\n }\n\n /** current dimensions of the linked image var — null when no link, unset\n * path, or an unreadable/undecodable file (those errors belong to the\n * image var itself, the size row simply disappears) */\n imageSize(): { width: number; height: number; name: string } | null {\n const iv = this.imageVar\n if (iv == null || iv.value === '') return null\n try {\n const abs = iv.absPath()\n const meta = imageMeta(getComfyStorage().readBytes(abs))\n if (meta.width == null || meta.height == null) return null\n return { width: meta.width, height: meta.height, name: basename(abs) }\n } catch {\n return null\n }\n }\n\n /** accepts '1024x768' / '1024×768' / a preset label */\n parse(raw: string): boolean {\n const m = raw.trim().match(/^(\\d+)\\s*[x×]\\s*(\\d+)$/)\n if (m != null) {\n this.set({ width: Number(m[1]), height: Number(m[2]) })\n return true\n }\n const preset = this.presets.find((p) => p.label === raw.trim())\n if (preset != null) {\n this.set({ width: preset.width, height: preset.height })\n return true\n }\n return false\n }\n\n override display(): string {\n const { width, height } = this.value\n const hit = this.presets.find((p) => p.width === width && p.height === height)\n return `${width}×${height}${hit ? ` (${hit.label})` : ''}`\n }\n}\n\nexport type MediaVarOpts = {\n /** where the TUI picker starts browsing AND what relative values resolve against (absPath) */\n folder?: string\n /** picker listing filter, lowercase without dots; never affects the value. NOT a security\n * boundary: `comfy-ts serve` keeps its own floor of media types it will read off the disk\n * and upload, which this list may NARROW but never widen (emptying it changes the picker,\n * not what the api accepts) */\n extensions?: readonly string[]\n label?: string\n /** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file\n * and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */\n sidecarText?: TextVar\n}\nexport type ImageVarOpts = MediaVarOpts\nexport type AudioVarOpts = MediaVarOpts\nexport type VideoVarOpts = MediaVarOpts\n\nexport const DEFAULT_IMAGE_EXTENSIONS: readonly string[] = DEFAULT_MEDIA_EXTENSIONS.image\nexport const DEFAULT_AUDIO_EXTENSIONS: readonly string[] = DEFAULT_MEDIA_EXTENSIONS.audio\nexport const DEFAULT_VIDEO_EXTENSIONS: readonly string[] = DEFAULT_MEDIA_EXTENSIONS.video\n\n/** empty media var consumed at build time — typed so drivers surface it apart from real crashes */\nexport class MediaVarEmptyError extends Error {\n /** name, not instanceof: the cli bundle and dist/index.js each define this class */\n override readonly name: string = 'MediaVarEmptyError'\n constructor(\n public readonly varName: string,\n public readonly media: MediaKind = 'image',\n ) {\n super(`${media} var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/file'))`)\n }\n}\n/** the image-only name this error had first; the same class */\nexport const ImageVarEmptyError = MediaVarEmptyError\nexport type ImageVarEmptyError = MediaVarEmptyError\n\n/** trim + expand a leading `~/` — every media var write funnels through this */\nfunction expandUserPath(raw: string): string {\n const trimmed = raw.trim()\n return trimmed.startsWith('~/') ? join(getComfyStorage().homedir(), trimmed.slice(2)) : trimmed\n}\n\n/** the loader node each medium goes through, and its file input */\nconst MEDIA_LOADERS: Record<MediaKind, { node: string; input: string }> = {\n image: { node: 'LoadImage', input: 'image' },\n audio: { node: 'LoadAudio', input: 'audio' },\n video: { node: 'LoadVideo', input: 'file' },\n}\n\n/**\n * a local media file path. The VALUE is a PLAIN PATH STRING — text-encodable,\n * drafts persist it verbatim (toJSON = the string), hand-editable in the\n * draft json. Empty = unset: outValue()/absPath() throw MediaVarEmptyError,\n * so a build never runs on a silent placeholder. The TUI opens the file\n * picker overlay for every media kind.\n */\nexport abstract class MediaVar extends ComfyVar<string> {\n abstract override readonly kind: MediaKind\n constructor(\n defaultValue: string,\n public opts: MediaVarOpts = {},\n ) {\n super(expandUserPath(defaultValue), opts.label)\n }\n /** what the picker lists (lowercase, no dots) */\n get extensions(): readonly string[] {\n return this.opts.extensions ?? DEFAULT_MEDIA_EXTENSIONS[this.kind]\n }\n override set(value: string): this {\n return super.set(expandUserPath(value))\n }\n parse(raw: string): boolean {\n this.set(raw)\n return true\n }\n isSet(): boolean {\n return this.value !== ''\n }\n private emptyError(): MediaVarEmptyError {\n return new MediaVarEmptyError(this.name ?? this.label ?? this.kind, this.kind)\n }\n /** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */\n absPath(): string {\n if (!this.isSet()) throw this.emptyError()\n if (isAbsolute(this.value)) return this.value\n return resolve(this.opts.folder ?? getComfyStorage().cwd(), this.value)\n }\n /** empty = unset: the build fails LOUD here (varValues calls outValue) */\n override outValue(): string {\n if (!this.isSet()) throw this.emptyError()\n return this.value\n }\n override display(): string {\n if (!this.isSet()) return '(unset) pick a file'\n const home = getComfyStorage().homedir()\n return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value\n }\n /** upload the file hash-named (reruns dedupe) and add this medium's loader node. A dry\n * build names the file by its hash and uploads nothing */\n protected async loadVia(wf: ComfyWorkflow<string>): Promise<unknown> {\n const loader = MEDIA_LOADERS[this.kind]\n const factory = wf.builderBase[loader.node]\n if (factory == null)\n throw new Error(\n `host '${wf.host.data.id}' has no ${loader.node} node: ${this.kind} var '${this.name ?? '?'}' cannot load`,\n )\n const abs = this.absPath()\n const bytes = getComfyStorage().readBytes(abs)\n const ext = extensionOf(abs)\n const name = `${hashArrayBuffer(bytes)}${ext === '' ? '' : `.${ext}`}`\n const onHost = wf.dry\n ? name\n : await wf.host.uploader.uploadInput({\n blob: new Blob([bytes as Uint8Array<ArrayBuffer>], { type: mediaMime(abs) }),\n name,\n slot: `${loader.node}.${loader.input}`,\n type: 'input',\n })\n return factory({ [loader.input]: onHost })\n }\n}\n\n/** a local image path, loaded through LoadImage */\nexport class ImageVar extends MediaVar {\n readonly kind = 'image' as const\n async loadInWorkflow<WID extends string>(wf: ComfyWorkflow<WID>): Promise<NodeOf<WID, 'LoadImage'>> {\n // sanctioned cast (family 1): the node is the host's own LoadImage, built from object_info\n return (await this.loadVia(wf)) as NodeOf<WID, 'LoadImage'>\n }\n}\n\n/** a local audio path, loaded through LoadAudio */\nexport class AudioVar extends MediaVar {\n readonly kind = 'audio' as const\n async loadInWorkflow<WID extends string>(wf: ComfyWorkflow<WID>): Promise<NodeOf<WID, 'LoadAudio'>> {\n // sanctioned cast (family 1): same as ImageVar\n return (await this.loadVia(wf)) as NodeOf<WID, 'LoadAudio'>\n }\n}\n\n/** a local video path, loaded through LoadVideo */\nexport class VideoVar extends MediaVar {\n readonly kind = 'video' as const\n async loadInWorkflow<WID extends string>(wf: ComfyWorkflow<WID>): Promise<NodeOf<WID, 'LoadVideo'>> {\n // sanctioned cast (family 1): same as ImageVar\n return (await this.loadVia(wf)) as NodeOf<WID, 'LoadVideo'>\n }\n}\n\n/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.model / v.loras / v.size / v.image / v.audio / v.video */\nexport const v = {\n // the old `v.text(x, 'label')` form still works: a bare string IS the label\n text: (defaultValue: string, opts: TextVarOpts | string = {}): TextVar =>\n new TextVar(defaultValue, typeof opts === 'string' ? { label: opts } : opts),\n prompt: (\n /** a string, or `{ lanes: [{ name, prompt, active }] }` merged in listed order */\n defaultValue: PromptInput,\n opts: PromptVarOpts = {},\n ): PromptVar => new PromptVar(defaultValue, opts),\n int: (defaultValue: number, opts: { min?: number; max?: number; label?: string } = {}): IntVar =>\n new IntVar(defaultValue, opts),\n float: (defaultValue: number, opts: { min?: number; max?: number; label?: string } = {}): FloatVar =>\n new FloatVar(defaultValue, opts),\n /** `mode` is the SPEC default the workflow runs in: `'+'` makes every run step the seed,\n * which is what a tuning session wants, and reset()/revert come back to it */\n seed: (defaultValue: number = 0, opts: string | { label?: string; mode?: SeedMode } = {}): SeedVar =>\n new SeedVar(defaultValue, opts),\n toggle: (defaultValue: boolean, label?: string): ToggleVar => new ToggleVar(defaultValue, label),\n /** exactly one option (the default), `{ select: 'zero-or-one' }` for one or none (value\n * `T | null`), `{ select: 'many' }` for any number (value `T[]`) */\n choice,\n loras: <T extends string = string>(\n options: readonly T[] | RegExp,\n /** a record, or `{ lanes: [{ name, active, loras }] }` merged in listed order */\n initial: LorasInput<T> = {},\n label?: string,\n ): LorasVar<T> => new LorasVar(options, initial, label),\n size: (\n defaultValue?: SizeValue,\n opts: { presets?: SizePreset[]; starred?: readonly string[]; label?: string; image?: ImageVar } = {},\n ): SizeVar =>\n new SizeVar(defaultValue, opts.presets ?? sizePresetsFor(defaultValue), opts.label, opts.image, opts.starred),\n /** host-bound: only inside defineWorkflow({ vars: (v) => … }), typed per slot there */\n model,\n image: (defaultValue: string, opts: MediaVarOpts = {}): ImageVar => new ImageVar(defaultValue, opts),\n audio: (defaultValue: string, opts: MediaVarOpts = {}): AudioVar => new AudioVar(defaultValue, opts),\n video: (defaultValue: string, opts: MediaVarOpts = {}): VideoVar => new VideoVar(defaultValue, opts),\n}\n\n/**\n * structural face of any var: readonly `value` keeps ComfyVar<T> assignable\n * despite T-invariance on the mutable field. VarValues re-derives the exact\n * value types via infer.\n */\nexport type AnyVar = {\n readonly kind: VarKind\n readonly value: unknown\n readonly defaultValue: unknown\n readonly label?: string\n /** the vars-spec key — DefinedWorkflow writes it at define time */\n name?: string\n readonly uiOpts: VarUi\n parse(raw: string): boolean\n loadJSON(value: unknown): unknown\n reset(): unknown\n toJSON(): unknown\n outValue(): unknown\n display(): string\n toEditBuffer(): string\n afterRun(): void\n /** host-dependent vars (LorasVar regex) resolve here — DefinedWorkflow calls it at define time */\n bindHost?(host: LorasHost): void\n}\n\nexport type VarsSpec = { [key: string]: AnyVar }\n\nexport type VarValues<V extends VarsSpec> = {\n // outValue() return type, not the stored type: PromptVar stores string, contributes PromptValue\n [K in keyof V]: V[K] extends { outValue(): infer O } ? O : never\n}\n\nexport function varValues<V extends VarsSpec>(vars: V): VarValues<V> {\n const out: Record<string, unknown> = {}\n // outValue, not value: PromptVar strips comments / prefixes lora keywords here\n for (const [k, varDef] of Object.entries(vars)) out[k] = varDef.outValue()\n return out as VarValues<V>\n}\n","import type { ComfyHost } from 'src/host/ComfyHost.ts'\nimport type { ComfyExecution } from 'src/runner/ComfyExecution.ts'\nimport type { ComfyWorkflow, RunSettings } from 'src/runner/ComfyWorkflow.ts'\nimport type { SdkForHost } from 'src/types/comfy-sdk.ts'\nimport type { LorasInput } from 'src/vars/lanes.ts'\nimport {\n type AnyVar,\n type ChoiceVar,\n type LorasVar,\n type ModelVarOpts,\n type OptionalChoiceVar,\n v,\n type VarsSpec,\n type VarValues,\n varValues,\n} from 'src/vars/ComfyVars.ts'\n\n/** the host's generated lora-name union (plain string when no sdk is generated) */\nexport type LoraNameOf<ID extends string> = 'E_LoraName' extends keyof SdkForHost<ID>['Union']\n ? SdkForHost<ID>['Union']['E_LoraName'] & string\n : string\n\n/**\n * the `v` handed to a vars LAMBDA: the global factory, host-typed —\n * `v.loras(regex)` yields the host's lora-name union (resolved via bindHost)\n */\nexport type BoundVars<ID extends string> = Omit<typeof v, 'loras' | 'model'> & {\n loras(options: RegExp, initial?: LorasInput<LoraNameOf<ID>>, label?: string): LorasVar<LoraNameOf<ID>>\n loras<T extends string>(options: readonly T[], initial?: LorasInput<T>, label?: string): LorasVar<T>\n /** the host's file list for one loader input: the slot autocompletes, the value is its union */\n model: ModelFactory<SdkForHost<ID>['Slots']>\n}\n\n/** `v.model` typed by a host's slot table S (`Slots`): its own interface, so the host id's\n * variance stays measurable (inlined into BoundVars, ComfyHost<ID> stopped being a ComfyHost<string>) */\nexport interface ModelFactory<S> {\n <K extends keyof S & string>(\n slot: K,\n opts: ModelVarOpts<S[K] & string> & { default: S[K] & string },\n ): ChoiceVar<S[K] & string>\n <K extends keyof S & string>(\n slot: K,\n opts: ModelVarOpts<S[K] & string> & { default: null },\n ): OptionalChoiceVar<S[K] & string>\n}\n\n/** every `Node.input` slot of the host's generated sdk (any string without one) */\nexport type SlotNameOf<ID extends string> = keyof SdkForHost<ID>['Slots'] & string\n\n/** the value union of one slot, strings only (a loader file list) */\nexport type SlotValueOf<ID extends string, K extends string> = K extends keyof SdkForHost<ID>['Slots']\n ? SdkForHost<ID>['Slots'][K] & string\n : string\n\nexport type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {\n /** short id; also names the workflow instances */\n id?: string\n /** optional TUI tree color (ink color name or hex); unset = the tree's\n * per-family palette (first `-` word of the module basename) */\n color?: string\n /** the tweakable knobs; drivers (scripts, TUI) edit these between runs.\n * A LAMBDA gives cross-referencing vars a scope (loras + prompt with\n * loraKeywordsFrom created inline) — resolved ONCE at define time, and it\n * RECEIVES the host-typed `v` (no import needed) */\n vars: V | ((v: BoundVars<ID>) => V)\n /** builds the graph from the CURRENT var values; re-executed on every run().\n * may be async (e.g. image uploads through the wf param) */\n build: (b: SdkForHost<ID>['Builder'], vars: VarValues<V>, wf: ComfyWorkflow<ID>) => void | Promise<void>\n /** named texts computed from the CURRENT var values, the same `vars` build receives, shown\n * live while the vars are edited (the serve panel: a foldable block under generate). Use the\n * function build uses, so a preview is what the run sends, never a paraphrase of it */\n previews?: Record<string, (vars: VarValues<V>) => string>\n /** free search tags for the serve omnibox, added to the ones read from the graph\n * (`image`, `audio`, `video`, `text`, `llm`, `edit`) */\n tags?: string[]\n}\n\n/** type predicate (not a cast): a VarsSpec is a plain record, never callable */\nfunction isVarsThunk<ID extends string, V extends VarsSpec>(\n vars: V | ((v: BoundVars<ID>) => V),\n): vars is (v: BoundVars<ID>) => V {\n return typeof vars === 'function'\n}\n\n/**\n * a re-runnable workflow definition: `build` re-executes per run with the\n * current var values, so every run gets a fresh, deterministic graph.\n */\nexport class DefinedWorkflow<ID extends string = string, V extends VarsSpec = VarsSpec> {\n /** spec.vars resolved once (may be given as a thunk) — the SAME instances for the workflow's lifetime */\n readonly vars: V\n\n constructor(\n public host: ComfyHost<ID>,\n public spec: DefineWorkflowSpec<ID, V>,\n ) {\n // cast: whitelist family 1 (agent/coding.md) — the runtime `v` IS the\n // factory BoundVars describes; the regex-loras typing claim it adds is\n // resolved from the same object_info enum via bindHost below\n this.vars = isVarsThunk(spec.vars) ? spec.vars(v as BoundVars<ID>) : spec.vars\n // define-time var wiring: the spec key becomes the var's name (error\n // messages name the var with it), host-dependent vars (v.loras(regex))\n // resolve their options\n for (const [key, varDef] of this.entries()) {\n varDef.name = key\n varDef.bindHost?.(this.host)\n }\n // a condition naming a var that does not exist would silently never enable its field\n const names = this.entries().map(([key]) => key)\n for (const [key, varDef] of this.entries())\n for (const other of Object.keys(varDef.uiOpts.activeWhen ?? {}))\n if (!names.includes(other))\n throw new Error(\n `workflow '${spec.id ?? '?'}': var '${key}' is activeWhen '${other}', which is not one of its vars (${names.join(', ')})`,\n )\n }\n\n /** every preview for the current var values. A preview that throws, or vars that cannot be\n * read yet (an image var still empty), give a line saying so instead of failing the others */\n computePreviews(): Record<string, string> {\n const previews = this.spec.previews ?? {}\n const names = Object.keys(previews)\n if (names.length === 0) return {}\n let values: VarValues<V>\n try {\n values = varValues(this.vars)\n } catch (e) {\n const why = `unavailable: ${e instanceof Error ? e.message : String(e)}`\n return Object.fromEntries(names.map((n) => [n, why]))\n }\n const out: Record<string, string> = {}\n for (const [name, fn] of Object.entries(previews)) {\n try {\n out[name] = fn(values)\n } catch (e) {\n out[name] = `🔴 preview '${name}' failed: ${e instanceof Error ? e.message : String(e)}`\n }\n }\n return out\n }\n\n /** [name, var] pairs, for drivers that enumerate the knobs */\n entries(): [string, AnyVar][] {\n return Object.entries(this.vars)\n }\n\n /** the workflow built by the latest run() (null before the first run) */\n lastWorkflow: ComfyWorkflow<ID> | null = null\n /** the latest execution (null before the first run) */\n lastExecution: ComfyExecution | null = null\n\n /**\n * build a fresh graph from the CURRENT var values (no send). `p.advance`\n * (set by run()) fires each var's afterRun() right after snapshotting the\n * values — atomically, before any await — so the graph uses this run's seed\n * while the var moves to the next (queued runs get distinct seeds; a bare\n * build() for copy/export never advances). `p.host` substitutes the host\n * the graph is built against (TUI host override): node/model availability\n * there surfaces as workflow.problems / server validation, by design.\n * `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.\n */\n async build(p: { advance?: boolean; host?: ComfyHost<ID>; dry?: boolean } = {}): Promise<ComfyWorkflow<ID>> {\n const host = p.host ?? this.host\n const wf = host.workflow({ id: this.spec.id })\n wf.dry = p.dry === true\n const values = varValues(this.vars)\n if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun()\n await this.spec.build(wf.builder, values, wf)\n if (wf.dry) return wf\n this.lastWorkflow = wf\n return wf\n }\n\n /** build a fresh graph from the current var values, send it, wait for outputs.\n * connects first (idempotent) — modules can import offline from the schema cache.\n * `settings.host` runs against THAT host instead of the defining one. */\n async run(settings: RunSettings & { host?: ComfyHost<ID> } = {}): Promise<ComfyExecution> {\n const host = settings.host ?? this.host\n await host.connect()\n const wf = await this.build({ advance: true, host })\n const execution = await wf.run({\n save: settings.save,\n ephemeral: settings.ephemeral,\n scrubHistory: settings.scrubHistory,\n idMode: settings.idMode,\n log: settings.log,\n onProgress: settings.onProgress,\n onPreview: settings.onPreview,\n })\n this.lastExecution = execution\n return execution\n }\n}\n","import { isRecord } from 'src/utils/isRecord.ts'\n\n/**\n * what changed on a host since a schema was loaded: node types, and the model files each loader\n * lists. ComfyUI exposes no boot time, so staleness is decided by CONTENT: a restart that changed\n * nothing stays quiet, a new lora shows even when nobody knows when the box rebooted.\n * A light check asks only the loaders (`/object_info/<node>`, a few KB); a full one compares every\n * node type (`/object_info`, megabytes).\n */\n\n/** the loader inputs whose combo IS a model folder listing */\nexport const MODEL_LISTS = [\n { noun: 'lora', node: 'LoraLoader', input: 'lora_name' },\n { noun: 'checkpoint', node: 'CheckpointLoaderSimple', input: 'ckpt_name' },\n { noun: 'unet', node: 'UNETLoader', input: 'unet_name' },\n { noun: 'text encoder', node: 'CLIPLoader', input: 'clip_name' },\n { noun: 'vae', node: 'VAELoader', input: 'vae_name' },\n] as const\n\ntype Spec = Record<string, unknown>\ntype Delta = { added: string[]; removed: string[] }\n\nexport type SchemaDrift = {\n /** null on a light check: node types are only compared by a full one */\n nodes: Delta | null\n models: ({ noun: string } & Delta)[]\n}\n\n/** a combo's options in both object_info spellings: `[[...options]]` and `['COMBO', { options }]` */\nexport function comboOptions(spec: Spec, node: string, input: string): string[] | null {\n const def = spec[node]\n if (!isRecord(def) || !isRecord(def['input'])) return null\n const sections = def['input']\n for (const section of ['required', 'optional']) {\n const sec = sections[section]\n if (!isRecord(sec)) continue\n const slot = sec[input]\n if (!Array.isArray(slot)) continue\n const first: unknown = slot[0]\n if (Array.isArray(first)) return first.filter((x): x is string => typeof x === 'string')\n const opts: unknown = slot[1]\n if (first === 'COMBO' && isRecord(opts) && Array.isArray(opts['options']))\n return opts['options'].filter((x): x is string => typeof x === 'string')\n }\n return null\n}\n\nfunction delta(before: readonly string[], after: readonly string[]): Delta {\n const was = new Set(before)\n const now = new Set(after)\n return { added: after.filter((x) => !was.has(x)), removed: before.filter((x) => !now.has(x)) }\n}\n\n/** `live` may be PARTIAL (a light check holds only the loaders): a list is compared only where both\n * sides have the loader, and node types only when `full` */\nexport function diffSchemas(p: { loaded: Spec; live: Spec; full: boolean }): SchemaDrift {\n const models: SchemaDrift['models'] = []\n for (const m of MODEL_LISTS) {\n const before = comboOptions(p.loaded, m.node, m.input)\n const after = comboOptions(p.live, m.node, m.input)\n if (before == null || after == null) continue\n const d = delta(before, after)\n if (d.added.length > 0 || d.removed.length > 0) models.push({ noun: m.noun, ...d })\n }\n return { nodes: p.full ? delta(Object.keys(p.loaded), Object.keys(p.live)) : null, models }\n}\n\nexport function driftChanged(d: SchemaDrift): boolean {\n return d.models.length > 0 || (d.nodes != null && (d.nodes.added.length > 0 || d.nodes.removed.length > 0))\n}\n\n/** `+5 loras, -1 unet, +4 node types`, '' when nothing changed */\nexport function summarizeDrift(d: SchemaDrift): string {\n const parts: string[] = []\n const say = (n: number, sign: string, noun: string): void => {\n if (n > 0) parts.push(`${sign}${n} ${noun}${n === 1 ? '' : 's'}`)\n }\n for (const m of d.models) {\n say(m.added.length, '+', m.noun)\n say(m.removed.length, '-', m.noun)\n }\n if (d.nodes != null) {\n say(d.nodes.added.length, '+', 'node type')\n say(d.nodes.removed.length, '-', 'node type')\n }\n return parts.join(', ')\n}\n"],"mappings":";;;;;;AACA,MAAa,uBAAuB,UAA2B;CAC5D,IAAI,iBAAiB,OAAO,OAAO,MAAM;CACzC,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,OAAO,UAAU,UAAU;EAC5B,IAAI,aAAa,SAAS,OAAO,MAAM,YAAY,UAAU,OAAO,MAAM;EAC1E,OAAO,KAA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