comfy-ts 2.7.0 → 2.9.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 (104) hide show
  1. package/README.md +20 -13
  2. package/dist/{DefinedWorkflow-BJgt5t0x.js → DefinedWorkflow-BatWaZO1.js} +199 -16
  3. package/dist/DefinedWorkflow-BatWaZO1.js.map +1 -0
  4. package/dist/{DraftsSt-dizp3VcC.js → LogsSt-DFxzQfDc.js} +152 -4
  5. package/dist/LogsSt-DFxzQfDc.js.map +1 -0
  6. package/dist/cli.js +7 -5
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +284 -35
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +125 -7
  11. package/dist/index.d.ts +125 -7
  12. package/dist/index.js +282 -37
  13. package/dist/index.js.map +1 -1
  14. package/dist/run-serve-_nrvJYyt.js +1948 -0
  15. package/dist/run-serve-_nrvJYyt.js.map +1 -0
  16. package/dist/{run-tui-JxlEbb_f.js → run-tui-BLEdTsOX.js} +106 -157
  17. package/dist/run-tui-BLEdTsOX.js.map +1 -0
  18. package/dist/serve-web.js +441 -72
  19. package/dist/{state-CaHeDL-0.js → state-BbgJeCe6.js} +180 -45
  20. package/dist/state-BbgJeCe6.js.map +1 -0
  21. package/dist/web.d.ts +185 -7
  22. package/dist/web.js +235 -36
  23. package/dist/web.js.map +1 -1
  24. package/examples/README.md +1 -0
  25. package/examples/comfy-cloud/sdk.d.ts +4066 -321
  26. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +18 -2
  27. package/examples/rvion/07-local-llm-text-gen.cflow.ts +220 -0
  28. package/examples/web/tsconfig.json +3 -0
  29. package/extra/README.md +32 -0
  30. package/extra/comfyui-textgen-stream/README.md +35 -0
  31. package/extra/comfyui-textgen-stream/__init__.py +166 -0
  32. package/extra/scripts/fetch_text_encoder.py +137 -0
  33. package/package.json +6 -3
  34. package/src/cli/comfy-ts-cli.ts +3 -1
  35. package/src/cli/serve/ServeApp.ts +754 -40
  36. package/src/cli/serve/applyVarPayload.ts +10 -3
  37. package/src/cli/serve/describeVar.ts +47 -7
  38. package/src/cli/serve/hostProtocol.ts +68 -0
  39. package/src/cli/serve/managerOnlyLoras.ts +27 -0
  40. package/src/cli/serve/run-serve.ts +35 -38
  41. package/src/cli/serve/serveSettings.ts +86 -0
  42. package/src/cli/serve/startupPrint.ts +111 -0
  43. package/src/cli/serve/web/api.ts +97 -1
  44. package/src/cli/serve/web/components/App.tsx +61 -22
  45. package/src/cli/serve/web/components/Gallery.tsx +306 -41
  46. package/src/cli/serve/web/components/Icon.tsx +160 -0
  47. package/src/cli/serve/web/components/PromptEnhancer.tsx +12 -9
  48. package/src/cli/serve/web/components/Sidebar.tsx +43 -19
  49. package/src/cli/serve/web/components/VarsForm.tsx +440 -91
  50. package/src/cli/serve/web/components/controls/BasicControls.tsx +38 -5
  51. package/src/cli/serve/web/components/controls/ImageControl.tsx +3 -2
  52. package/src/cli/serve/web/components/controls/LorasControl.tsx +498 -81
  53. package/src/cli/serve/web/components/controls/PresetPicker.tsx +60 -0
  54. package/src/cli/serve/web/components/controls/SeedControl.tsx +38 -20
  55. package/src/cli/serve/web/components/controls/SizeControl.tsx +3 -2
  56. package/src/cli/serve/web/llm.ts +1 -1
  57. package/src/cli/serve/web/logWeb.ts +6 -0
  58. package/src/cli/serve/web/state/EnhancerSt.ts +8 -15
  59. package/src/cli/serve/web/state/FormSt.ts +74 -18
  60. package/src/cli/serve/web/state/RunSt.ts +22 -1
  61. package/src/cli/serve/web/state/WebSt.ts +814 -22
  62. package/src/cli/serve/web/state/host.ts +206 -0
  63. package/src/cli/serve/web/state/lightbox.ts +44 -0
  64. package/src/cli/serve/web/state/moduleTree.ts +52 -0
  65. package/src/cli/serve/web/state/payload.ts +44 -2
  66. package/src/cli/serve/web/state/urlSelection.ts +53 -0
  67. package/src/cli/serve/web/styles.ts +422 -57
  68. package/src/cli/serve/web/tsconfig.json +4 -0
  69. package/src/cli/tui/components/PickerOverlays.tsx +37 -0
  70. package/src/cli/tui/components/StatusBar.tsx +14 -1
  71. package/src/cli/tui/components/TuiApp.tsx +5 -2
  72. package/src/cli/tui/state/HostSt.ts +3 -2
  73. package/src/cli/tui/state/PickerSt.ts +48 -2
  74. package/src/cli/tui/state/TreeSt.ts +1 -1
  75. package/src/cli/tui/state/TuiSt.ts +2 -1
  76. package/src/coreExports.ts +8 -1
  77. package/src/graph/ComfyNode.ts +58 -1
  78. package/src/host/ComfyHost.ts +13 -2
  79. package/src/host/ComfyManager.ts +31 -13
  80. package/src/host/loraInfoCache.ts +35 -1
  81. package/src/host/loraManagerApi.ts +94 -0
  82. package/src/index.ts +2 -0
  83. package/src/promptEnhancers.ts +102 -0
  84. package/src/runner/ComfyExecution.ts +61 -6
  85. package/src/runner/ComfyWorkflow.ts +18 -4
  86. package/src/runner/ComfyWsApi.ts +3 -0
  87. package/src/runner/describePromptRejection.ts +34 -0
  88. package/src/sdk-generator/ComfySchema.ts +17 -4
  89. package/src/sdk-generator/comfyui-sdk-codegen.ts +56 -2
  90. package/src/utils/ansi.ts +13 -0
  91. package/src/utils/matchesRegex.ts +13 -0
  92. package/src/utils/safeName.ts +29 -0
  93. package/src/utils/stringMap.ts +9 -0
  94. package/src/vars/ComfyVars.ts +61 -10
  95. package/src/vars/presets.ts +17 -0
  96. package/src/web.ts +12 -0
  97. package/dist/DefinedWorkflow-BJgt5t0x.js.map +0 -1
  98. package/dist/DraftsSt-dizp3VcC.js.map +0 -1
  99. package/dist/run-serve-D1Tsuru9.js +0 -1162
  100. package/dist/run-serve-D1Tsuru9.js.map +0 -1
  101. package/dist/run-tui-JxlEbb_f.js.map +0 -1
  102. package/dist/state-CaHeDL-0.js.map +0 -1
  103. package/src/cli/serve/promptEnhancers.ts +0 -69
  104. package/src/cli/serve/safeName.ts +0 -12
@@ -1,69 +0,0 @@
1
- // the master prompts of the web ui's prompt enhancer, as FILES:
2
- // `.comfy-ts/prompt-enhancers/<name>.md`, the drafts model applied to prose.
3
- // Markdown, not json: these are hand-edited paragraphs, and a json string field
4
- // would be one escaped line. The FILENAME is the identity (a rename is a write
5
- // plus a delete); validStoreName is the same gate the draft routes use.
6
- import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
7
- import { join } from 'pathe'
8
- import { validStoreName } from 'src/cli/serve/safeName.ts'
9
-
10
- const EXT = '.md'
11
-
12
- export type PromptEnhancer = { name: string; text: string }
13
-
14
- export function promptEnhancersDir(): string {
15
- return comfyts.resolveFromPromptEnhancers('')
16
- }
17
-
18
- export function promptEnhancerPath(name: string): string | null {
19
- const safe = validStoreName(name)
20
- return safe == null ? null : join(promptEnhancersDir(), `${safe}${EXT}`)
21
- }
22
-
23
- /** the shipped starting point. It is a FILE from the first read on, so it can be edited
24
- * on disk like everything else — the browser ships no copy of this text */
25
- const SEED: PromptEnhancer = {
26
- name: 'refine-krea2-prompt',
27
- text: `You rewrite image prompts for krea2 turbo, a distilled 8 step text to image model whose text encoder reads flowing natural language, not tag soup, and which is steered by adjectives rather than by negatives.
28
-
29
- Rewrite the user's prompt into ONE dense paragraph someone could picture with their eyes closed:
30
- - keep every noun and every named subject the user wrote, they are the point
31
- - add what is missing to make it fun to look at: lighting, palette, material, texture, camera angle, composition, mood
32
- - prefer concrete visual nouns over praise, never write "masterpiece", "8k", "highly detailed", "award winning"
33
- - stay under about 80 words, no lists, no headings, no quotes around the result
34
- - keep any "// " comment line and any "- " negative line from the input verbatim, each on its own line
35
-
36
- Answer with the rewritten prompt and nothing else: no preamble, no explanation.
37
- `,
38
- }
39
-
40
- /** seeds ONCE, on an absent folder. A folder he emptied on purpose stays empty */
41
- export function listPromptEnhancers(): PromptEnhancer[] {
42
- const dir = promptEnhancersDir()
43
- if (!existsSync(dir)) writePromptEnhancer(SEED.name, SEED.text)
44
- if (!existsSync(dir)) return []
45
- const out: PromptEnhancer[] = []
46
- for (const file of readdirSync(dir).sort()) {
47
- if (!file.endsWith(EXT)) continue
48
- const name = file.slice(0, -EXT.length)
49
- if (validStoreName(name) == null) continue
50
- out.push({ name, text: readFileSync(join(dir, file), 'utf8') })
51
- }
52
- return out
53
- }
54
-
55
- export function writePromptEnhancer(name: string, text: string): string | null {
56
- const path = promptEnhancerPath(name)
57
- if (path == null) return null
58
- mkdirSync(promptEnhancersDir(), { recursive: true })
59
- writeFileSync(path, text)
60
- return path
61
- }
62
-
63
- /** a missing file is still a success: the caller asked for it to be gone, and it is */
64
- export function deletePromptEnhancer(name: string): boolean {
65
- const path = promptEnhancerPath(name)
66
- if (path == null) return false
67
- if (existsSync(path)) rmSync(path)
68
- return true
69
- }
@@ -1,12 +0,0 @@
1
- // THE name gate for every serve route that turns a url segment into a file path.
2
- // SECURITY-CRITICAL and deliberately shared: handle() decodes per segment, so
3
- // `%2F` arrives as a real `/` while the segment count still looks right. One
4
- // function, because a second regex somewhere else is a second traversal hole.
5
-
6
- /** the accepted name, or null. Rejects traversal, absolute paths, leading dots and empties */
7
- export function validStoreName(raw: string): string | null {
8
- const name = raw.trim()
9
- // length cap: past it the fs answers ENAMETOOLONG as a raw 500
10
- if (name.length > 100) return null
11
- return /^[\w][\w .-]*$/.test(name) ? name : null
12
- }