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
@@ -0,0 +1,160 @@
1
+ // ONE inline svg icon set for the panel. No icon font, no dependency, no emoji:
2
+ // emoji render differently per platform (and a phone shows its own set), so an
3
+ // affordance drawn with one is not the same button on two devices.
4
+ // every path uses currentColor and 1em, so an icon inherits the text it sits in.
5
+ import type { ReactNode } from 'react'
6
+
7
+ export type IconName =
8
+ | 'close'
9
+ | 'trash'
10
+ | 'copy'
11
+ | 'external'
12
+ | 'dice'
13
+ | 'image'
14
+ | 'tag'
15
+ | 'sparkle'
16
+ | 'play'
17
+ | 'pause'
18
+ | 'save'
19
+ | 'ghost'
20
+ | 'panel-off'
21
+ | 'panel-bottom'
22
+ | 'panel-side'
23
+ | 'panel-left'
24
+ | 'panel-corner'
25
+ | 'swap'
26
+ | 'plus'
27
+ | 'copy-plus'
28
+ | 'pen'
29
+ | 'broom'
30
+ | 'expand'
31
+ | 'shrink'
32
+ | 'power'
33
+ | 'warn'
34
+ | 'grip'
35
+ | 'link'
36
+ | 'unlink'
37
+ | 'refresh'
38
+ | 'terminal'
39
+ | 'folder'
40
+ | 'dot'
41
+
42
+ /** 24x24 viewBox paths, stroked (fill: none) unless the shape reads better solid */
43
+ const PATHS: Record<IconName, ReactNode> = {
44
+ close: <path d="M6 6l12 12M18 6L6 18" />,
45
+ trash: <path d="M4 7h16M10 7V5h4v2M6 7l1 12h10l1-12M10 11v5M14 11v5" />,
46
+ copy: <path d="M9 9h10v10H9zM5 15V5h10" />,
47
+ external: <path d="M14 5h5v5M19 5l-8 8M18 14v5H5V6h5" />,
48
+ dice: (
49
+ <>
50
+ <rect x="4" y="4" width="16" height="16" rx="3" />
51
+ <circle cx="9" cy="9" r="1.3" fill="currentColor" stroke="none" />
52
+ <circle cx="15" cy="15" r="1.3" fill="currentColor" stroke="none" />
53
+ <circle cx="12" cy="12" r="1.3" fill="currentColor" stroke="none" />
54
+ </>
55
+ ),
56
+ image: (
57
+ <>
58
+ <rect x="3" y="5" width="18" height="14" rx="2" />
59
+ <circle cx="8.5" cy="10" r="1.5" />
60
+ <path d="M4 17l5-5 4 4 3-2 4 4" />
61
+ </>
62
+ ),
63
+ tag: (
64
+ <>
65
+ <path d="M4 11V4h7l9 9-7 7-9-9z" />
66
+ <circle cx="8" cy="8" r="1.3" fill="currentColor" stroke="none" />
67
+ </>
68
+ ),
69
+ sparkle: (
70
+ <path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9zM18 15l.8 2.2L21 18l-2.2.8L18 21l-.8-2.2L15 18l2.2-.8z" />
71
+ ),
72
+ play: <path d="M7 4l13 8-13 8z" fill="currentColor" stroke="none" />,
73
+ pause: <path d="M8 5v14M16 5v14" />,
74
+ save: <path d="M5 4h11l3 3v13H5zM8 4v6h7V4M8 20v-6h8v6" />,
75
+ ghost: <path d="M5 20V10a7 7 0 0114 0v10l-2.3-2-2.4 2-2.3-2-2.4 2zM9.5 10h.01M14.5 10h.01" />,
76
+ 'panel-off': (
77
+ <>
78
+ <rect x="3" y="4" width="18" height="16" rx="2" />
79
+ <path d="M4 5l16 14" />
80
+ </>
81
+ ),
82
+ 'panel-bottom': (
83
+ <>
84
+ <rect x="3" y="4" width="18" height="16" rx="2" />
85
+ <path d="M3 14h18" />
86
+ <rect x="4.5" y="15.5" width="15" height="3" fill="currentColor" stroke="none" opacity="0.85" />
87
+ </>
88
+ ),
89
+ 'panel-side': (
90
+ <>
91
+ <rect x="3" y="4" width="18" height="16" rx="2" />
92
+ <path d="M14 4v16" />
93
+ <rect x="15.5" y="5.5" width="4" height="13" fill="currentColor" stroke="none" opacity="0.85" />
94
+ </>
95
+ ),
96
+ 'panel-left': (
97
+ <>
98
+ <rect x="3" y="4" width="18" height="16" rx="2" />
99
+ <path d="M10 4v16" />
100
+ <rect x="4.5" y="5.5" width="4" height="13" fill="currentColor" stroke="none" opacity="0.85" />
101
+ </>
102
+ ),
103
+ /* same frame as the other placements, filled in the corner it actually occupies — a pin
104
+ said "sticky" while every sibling said WHERE */
105
+ 'panel-corner': (
106
+ <>
107
+ <rect x="3" y="4" width="18" height="16" rx="2" />
108
+ <rect x="12.5" y="12.5" width="7" height="6" fill="currentColor" stroke="none" opacity="0.85" />
109
+ </>
110
+ ),
111
+ swap: <path d="M4 8h13l-3-3M20 16H7l3 3" />,
112
+ plus: <path d="M12 5v14M5 12h14" />,
113
+ 'copy-plus': <path d="M9 9h10v10H9zM5 15V5h10M14 12v4M12 14h4" />,
114
+ pen: <path d="M4 20h4L20 8l-4-4L4 16zM14 6l4 4" />,
115
+ broom: <path d="M19 4l-7 7M9.5 8.5l6 6-5 5-6-6zM4.5 13.5L2 21l7.5-2.5" />,
116
+ expand: <path d="M4 9V4h5M20 15v5h-5M15 4h5v5M9 20H4v-5" />,
117
+ shrink: <path d="M9 4v5H4M15 20v-5h5M20 9h-5V4M4 15h5v5" />,
118
+ power: <path d="M12 3v9M7.5 6.5a7 7 0 109 0" />,
119
+ warn: <path d="M12 4l9 16H3zM12 10v4M12 17h.01" />,
120
+ link: (
121
+ <path d="M10 14a4 4 0 015.7 0l2.6-2.6a4 4 0 10-5.7-5.7L11 7.3M14 10a4 4 0 01-5.7 0l-2.6 2.6a4 4 0 105.7 5.7L13 16.7" />
122
+ ),
123
+ unlink: <path d="M9 15l-1.6 1.6a4 4 0 01-5.7-5.7L3.3 9.3M15 9l1.6-1.6a4 4 0 015.7 5.7L20.7 14.7M4 4l16 16" />,
124
+ grip: (
125
+ <>
126
+ <circle cx="9" cy="6" r="1.4" fill="currentColor" stroke="none" />
127
+ <circle cx="15" cy="6" r="1.4" fill="currentColor" stroke="none" />
128
+ <circle cx="9" cy="12" r="1.4" fill="currentColor" stroke="none" />
129
+ <circle cx="15" cy="12" r="1.4" fill="currentColor" stroke="none" />
130
+ <circle cx="9" cy="18" r="1.4" fill="currentColor" stroke="none" />
131
+ <circle cx="15" cy="18" r="1.4" fill="currentColor" stroke="none" />
132
+ </>
133
+ ),
134
+ refresh: <path d="M20 11a8 8 0 10-2 6M20 6v5h-5" />,
135
+ terminal: <path d="M4 5h16v14H4zM7 9l3 3-3 3M13 15h4" />,
136
+ folder: <path d="M3 7h6l2 2h10v10H3z" />,
137
+ dot: <circle cx="12" cy="12" r="5" fill="currentColor" stroke="none" />,
138
+ }
139
+
140
+ /** `size` is a multiplier of the surrounding font size, so icons scale with their button */
141
+ export function Icon(p: { name: IconName; size?: number; title?: string }): ReactNode {
142
+ return (
143
+ <svg
144
+ className="icon"
145
+ viewBox="0 0 24 24"
146
+ width={`${p.size ?? 1.15}em`}
147
+ height={`${p.size ?? 1.15}em`}
148
+ fill="none"
149
+ stroke="currentColor"
150
+ strokeWidth={1.8}
151
+ strokeLinecap="round"
152
+ strokeLinejoin="round"
153
+ aria-hidden={p.title == null}
154
+ role={p.title == null ? undefined : 'img'}
155
+ >
156
+ {p.title == null ? null : <title>{p.title}</title>}
157
+ {PATHS[p.name]}
158
+ </svg>
159
+ )
160
+ }
@@ -1,5 +1,6 @@
1
1
  // ✨ on a prompt row → the refine modal: openrouter key + thinking model +
2
2
  // a library of named master prompts. Nothing touches the var until APPLY.
3
+ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
3
4
  import { observer } from 'mobx-react-lite'
4
5
  import { useEffect } from 'react'
5
6
  import type { ProviderId, ReasoningEffort } from 'src/cli/serve/web/llm.ts'
@@ -70,12 +71,12 @@ const Settings = observer(function Settings(p: { e: EnhancerSt }) {
70
71
  style={{ flex: 1 }}
71
72
  />
72
73
  )}
73
- <label className="row-inline" title="hide models that report no reasoning support">
74
+ <label className="row-inline" data-tip="hide models that report no reasoning support">
74
75
  <input type="checkbox" checked={p.e.thinkingOnly} onChange={() => p.e.toggleThinkingOnly()} />
75
76
  <span className="hint">thinking only</span>
76
77
  </label>
77
78
  {local ? null : (
78
- <label className="row-inline" title="reasoning effort sent to the model">
79
+ <label className="row-inline" data-tip="reasoning effort sent to the model">
79
80
  <span className="hint">effort</span>
80
81
  <select value={p.e.effort} onChange={(ev) => p.e.setEffort(ev.target.value)}>
81
82
  {EFFORTS.map((x) => (
@@ -146,8 +147,8 @@ const MasterPrompt = observer(function MasterPrompt(p: { e: EnhancerSt }) {
146
147
  <button type="button" onClick={rename}>
147
148
  rename
148
149
  </button>
149
- <button type="button" onClick={remove} title="delete this master prompt file">
150
- ✕
150
+ <button type="button" onClick={remove} data-tip="delete this master prompt file">
151
+ <Icon name="close" />
151
152
  </button>
152
153
  <span className="hint">
153
154
  {p.e.saveState === 'saving' ? 'saving…' : null}
@@ -179,9 +180,11 @@ const Modal = observer(function Modal(p: { e: EnhancerSt }) {
179
180
  <div className="modal-overlay" onClick={() => e.close()}>
180
181
  <div className="modal" onClick={(ev) => ev.stopPropagation()}>
181
182
  <div className="modal-head">
182
- <b style={{ flex: 1 }}>✨ enhance prompt</b>
183
+ <b style={{ flex: 1 }}>
184
+ <Icon name="sparkle" /> enhance prompt
185
+ </b>
183
186
  <button type="button" onClick={() => e.close()}>
184
- ✕
187
+ <Icon name="close" />
185
188
  </button>
186
189
  </div>
187
190
  <div className="modal-body">
@@ -217,7 +220,7 @@ const Modal = observer(function Modal(p: { e: EnhancerSt }) {
217
220
  stop
218
221
  </button>
219
222
  ) : (
220
- <button type="button" className="primary" onClick={() => e.run()} title="⌘⏎ / ctrl+⏎">
223
+ <button type="button" className="primary" onClick={() => e.run()} data-tip="⌘⏎ / ctrl+⏎">
221
224
  enhance
222
225
  </button>
223
226
  )}
@@ -243,10 +246,10 @@ export const PromptEnhancer = observer(function PromptEnhancer(p: { v: VarSt; st
243
246
  <button
244
247
  type="button"
245
248
  className="link"
246
- title="rewrite this prompt with an llm"
249
+ data-tip="rewrite this prompt with an llm"
247
250
  onClick={() => e.openFor({ v: p.v, module: p.module })}
248
251
  >
249
- ✨ enhance
252
+ <Icon name="sparkle" /> enhance
250
253
  </button>
251
254
  {e.target === p.v ? <Modal e={e} /> : null}
252
255
  </>
@@ -1,29 +1,53 @@
1
- // module → drafts navigation + module load errors, mirrors the TUI tree's job
1
+ // module → drafts navigation + module load errors, mirrors the TUI tree's job.
2
+ // A TREE: folder, then its workflows, then their drafts, the folder is part of
3
+ // what identifies a workflow, and eating it made six workflows look like a flat list
2
4
  import { observer } from 'mobx-react-lite'
5
+ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
6
+ import { groupModulesByFolder } from 'src/cli/serve/web/state/moduleTree.ts'
3
7
  import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
4
8
 
5
9
  export const Sidebar = observer(function Sidebar(p: { st: WebSt }) {
10
+ const groups = groupModulesByFolder(p.st.modules)
6
11
  return (
7
12
  <div className="sidebar">
8
- {p.st.modules.map((mod) => (
9
- <div key={mod.module}>
10
- <div className="side-module">
11
- <span className="name">{mod.module}</span>
12
- <span className="host">{mod.host}</span>
13
+ {/* it opens from the WORKFLOW head box, which nothing announces: a way OUT that is
14
+ visible from inside is what makes that discoverable, and it says where it is */}
15
+ <div className="side-head">
16
+ <span>workflows</span>
17
+ <button
18
+ type="button"
19
+ data-tip="close — reopen it by clicking the workflow name"
20
+ onClick={() => p.st.toggleSidebar()}
21
+ >
22
+ <Icon name="close" />
23
+ </button>
24
+ </div>
25
+ {groups.map((group) => (
26
+ <div key={group.folder} className="side-group">
27
+ {group.folder === '' ? null : <div className="side-folder">{group.folder}/</div>}
28
+ <div className="side-branch">
29
+ {group.modules.map((mod) => (
30
+ <div key={mod.module}>
31
+ <div className="side-module">
32
+ <span className="name">{mod.module}</span>
33
+ <span className="host">{mod.host}</span>
34
+ </div>
35
+ {mod.drafts.map((draft) => {
36
+ const sel = p.st.form?.moduleKey === mod.module && p.st.form?.draft === draft
37
+ return (
38
+ <button
39
+ key={draft}
40
+ type="button"
41
+ className={sel ? 'side-draft sel' : 'side-draft'}
42
+ onClick={() => void p.st.select({ module: mod.module, draft })}
43
+ >
44
+ {draft}
45
+ </button>
46
+ )
47
+ })}
48
+ </div>
49
+ ))}
13
50
  </div>
14
- {mod.drafts.map((draft) => {
15
- const sel = p.st.form?.moduleKey === mod.module && p.st.form?.draft === draft
16
- return (
17
- <button
18
- key={draft}
19
- type="button"
20
- className={sel ? 'side-draft sel' : 'side-draft'}
21
- onClick={() => void p.st.select({ module: mod.module, draft })}
22
- >
23
- {draft}
24
- </button>
25
- )
26
- })}
27
51
  </div>
28
52
  ))}
29
53
  {Object.keys(p.st.loadErrors).length > 0 ? (