comfy-ts 2.9.0 → 2.11.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 (55) hide show
  1. package/README.md +6 -4
  2. package/dist/{LogsSt-DFxzQfDc.js → LogsSt-qtFzOKpu.js} +2 -2
  3. package/dist/{LogsSt-DFxzQfDc.js.map → LogsSt-qtFzOKpu.js.map} +1 -1
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +102 -3
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +19 -0
  8. package/dist/index.d.ts +19 -0
  9. package/dist/index.js +102 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-_nrvJYyt.js → run-serve-BK7BA2dn.js} +91 -3
  12. package/dist/run-serve-BK7BA2dn.js.map +1 -0
  13. package/dist/{run-tui-BLEdTsOX.js → run-tui-CQyvMf0N.js} +36 -4
  14. package/dist/run-tui-CQyvMf0N.js.map +1 -0
  15. package/dist/{DefinedWorkflow-BatWaZO1.js → schemaDrift-DjjEtwfx.js} +176 -2
  16. package/dist/schemaDrift-DjjEtwfx.js.map +1 -0
  17. package/dist/serve-web.js +32 -16
  18. package/dist/{state-BbgJeCe6.js → state--wrz0BQc.js} +23 -5
  19. package/dist/state--wrz0BQc.js.map +1 -0
  20. package/dist/web.d.ts +19 -0
  21. package/dist/web.js +102 -3
  22. package/dist/web.js.map +1 -1
  23. package/examples/README.md +1 -0
  24. package/examples/comfy-cloud/capybara-i2v.cflow.ts +2 -0
  25. package/examples/comfy-cloud/ltx25-i2v.cflow.ts +152 -0
  26. package/examples/comfy-cloud/ltx25-t2v.cflow.ts +126 -0
  27. package/examples/comfy-cloud/minimax-music3-t2a.cflow.ts +95 -0
  28. package/examples/comfy-cloud/sdk.d.ts +30724 -24404
  29. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +2 -0
  30. package/examples/comfy-cloud/wan22-i2v.cflow.ts +2 -0
  31. package/examples/comfy-cloud/wan22-t2v.cflow.ts +2 -0
  32. package/examples/rvion/07-local-llm-text-gen.cflow.ts +2 -2
  33. package/examples/rvion/08-qwen-image-21-t2i.cflow.ts +64 -0
  34. package/examples/rvion/09-qwen-image-21-edit.cflow.ts +83 -0
  35. package/package.json +4 -2
  36. package/src/cli/serve/ServeApp.ts +94 -0
  37. package/src/cli/serve/describeVar.ts +7 -0
  38. package/src/cli/serve/favicon.ts +3 -0
  39. package/src/cli/serve/web/api.ts +12 -0
  40. package/src/cli/serve/web/components/VarsForm.tsx +18 -7
  41. package/src/cli/serve/web/components/controls/LorasControl.tsx +102 -6
  42. package/src/cli/serve/web/state/WebSt.ts +79 -0
  43. package/src/cli/serve/web/state/loraSort.ts +39 -0
  44. package/src/cli/serve/web/styles.ts +15 -0
  45. package/src/cli/tui/components/Header.tsx +2 -0
  46. package/src/cli/tui/state/HostSt.ts +34 -0
  47. package/src/graph/ComfyNode.ts +19 -3
  48. package/src/host/ComfyHost.ts +15 -0
  49. package/src/host/loraInfoCache.ts +64 -0
  50. package/src/host/loraManagerApi.ts +27 -0
  51. package/src/host/schemaDrift.ts +87 -0
  52. package/dist/DefinedWorkflow-BatWaZO1.js.map +0 -1
  53. package/dist/run-serve-_nrvJYyt.js.map +0 -1
  54. package/dist/run-tui-BLEdTsOX.js.map +0 -1
  55. package/dist/state-BbgJeCe6.js.map +0 -1
@@ -52,6 +52,8 @@ export const wan225bT2v = host.defineWorkflow({
52
52
  b.SaveVideo({
53
53
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
54
54
  filename_prefix: 'comfy-ts-zoo/wan22-5b-t2v',
55
+ format: 'auto',
56
+ codec: 'auto',
55
57
  })
56
58
  },
57
59
  })
@@ -90,6 +90,8 @@ export const wan22I2v = host.defineWorkflow({
90
90
  b.SaveVideo({
91
91
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
92
92
  filename_prefix: 'comfy-ts-zoo/wan22-i2v',
93
+ format: 'auto',
94
+ codec: 'auto',
93
95
  })
94
96
  },
95
97
  })
@@ -81,6 +81,8 @@ export const wan22T2v = host.defineWorkflow({
81
81
  b.SaveVideo({
82
82
  video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
83
83
  filename_prefix: 'comfy-ts-zoo/wan22-t2v',
84
+ format: 'auto',
85
+ codec: 'auto',
84
86
  })
85
87
  },
86
88
  })
@@ -38,7 +38,6 @@ const GENERATIVE = [
38
38
  const SWEEP_CANDIDATES = [
39
39
  ...GENERATIVE,
40
40
  'qwen_3_8b_fp8mixed.safetensors',
41
- 'mistral_3_small_flux2_bf16.safetensors',
42
41
  'qwen_2.5_vl_7b_fp8_scaled.safetensors',
43
42
  'clip_l.safetensors',
44
43
  't5\\t5xxl_fp8_e4m3fn_scaled.safetensors',
@@ -108,7 +107,8 @@ const buildTextGen = (b: Comfy.Windows1.Builder, p: TextGenParams): void => {
108
107
  'sampling_mode.seed': p.seed,
109
108
  } as const
110
109
  const generated = p.streaming ? b[STREAMING_NODE_KEY]({ ...shared, stream_every: 4 }) : b.TextGenerate({ ...shared })
111
- b.PreviewAny({ source: generated._STRING })
110
+ // TextGenerate has TWO string outputs (generated_text, thinking), so there is no `_STRING`
111
+ b.PreviewAny({ source: generated.outputs.generated_text })
112
112
  }
113
113
 
114
114
  export const localLlmTextGen = host.defineWorkflow({
@@ -0,0 +1,64 @@
1
+ // qwen image 2.1 text-to-image on windows-1 — mirrors the official image_qwen_image_2_1_t2i template
2
+ // int8 diffusion model + qwen3-vl 8b text encoder, 25 steps at cfg 1 (the negative only bites once cfg > 1)
3
+ // box inventory: qwen_image_2.1_int8_convrot, qwen3vl_8b_int8_convrot, qwen_image_2.1_vae_bf16 (Comfy-Org/Qwen-Image-2.1), ComfyUI ≥ 0.37
4
+ // run directly: bun examples/rvion/08-qwen-image-21-t2i.cflow.ts ["prompt"] [seed]
5
+ import { ComfyTS, v } from 'comfy-ts'
6
+
7
+ const comfy = ComfyTS.create()
8
+ const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
9
+ await host.loadSchemaFromCache() // offline import; run() connects lazily
10
+
11
+ export const qwenImage21T2i = host.defineWorkflow({
12
+ id: 'qwen-image-21-t2i',
13
+ vars: {
14
+ // `- ` lines are the negative prompt, `//` lines are comments
15
+ prompt: v.prompt(
16
+ 'Greyscale fashion editorial portrait of an avant-garde woman tilted upwards in profile, striking high-contrast chiaroscuro lighting, oversized thick-rimmed circular black sunglasses, a high-necked structural dress in a disrupted optical camouflage pattern of oversized polka dots and pixelated stippling. The background is a vivid mixed-media graphic collage: flat lime green planes, black and white overlapping circles, bold zebra-striped semi-circles, micro-halftone dot matrices. Sharp silhouettes, paper cut-out edges, clean graphic novel textures. No text, no letters, no logos, no watermark.',
17
+ ),
18
+ seed: v.seed(42, { mode: '+' }),
19
+ steps: v.int(25, { min: 1, max: 60 }),
20
+ cfg: v.float(1, { min: 1, max: 10 }),
21
+ size: v.size({ width: 1024, height: 1024 }),
22
+ },
23
+ build: (b, vars) => {
24
+ const unet = b.UNETLoader({ unet_name: 'qwen_image_2.1_int8_convrot.safetensors', weight_dtype: 'default' })
25
+ const clip = b.CLIPLoader({
26
+ clip_name: 'qwen3vl_8b_int8_convrot.safetensors',
27
+ type: 'qwen_image',
28
+ device: 'default',
29
+ })
30
+ const vae = b.VAELoader({ vae_name: 'qwen_image_2.1_vae_bf16.safetensors' })
31
+
32
+ const cond = b.TextEncodeQwenImage21({
33
+ clip,
34
+ prompt: vars.prompt.positive,
35
+ negative_prompt: vars.prompt.negative,
36
+ resolution: 1024,
37
+ })
38
+ const samples = b.KSampler({
39
+ model: unet,
40
+ positive: cond.outputs.positive,
41
+ negative: cond.outputs.negative,
42
+ latent_image: b.EmptyLatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
43
+ seed: vars.seed,
44
+ steps: vars.steps,
45
+ cfg: vars.cfg,
46
+ sampler_name: 'euler',
47
+ scheduler: 'simple',
48
+ denoise: 1,
49
+ })
50
+ b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae }) })
51
+ },
52
+ })
53
+
54
+ export default qwenImage21T2i
55
+
56
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
57
+ if (import.meta.main) {
58
+ if (process.argv[2]) qwenImage21T2i.vars.prompt.set(process.argv[2])
59
+ if (process.argv[3]) qwenImage21T2i.vars.seed.set(Number(process.argv[3]))
60
+
61
+ const execution = await qwenImage21T2i.run({ log: true, save: { prefix: 'comfy-ts-example/qwen-image-21-t2i' } })
62
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
63
+ host.disconnect()
64
+ }
@@ -0,0 +1,83 @@
1
+ // qwen image 2.1 edit on windows-1 — mirrors the official image_qwen_image_2_1_image_edit template, single reference image
2
+ // the reference is seen by the text encoder AND spliced in as a vae latent; the output keeps the reference's own size
3
+ // the "remove background" preset is the official image_qwen_image_2_1_background_removal template: same graph, that instruction
4
+ // box inventory: qwen_image_2.1_int8_convrot, qwen3vl_8b_int8_convrot, qwen_image_2.1_vae_bf16 (Comfy-Org/Qwen-Image-2.1), ComfyUI ≥ 0.37
5
+ // run directly: bun examples/rvion/09-qwen-image-21-edit.cflow.ts [path/to/image.png] ["edit instruction"]
6
+ import { asAbsolutePath, ComfyTS, exampleImagePath, MediaImage, v } from 'comfy-ts'
7
+
8
+ const comfy = ComfyTS.create()
9
+ const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
10
+ await host.loadSchemaFromCache() // offline import; run() connects lazily
11
+
12
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
13
+ const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
14
+
15
+ export const qwenImage21Edit = host.defineWorkflow({
16
+ id: 'qwen-image-21-edit',
17
+ vars: {
18
+ image,
19
+ // the reference is <image1> in the instruction. `- ` lines are the negative prompt
20
+ prompt: v.prompt(
21
+ 'Keep the bear and its pose in <image1> unchanged, wrap a hand-knitted red wool scarf around its neck, realistic wool texture, natural folds, keep the original background and lighting, sharp details',
22
+ {
23
+ presets: {
24
+ 'knitted scarf':
25
+ 'Keep the bear and its pose in <image1> unchanged, wrap a hand-knitted red wool scarf around its neck, realistic wool texture, natural folds, keep the original background and lighting, sharp details',
26
+ 'remove background': 'Remove the background, and output a PNG image',
27
+ watercolor: 'Turn <image1> into a detailed watercolor painting, keep the composition unchanged',
28
+ },
29
+ },
30
+ ),
31
+ seed: v.seed(42, { mode: '+' }),
32
+ steps: v.int(25, { min: 1, max: 60 }),
33
+ },
34
+ // async build: the reference image is uploaded (hash-named, deduped) per run
35
+ build: async (b, vars, wf) => {
36
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
37
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
38
+
39
+ const unet = b.UNETLoader({ unet_name: 'qwen_image_2.1_int8_convrot.safetensors', weight_dtype: 'default' })
40
+ const clip = b.CLIPLoader({
41
+ clip_name: 'qwen3vl_8b_int8_convrot.safetensors',
42
+ type: 'qwen_image',
43
+ device: 'default',
44
+ })
45
+ const vae = b.VAELoader({ vae_name: 'qwen_image_2.1_vae_bf16.safetensors' })
46
+
47
+ // resolution 0: the reference keeps its own size (rounded to a multiple of 32)
48
+ const cond = b.TextEncodeQwenImage21({
49
+ clip,
50
+ prompt: vars.prompt.positive,
51
+ negative_prompt: vars.prompt.negative,
52
+ resolution: 0,
53
+ 'images.image_1': loaded,
54
+ vae,
55
+ })
56
+ const samples = b.KSampler({
57
+ // kv cache of the reference prefix, reused across steps instead of recomputed
58
+ model: b.QwenImage21Cache({ model: unet, device: 'auto', dtype: 'default' }),
59
+ positive: cond.outputs.positive,
60
+ negative: cond.outputs.negative,
61
+ latent_image: cond.outputs.latent,
62
+ seed: vars.seed,
63
+ steps: vars.steps,
64
+ cfg: 1,
65
+ sampler_name: 'euler',
66
+ scheduler: 'simple',
67
+ denoise: 1,
68
+ })
69
+ b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae }) })
70
+ },
71
+ })
72
+
73
+ export default qwenImage21Edit
74
+
75
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
76
+ if (import.meta.main) {
77
+ if (process.argv[2]) qwenImage21Edit.vars.image.set(process.argv[2])
78
+ if (process.argv[3]) qwenImage21Edit.vars.prompt.set(process.argv[3])
79
+
80
+ const execution = await qwenImage21Edit.run({ log: true, save: { prefix: 'comfy-ts-example/qwen-image-21-edit' } })
81
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
82
+ host.disconnect()
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfy-ts",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
5
5
  "keywords": [
6
6
  "comfyui",
@@ -87,6 +87,7 @@
87
87
  "sdk:outline": "bun scripts/sdk-outline.ts",
88
88
  "loras": "bun src/cli/comfy-ts-cli.ts loras",
89
89
  "examples:images": "bun scripts/fetch-example-images.ts",
90
+ "gen:favicon": "bun scripts/gen-favicon.ts",
90
91
  "templates:fetch": "bun scripts/fetch-templates.ts",
91
92
  "templates:check": "bun scripts/check-templates.ts",
92
93
  "hooks:install": "git config core.hooksPath .githooks",
@@ -97,7 +98,8 @@
97
98
  "serve": "bun src/cli/comfy-ts-cli.ts serve",
98
99
  "serve:watch": "bun --watch src/cli/comfy-ts-cli.ts serve",
99
100
  "serve:0000": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0",
100
- "serve:0000:rvion": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0 examples/rvion"
101
+ "serve:0000:rvion": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0 examples/rvion",
102
+ "serve:rvion": "bun --watch src/cli/comfy-ts-cli.ts serve examples/rvion"
101
103
  },
102
104
  "rvt": {
103
105
  "skip": [
@@ -19,12 +19,18 @@ import { applyVarPayload } from 'src/cli/serve/applyVarPayload.ts'
19
19
  import { describeVar, type VarDescriptor } from 'src/cli/serve/describeVar.ts'
20
20
  import { deletePromptEnhancer, listPromptEnhancers, writePromptEnhancer } from 'src/promptEnhancers.ts'
21
21
  import { managerOnlyLoraOptions } from 'src/cli/serve/managerOnlyLoras.ts'
22
+ import { FAVICON_DATA_URI } from 'src/cli/serve/favicon.ts'
23
+ import { driftChanged, summarizeDrift } from 'src/host/schemaDrift.ts'
22
24
  import { validSavePrefix, validStoreName } from 'src/utils/safeName.ts'
23
25
  import { readServeSettings, writeServeSettings, type ServeSettings } from 'src/cli/serve/serveSettings.ts'
24
26
  import { assembleLogChunks } from 'src/cli/tui/state/LogsSt.ts'
25
27
  import { draftsDirForFile, listDraftsForFile } from 'src/cli/tui/state/DraftsSt.ts'
26
28
  import {
27
29
  buildLoraMirror,
30
+ getLoraAddedAt,
31
+ getLoraTriggers,
32
+ type LoraTriggers,
33
+ recordCivitaiMiss,
28
34
  getLoraDisplayName,
29
35
  getLoraInfo,
30
36
  getLoraPreviewUrl,
@@ -34,6 +40,7 @@ import {
34
40
  writeLoraMirror,
35
41
  } from 'src/host/loraInfoCache.ts'
36
42
  import {
43
+ fetchLoraCivitai,
37
44
  fetchLoraDescription,
38
45
  fetchLoraExampleImages,
39
46
  fetchLoraList,
@@ -254,7 +261,9 @@ const USAGE = [
254
261
  'DELETE /drafts/<module>/<draft> — delete that draft file',
255
262
  'GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes',
256
263
  'POST /upload with {"name","dataBase64"} — store a browser file for an image var',
264
+ 'GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)',
257
265
  'GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)',
266
+ 'POST /hosts/<hostId>/lora-civitai/<lora> — fetch its civitai metadata (trigger words) through the lora manager, then re-sync the mirror',
258
267
  'GET /lora-preview/<hostId>/<lora> — preview image bytes',
259
268
  'GET /lora-about/<hostId>/<lora> — civitai description + example images (live from the extension)',
260
269
  'GET /prompt-enhancers — the web ui master prompts (.comfy-ts/prompt-enhancers/*.md)',
@@ -284,6 +293,7 @@ const WEB_SHELL = `<!doctype html>
284
293
  <meta charset="utf-8">
285
294
  <meta name="viewport" content="width=device-width, initial-scale=1">
286
295
  <title>comfy-ts serve</title>
296
+ <link rel="icon" type="image/png" href="${FAVICON_DATA_URI}">
287
297
  <style>html{background:#101217;color:#e8eaf0}</style>
288
298
  </head>
289
299
  <body>
@@ -384,6 +394,8 @@ export class ServeApp {
384
394
  return await this.replyHostLogs(segs[1])
385
395
  if (segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] === 'ping')
386
396
  return await this.replyHostPing(segs[1])
397
+ if (segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] === 'drift')
398
+ return await this.replyHostDrift(segs[1], req.url.includes('full=1'))
387
399
  if (segs[0] === 'images' && segs.length === 3 && segs[1] != null && segs[2] != null)
388
400
  return this.replyMemoryImage(`${segs[1]}/${segs[2]}`)
389
401
  if (segs[0] === 'outputs') return this.replyOutput(segs.slice(1))
@@ -404,6 +416,15 @@ export class ServeApp {
404
416
  return this.replySetHost(segs[1], req)
405
417
  if (req.method === 'POST' && segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] != null)
406
418
  return await this.replyHostAction(segs[1], segs[2])
419
+ if (
420
+ req.method === 'POST' &&
421
+ segs[0] === 'hosts' &&
422
+ segs.length === 4 &&
423
+ segs[1] != null &&
424
+ segs[2] === 'lora-civitai' &&
425
+ segs[3] != null
426
+ )
427
+ return await this.replyLoraCivitaiFetch(segs[1], segs[3])
407
428
  if (req.method === 'PUT' && segs[0] === 'prompt-enhancers' && segs.length === 2 && segs[1] != null)
408
429
  return this.replySavePromptEnhancer(segs[1], req)
409
430
  if (req.method === 'DELETE' && segs[0] === 'prompt-enhancers' && segs.length === 2 && segs[1] != null)
@@ -520,6 +541,18 @@ export class ServeApp {
520
541
  if (kw !== '') keywords[option] = kw
521
542
  }
522
543
  if (Object.keys(keywords).length > 0) desc.optionKeywords = keywords
544
+ const addedAt: Record<string, number> = {}
545
+ for (const option of desc.options) {
546
+ const t = getLoraAddedAt(option, hostId)
547
+ if (t != null) addedAt[option] = t
548
+ }
549
+ if (Object.keys(addedAt).length > 0) desc.optionAddedAt = addedAt
550
+ const triggers: Record<string, LoraTriggers> = {}
551
+ for (const option of desc.options) {
552
+ const t = getLoraTriggers(option, hostId)
553
+ if (t != null) triggers[option] = t
554
+ }
555
+ if (Object.keys(triggers).length > 0) desc.optionTriggers = triggers
523
556
  }
524
557
  vars[name] = desc
525
558
  }
@@ -818,6 +851,67 @@ export class ServeApp {
818
851
  })
819
852
  }
820
853
 
854
+ /** fetch ONE lora's civitai metadata through the lora manager, then re-sync the mirror so its
855
+ * trigger words reach every surface. The extension keys the request by the file path ON THE
856
+ * HOST, which only the mirror knows, so a lora outside the mirror needs a sync first */
857
+ private async replyLoraCivitaiFetch(hostId: string, lora: string): Promise<ServeReply> {
858
+ const host = comfyts.hosts.get(hostId)
859
+ if (host == null) return json(404, { error: `unknown host '${hostId}'` })
860
+ const info = getLoraInfo(lora, hostId)
861
+ const filePath = info == null ? null : lmFilePath(info)
862
+ if (filePath == null)
863
+ return json(404, { error: `'${lora}' is not in the lora manager mirror of ${hostId}: sync the mirror first` })
864
+ const fetched = await fetchLoraCivitai(host, filePath)
865
+ const sha256 = info == null ? null : lmSha256(info)
866
+ // civitai ANSWERED that it has no version for this hash: a definite result, kept so the
867
+ // card stops offering a fetch. Any other failure (network, the extension) stays an error
868
+ if (!fetched.ok && /no version data found/i.test(fetched.reason) && sha256 != null) {
869
+ recordCivitaiMiss({ hostId, sha256, miss: true })
870
+ return json(200, {
871
+ ok: true,
872
+ host: hostId,
873
+ lora,
874
+ triggers: { state: 'not-on-civitai' },
875
+ note: `civitai does not know '${lora}' (a private or local lora): no trigger words to fetch`,
876
+ })
877
+ }
878
+ if (!fetched.ok) return json(502, { error: `civitai fetch failed for '${lora}': ${fetched.reason}` })
879
+ if (sha256 != null) recordCivitaiMiss({ hostId, sha256, miss: false })
880
+ const synced = await this.refreshLoraMirror(hostId, host)
881
+ if (synced.status !== 200) return synced
882
+ const t = getLoraTriggers(lora, hostId)
883
+ const note =
884
+ t?.state === 'words'
885
+ ? `trigger words: ${t.words.join(', ')}`
886
+ : t?.state === 'none'
887
+ ? `civitai lists no trigger words for '${lora}'`
888
+ : `civitai has no metadata for '${lora}'`
889
+ return json(200, { ok: true, host: hostId, lora, triggers: t, note })
890
+ }
891
+
892
+ /** has the host changed since this process loaded its schema: new or removed model files (and
893
+ * node types on a full check). A host whose catalog is COMMITTED rather than live-synced
894
+ * (sdkAutoWrite: false, the cloud catalog) is not compared: its live list moves on purpose */
895
+ private async replyHostDrift(hostId: string, full: boolean): Promise<ServeReply> {
896
+ const host = comfyts.hosts.get(hostId)
897
+ if (host == null) return json(404, { error: `unknown host '${hostId}'` })
898
+ if (host.data.sdkAutoWrite === false)
899
+ return json(200, { host: hostId, checked: false, changed: false, summary: '' })
900
+ try {
901
+ const drift = await host.checkSchemaDrift({ full })
902
+ return json(200, {
903
+ host: hostId,
904
+ checked: true,
905
+ full,
906
+ changed: driftChanged(drift),
907
+ summary: summarizeDrift(drift),
908
+ drift,
909
+ })
910
+ } catch (e) {
911
+ return json(502, { error: `${hostId} unreachable: ${extractErrorMessage(e)}` })
912
+ }
913
+ }
914
+
821
915
  /** is the host answering RIGHT NOW: what the panel polls while a restart is in flight, so
822
916
  * "restarting…" ends on a fact rather than on a guess */
823
917
  private async replyHostPing(hostId: string): Promise<ServeReply> {
@@ -16,6 +16,7 @@ import type {
16
16
  VarKind,
17
17
  } from 'src/vars/ComfyVars.ts'
18
18
  import type { VarPreset } from 'src/vars/presets.ts'
19
+ import type { LoraTriggers } from 'src/host/loraInfoCache.ts'
19
20
 
20
21
  export type VarDescriptor = {
21
22
  kind: VarKind
@@ -41,6 +42,12 @@ export type VarDescriptor = {
41
42
  * the picker with a warning, because a lora present on disk usually runs even when the
42
43
  * server has not rescanned its list, filled by ServeApp.describeModule */
43
44
  managerOnlyOptions?: readonly string[]
45
+ /** loras: when each file landed on the host (epoch seconds, the lora manager's date), entries
46
+ * only where the mirror has one. The popup's `date added` sort reads it */
47
+ optionAddedAt?: Record<string, number>
48
+ /** loras: trigger words per option as the mirror knows them (words, fetched and empty, or
49
+ * civitai never asked). An option ABSENT from this record is not in the mirror at all */
50
+ optionTriggers?: Record<string, LoraTriggers>
44
51
  /** text: this one wants a box, not a line (`v.text(…, { multiline: true })`) */
45
52
  multiline?: boolean
46
53
  /** text + prompt: named starting texts (`{ presets: { label: text } }`). NOT `presets`, which
@@ -0,0 +1,3 @@
1
+ // generated by scripts/gen-favicon.ts from .shipkit/identity/icon.png, never edited by hand
2
+ export const FAVICON_DATA_URI =
3
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAKUklEQVR42u1aaWxU1xW2DWEJZCENNgaK8iNRU5UAAYKBWW1ImwbaoqiuQkrUVlRdlDZSGpqAcTKrFyAoJRCRKmpRidKA98Sm0MQhRClOs7CIggiTtniZN4sZe8AeL/Puvef23LeMnwePQdWwhTnS9XvP8zzvft/5znfPfXJWViYykYlMZCITmchEJjKRiUxc4eCcj8ExFkfOzQg+23huvL5pwFNKf8wYexmvZ2m/H6cpQlHFV5IYIXvtaMEh4+CM83/hIS9ZGSOUSvYNnXUNyC3iGgA2KuAZ7+NqvI3jZ6iKp3GsIYQsw+sZOmFJZIy5Ec0uRzufhOMHjMGnGnAUAAdtJALUqxgwOIYs7UBCViFptycTekNkXcv4eMzsL/Hap2Pkw0MQQbTBkj/UbvDjj514ukQvh+uWCOPE8LgUpX7UAJxpY7QAzqh6b1+rzPslZuANvZMdIoR/3/CMMdfNcqqBVyZDOV+P53FV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u7yqGTkKhq3WdvaKbmcu7uXDjpS6JCV+we0NgcQVgYWkA5pZICimrXw1DxTtRaDwaA18wDtjAsCQlGI0PPjozwH7++jnMekBZ6qweobIANXk6qb0iys3O1t9eE/AJErQH2zz+5ejAPmFGZndQEEBMeMTdmDApEOWBZaKAmLtBggUvIBi8XrklwNYiwOf3RMBV2wU73zsPcTLU8D21qxPuX9cGdqx5QSZ+JzF7z4HVG6EWl/9XaW13/09TyNZJWFHRNsXqkjZbPKE+++YYt3g7ccIBQQQ1aUQIEnDJQkLw3BmEpQ4/PFTqR2n7YfZz7XjeAYGonNDAX1su4ArTgWQpqiK2ivPY6ESiZkf7qusAvFEKSIK2/FjdHfcVYjuKkz5vq8SlUkwagSMAWRAiDNPsEhmVQBwFIVbF1ERtS9Di60+URPOpPrbwhQ6KpLJCQaoz8LnV3f7ANZX9qMtk8dD20+bwzbS7pOfMLv8RYVjWTQgAuzU0TI51jCRgD+EOyiYPkuLCFxi4muAKQkUp6AQ0Hu2nC51daHTBHqsr8OJKh3Tr9Qk+qX0uLh6aoDBLe3lHgd3d4UEgLWaPFLOWR3jhSwNclIoNX1tZUSXWcjyWdfECp8T2fNyDBknJ02/G+JySYH3xjrPT9O92OG6Q/yxRiEh6ISE2V49U+mYWlUmrcLkstTtbd1md/ibcwX2EajiEBnrMVBbBDs8vF3oCAyYkBZe6NQqRDj4u6wb9X4FsoQjVsFIA4HrZ8LHY1TUXbiXcUtHHbeWRTpvj7D1XvsO7qspw5NhsH4wVYB3KuwYNmAZw5UvS3bh8brW4gvvRKL/zlQKfSiEqCcaR/HnWzfWfZMX6snq1evtMZCITmchEJjKRiUxkIhM3ZfwPK9dyLD4coj4AAAAASUVORK5CYII='
@@ -176,6 +176,18 @@ export function postHostAction(p: { host: string; action: HostAction }): Promise
176
176
  return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/${p.action}`, { method: 'POST' })
177
177
  }
178
178
 
179
+ export type HostDrift = { host: string; checked: boolean; changed: boolean; summary: string }
180
+
181
+ export function fetchHostDrift(p: { host: string; full: boolean }): Promise<HostDrift> {
182
+ return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/drift${p.full ? '?full=1' : ''}`)
183
+ }
184
+
185
+ export function postLoraCivitai(p: { host: string; lora: string }): Promise<{ ok: true; note: string }> {
186
+ return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/lora-civitai/${encodeURIComponent(p.lora)}`, {
187
+ method: 'POST',
188
+ })
189
+ }
190
+
179
191
  export function fetchHostLogs(p: { host: string }): Promise<{ lines: string[] }> {
180
192
  return jsonFetch(`/hosts/${encodeURIComponent(p.host)}/logs`)
181
193
  }
@@ -411,13 +411,24 @@ export const VarsForm = observer(function VarsForm(p: { st: WebSt }) {
411
411
  >
412
412
  <Icon name="trash" />
413
413
  </button>
414
- <button
415
- type="button"
416
- data-tip="refetch object_info from the host and rewrite sdk.d.ts (the var lists widen in place)"
417
- onClick={() => void p.st.hostAction('refresh-schema')}
418
- >
419
- <Icon name="refresh" />
420
- </button>
414
+ {p.st.drift != null && p.st.drift.host === p.st.hostFor(form.moduleKey) ? (
415
+ <button
416
+ type="button"
417
+ className="attention"
418
+ data-tip={`the host changed since this panel loaded its schema (${p.st.drift.summary}): refetch to use it`}
419
+ onClick={() => void p.st.hostAction('refresh-schema')}
420
+ >
421
+ <Icon name="refresh" /> {p.st.drift.summary}
422
+ </button>
423
+ ) : (
424
+ <button
425
+ type="button"
426
+ data-tip="refetch object_info from the host and rewrite sdk.d.ts (the var lists widen in place)"
427
+ onClick={() => void p.st.hostAction('refresh-schema')}
428
+ >
429
+ <Icon name="refresh" />
430
+ </button>
431
+ )}
421
432
  <button
422
433
  type="button"
423
434
  className="danger"
@@ -19,6 +19,7 @@ import { fetchLoraAbout, fetchLoraInfo, loraPreviewSrc, type LoraAbout, type Lor
19
19
  import type { LoraStrength } from 'src/vars/ComfyVars.ts'
20
20
  import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
21
21
  import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
22
+ import { LORA_SORTS, sortLoraMatches } from 'src/cli/serve/web/state/loraSort.ts'
22
23
  import {
23
24
  loraIsOn,
24
25
  paletteOrder,
@@ -135,6 +136,76 @@ export const LorasControl = observer(function LorasControl(p: {
135
136
  * ones ComfyUI has no entry for until it rescans its models */
136
137
  const managerOnlyInUse = selectedNames.filter((n) => managerOnly.has(n))
137
138
  const showImages = p.st.showLoraImages
139
+ const triggers = p.v.desc.optionTriggers ?? {}
140
+ /** the trigger words under a row card, in one of FOUR states that never look alike: the
141
+ * words, a definite none (civitai was asked), never fetched (a button asks it), or not in
142
+ * the mirror at all (a button syncs it). Titles hidden hides the words, never the state */
143
+ const triggerLine = (name: string): ReactNode => {
144
+ const t = triggers[name]
145
+ if (t == null)
146
+ return (
147
+ <span className="chip-triggers missing">
148
+ not in the lora manager mirror
149
+ <button
150
+ type="button"
151
+ className="trigger-fetch"
152
+ disabled={p.st.loraSyncing}
153
+ data-tip="re-download the lora manager's list for this host (names, trigger words, previews)"
154
+ onClick={() => void p.st.refreshLoras()}
155
+ >
156
+ {p.st.loraSyncing ? 'syncing…' : 'sync'}
157
+ </button>
158
+ </span>
159
+ )
160
+ if (t.state === 'unfetched') {
161
+ const busy = p.st.loraFetching.has(name)
162
+ return (
163
+ <span className="chip-triggers missing">
164
+ trigger words never fetched
165
+ <button
166
+ type="button"
167
+ className="trigger-fetch"
168
+ disabled={busy}
169
+ data-tip="ask the lora manager to fetch this lora's civitai metadata, trigger words included"
170
+ onClick={() => void p.st.fetchLoraTriggers(name)}
171
+ >
172
+ {busy ? 'fetching…' : 'fetch'}
173
+ </button>
174
+ </span>
175
+ )
176
+ }
177
+ if (t.state === 'not-on-civitai') {
178
+ const busy = p.st.loraFetching.has(name)
179
+ return (
180
+ <span
181
+ className="chip-triggers missing"
182
+ data-tip="civitai was asked and has no version for this file: a private or local lora, so no trigger words exist there"
183
+ >
184
+ not on civitai
185
+ <button
186
+ type="button"
187
+ className="trigger-fetch"
188
+ disabled={busy}
189
+ data-tip="ask civitai again (it may have been published since)"
190
+ onClick={() => void p.st.fetchLoraTriggers(name)}
191
+ >
192
+ {busy ? 'asking…' : 'retry'}
193
+ </button>
194
+ </span>
195
+ )
196
+ }
197
+ if (t.state === 'none')
198
+ return (
199
+ <span className="chip-triggers none" data-tip="civitai was asked, and this lora has no trigger words">
200
+ no trigger words
201
+ </span>
202
+ )
203
+ return (
204
+ <span className="chip-triggers words" data-tip={showTitles ? t.words.join('\n') : 'titles are hidden'}>
205
+ {showTitles ? t.words.join(', ') : `${t.words.length} trigger word${t.words.length === 1 ? '' : 's'}`}
206
+ </span>
207
+ )
208
+ }
138
209
  const showTitles = p.st.showLoraTitles
139
210
 
140
211
  /** add to the palette (a strength) or REMOVE from it entirely (null) */
@@ -224,7 +295,12 @@ export const LorasControl = observer(function LorasControl(p: {
224
295
  const needle = local.filter.toLowerCase()
225
296
  const matchesFilter = (name: string): boolean =>
226
297
  name.toLowerCase().includes(needle) || label(name).toLowerCase().includes(needle)
227
- const matches = options.filter(matchesFilter)
298
+ const matches = sortLoraMatches({
299
+ names: options.filter(matchesFilter),
300
+ mode: p.st.loraSort,
301
+ label,
302
+ addedAt: p.v.desc.optionAddedAt ?? {},
303
+ })
228
304
  const cardCap = p.st.loraCap
229
305
  const cards = matches.filter((o) => !isInPalette(o)).slice(0, cardCap)
230
306
  /** the enum value IS a path (`krea2\styles\x.safetensors`, separators vary by host and by
@@ -234,6 +310,7 @@ export const LorasControl = observer(function LorasControl(p: {
234
310
  return parts.length <= 1 ? '' : parts.slice(0, -1).join('/')
235
311
  }
236
312
  const groupedCards = (() => {
313
+ if (p.st.loraSort !== 'folder') return [{ folder: null, names: cards }]
237
314
  const byFolder = new Map<string, string[]>()
238
315
  for (const name of cards) {
239
316
  const folder = folderOf(name)
@@ -466,6 +543,7 @@ export const LorasControl = observer(function LorasControl(p: {
466
543
  {warnBadge(name)}
467
544
  </span>
468
545
  <span className="chip-controls">{strengthInputs(name)}</span>
546
+ {triggerLine(name)}
469
547
  </span>
470
548
  ))
471
549
  )}
@@ -543,12 +621,30 @@ export const LorasControl = observer(function LorasControl(p: {
543
621
  })}
544
622
  </div>
545
623
  ) : null}
546
- <div className="section-title">all loras — tap to add to the palette</div>
624
+ <div className="section-title lora-sort-head">
625
+ all loras — tap to add to the palette
626
+ <span className="lora-sort">
627
+ sort
628
+ {LORA_SORTS.map((s) => (
629
+ <button
630
+ key={s.mode}
631
+ type="button"
632
+ className={p.st.loraSort === s.mode ? 'mode sel' : 'mode'}
633
+ data-tip={s.tip}
634
+ onClick={() => p.st.setLoraSort(s.mode)}
635
+ >
636
+ {s.label}
637
+ </button>
638
+ ))}
639
+ </span>
640
+ </div>
547
641
  {groupedCards.map((group) => (
548
- <div key={group.folder}>
549
- <div className="section-title">
550
- {group.folder === '' ? 'loose (no folder)' : `${group.folder}/`} · {group.names.length}
551
- </div>
642
+ <div key={group.folder ?? '*'}>
643
+ {group.folder == null ? null : (
644
+ <div className="section-title">
645
+ {group.folder === '' ? 'loose (no folder)' : `${group.folder}/`} · {group.names.length}
646
+ </div>
647
+ )}
552
648
  <div className="lora-grid">
553
649
  {group.names.map((name) => (
554
650
  <button