comfy-ts 2.6.0 → 2.8.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 (101) hide show
  1. package/README.md +22 -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 +8 -6
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +288 -35
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +128 -7
  11. package/dist/index.d.ts +128 -7
  12. package/dist/index.js +286 -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-idFhdO4f.js → run-tui-BPw-SZYW.js} +107 -158
  17. package/dist/run-tui-BPw-SZYW.js.map +1 -0
  18. package/dist/serve-web.js +434 -81
  19. package/dist/{state-C90kdjtB.js → state-B-boDz-Z.js} +184 -45
  20. package/dist/state-B-boDz-Z.js.map +1 -0
  21. package/dist/web.d.ts +112 -7
  22. package/dist/web.js +239 -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 +7 -1
  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 +4 -2
  35. package/src/cli/serve/ServeApp.ts +825 -43
  36. package/src/cli/serve/applyVarPayload.ts +10 -3
  37. package/src/cli/serve/describeVar.ts +47 -7
  38. package/src/cli/serve/managerOnlyLoras.ts +27 -0
  39. package/src/cli/serve/run-serve.ts +58 -29
  40. package/src/cli/serve/serveSettings.ts +86 -0
  41. package/src/cli/serve/startupPrint.ts +111 -0
  42. package/src/cli/serve/web/api.ts +120 -1
  43. package/src/cli/serve/web/components/App.tsx +61 -22
  44. package/src/cli/serve/web/components/Gallery.tsx +243 -30
  45. package/src/cli/serve/web/components/Icon.tsx +160 -0
  46. package/src/cli/serve/web/components/PromptEnhancer.tsx +85 -38
  47. package/src/cli/serve/web/components/Sidebar.tsx +43 -19
  48. package/src/cli/serve/web/components/VarsForm.tsx +440 -80
  49. package/src/cli/serve/web/components/controls/BasicControls.tsx +38 -5
  50. package/src/cli/serve/web/components/controls/ImageControl.tsx +3 -2
  51. package/src/cli/serve/web/components/controls/LorasControl.tsx +498 -81
  52. package/src/cli/serve/web/components/controls/PresetPicker.tsx +60 -0
  53. package/src/cli/serve/web/components/controls/SeedControl.tsx +38 -20
  54. package/src/cli/serve/web/components/controls/SizeControl.tsx +3 -2
  55. package/src/cli/serve/web/llm.ts +254 -0
  56. package/src/cli/serve/web/logWeb.ts +6 -0
  57. package/src/cli/serve/web/state/EnhancerSt.ts +261 -157
  58. package/src/cli/serve/web/state/FormSt.ts +70 -18
  59. package/src/cli/serve/web/state/RunSt.ts +22 -1
  60. package/src/cli/serve/web/state/WebSt.ts +542 -13
  61. package/src/cli/serve/web/state/lightbox.ts +44 -0
  62. package/src/cli/serve/web/state/moduleTree.ts +52 -0
  63. package/src/cli/serve/web/state/payload.ts +44 -2
  64. package/src/cli/serve/web/state/urlSelection.ts +53 -0
  65. package/src/cli/serve/web/styles.ts +415 -57
  66. package/src/cli/serve/web/tsconfig.json +4 -0
  67. package/src/cli/tui/components/PickerOverlays.tsx +37 -0
  68. package/src/cli/tui/components/StatusBar.tsx +14 -1
  69. package/src/cli/tui/components/TuiApp.tsx +5 -2
  70. package/src/cli/tui/state/HostSt.ts +3 -2
  71. package/src/cli/tui/state/PickerSt.ts +48 -2
  72. package/src/cli/tui/state/TreeSt.ts +1 -1
  73. package/src/cli/tui/state/TuiSt.ts +2 -1
  74. package/src/coreExports.ts +8 -1
  75. package/src/graph/ComfyNode.ts +58 -1
  76. package/src/host/ComfyHost.ts +13 -2
  77. package/src/host/ComfyManager.ts +31 -13
  78. package/src/host/loraInfoCache.ts +35 -1
  79. package/src/host/loraManagerApi.ts +94 -0
  80. package/src/index.ts +2 -0
  81. package/src/promptEnhancers.ts +102 -0
  82. package/src/runner/ComfyExecution.ts +61 -6
  83. package/src/runner/ComfyWorkflow.ts +18 -4
  84. package/src/runner/ComfyWsApi.ts +3 -0
  85. package/src/runner/describePromptRejection.ts +34 -0
  86. package/src/sdk-generator/ComfySchema.ts +17 -4
  87. package/src/sdk-generator/comfyui-sdk-codegen.ts +56 -2
  88. package/src/state.ts +6 -0
  89. package/src/utils/ansi.ts +13 -0
  90. package/src/utils/matchesRegex.ts +13 -0
  91. package/src/utils/safeName.ts +29 -0
  92. package/src/utils/stringMap.ts +9 -0
  93. package/src/vars/ComfyVars.ts +61 -10
  94. package/src/vars/presets.ts +17 -0
  95. package/dist/DefinedWorkflow-BJgt5t0x.js.map +0 -1
  96. package/dist/DraftsSt-dizp3VcC.js.map +0 -1
  97. package/dist/run-serve-CVu39RNd.js +0 -1002
  98. package/dist/run-serve-CVu39RNd.js.map +0 -1
  99. package/dist/run-tui-idFhdO4f.js.map +0 -1
  100. package/dist/state-C90kdjtB.js.map +0 -1
  101. package/src/cli/serve/web/openrouter.ts +0 -142
@@ -1,26 +1,49 @@
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
- import type { ReasoningEffort } from 'src/cli/serve/web/openrouter.ts'
6
- import type { EnhancerSt } from 'src/cli/serve/web/state/EnhancerSt.ts'
6
+ import type { ProviderId, ReasoningEffort } from 'src/cli/serve/web/llm.ts'
7
+ import { PROVIDERS, type EnhancerSt } from 'src/cli/serve/web/state/EnhancerSt.ts'
7
8
  import type { VarSt } from 'src/cli/serve/web/state/FormSt.ts'
8
9
  import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
9
10
 
10
11
  const EFFORTS: ReasoningEffort[] = ['off', 'low', 'medium', 'high']
11
12
 
13
+ const PROVIDER_LABEL: Record<ProviderId, string> = {
14
+ openrouter: 'openrouter (cloud)',
15
+ openwebui: 'open webui (local)',
16
+ }
17
+
12
18
  const Settings = observer(function Settings(p: { e: EnhancerSt }) {
13
19
  const models = p.e.visibleModels
20
+ const local = p.e.provider === 'openwebui'
14
21
  return (
15
22
  <div>
16
- <div className="section-title">openrouter · the key stays in this browser</div>
23
+ <div className="section-title">provider · keys stay in this browser</div>
17
24
  <div className="enh-row">
25
+ <select value={p.e.provider} onChange={(ev) => p.e.setProvider(ev.target.value)}>
26
+ {PROVIDERS.map((id) => (
27
+ <option key={id} value={id}>
28
+ {PROVIDER_LABEL[id]}
29
+ </option>
30
+ ))}
31
+ </select>
32
+ {local ? (
33
+ <input
34
+ type="text"
35
+ placeholder="http://localhost:3000"
36
+ value={p.e.baseUrl}
37
+ onChange={(ev) => p.e.setBaseUrl(ev.target.value)}
38
+ style={{ flex: 1, minWidth: 180 }}
39
+ />
40
+ ) : null}
18
41
  <input
19
42
  type="password"
20
- placeholder="sk-or-v1-… (localStorage only)"
43
+ placeholder={local ? 'open webui api key (blank if none)' : 'sk-or-v1-… (localStorage only)'}
21
44
  value={p.e.apiKey}
22
45
  onChange={(ev) => p.e.setApiKey(ev.target.value)}
23
- style={{ flex: 1, minWidth: 200 }}
46
+ style={{ flex: 1, minWidth: 160 }}
24
47
  />
25
48
  <button type="button" onClick={() => void p.e.loadModels()} disabled={p.e.modelsState === 'loading'}>
26
49
  {p.e.modelsState === 'loading' ? 'loading…' : 'load models'}
@@ -42,27 +65,34 @@ const Settings = observer(function Settings(p: { e: EnhancerSt }) {
42
65
  ) : (
43
66
  <input
44
67
  type="text"
45
- placeholder="model id, e.g. anthropic/claude-sonnet-5"
68
+ placeholder={local ? 'model id, e.g. qwen3:8b' : 'model id, e.g. anthropic/claude-sonnet-5'}
46
69
  value={p.e.model}
47
70
  onChange={(ev) => p.e.setModel(ev.target.value)}
48
71
  style={{ flex: 1 }}
49
72
  />
50
73
  )}
51
- <label className="row-inline" title="only models that support reasoning">
74
+ <label className="row-inline" data-tip="hide models that report no reasoning support">
52
75
  <input type="checkbox" checked={p.e.thinkingOnly} onChange={() => p.e.toggleThinkingOnly()} />
53
76
  <span className="hint">thinking only</span>
54
77
  </label>
55
- <label className="row-inline" title="reasoning effort sent to the model">
56
- <span className="hint">effort</span>
57
- <select value={p.e.effort} onChange={(ev) => p.e.setEffort(ev.target.value)}>
58
- {EFFORTS.map((x) => (
59
- <option key={x} value={x}>
60
- {x}
61
- </option>
62
- ))}
63
- </select>
64
- </label>
78
+ {local ? null : (
79
+ <label className="row-inline" data-tip="reasoning effort sent to the model">
80
+ <span className="hint">effort</span>
81
+ <select value={p.e.effort} onChange={(ev) => p.e.setEffort(ev.target.value)}>
82
+ {EFFORTS.map((x) => (
83
+ <option key={x} value={x}>
84
+ {x}
85
+ </option>
86
+ ))}
87
+ </select>
88
+ </label>
89
+ )}
65
90
  </div>
91
+ {local ? (
92
+ <div className="hint">
93
+ a local model's &lt;think&gt; block is routed to the thinking pane, never into your prompt
94
+ </div>
95
+ ) : null}
66
96
  {p.e.modelsError !== '' ? <div className="error">🔴 {p.e.modelsError}</div> : null}
67
97
  </div>
68
98
  )
@@ -70,22 +100,40 @@ const Settings = observer(function Settings(p: { e: EnhancerSt }) {
70
100
 
71
101
  const MasterPrompt = observer(function MasterPrompt(p: { e: EnhancerSt }) {
72
102
  const preset = p.e.preset
73
- if (preset == null) return null
103
+ if (preset == null) {
104
+ return (
105
+ <div>
106
+ <div className="section-title">master prompt</div>
107
+ <div className="hint">
108
+ {p.e.presetsState === 'loading' ? 'loading .comfy-ts/prompt-enhancers/…' : 'no master prompt yet'}
109
+ </div>
110
+ {p.e.presetsError !== '' ? <div className="error">🔴 {p.e.presetsError}</div> : null}
111
+ <button type="button" onClick={() => p.e.addPreset('refine-prompt')}>
112
+ create one
113
+ </button>
114
+ </div>
115
+ )
116
+ }
74
117
  const rename = (): void => {
75
- const name = window.prompt('rename this master prompt', preset.name)
76
- if (name != null) p.e.renamePreset(name)
118
+ const name = window.prompt('rename this master prompt (renames the file)', preset.name)
119
+ if (name != null) void p.e.renamePreset(name)
77
120
  }
78
121
  const create = (): void => {
79
122
  const name = window.prompt('name the new master prompt', 'refine-<model>-prompt')
80
123
  if (name != null) p.e.addPreset(name)
81
124
  }
125
+ const remove = (): void => {
126
+ if (window.confirm(`delete master prompt '${preset.name}'? the .md file is removed.`)) void p.e.deletePreset()
127
+ }
82
128
  return (
83
129
  <div>
84
- <div className="section-title">master prompt · one per image model</div>
130
+ <div className="section-title">
131
+ master prompt · one per image model · .comfy-ts/prompt-enhancers/{preset.name}.md
132
+ </div>
85
133
  <div className="enh-row">
86
- <select value={preset.id} onChange={(ev) => p.e.selectPreset(ev.target.value)} style={{ flex: 1 }}>
134
+ <select value={preset.name} onChange={(ev) => p.e.selectPreset(ev.target.value)} style={{ flex: 1 }}>
87
135
  {p.e.presets.map((m) => (
88
- <option key={m.id} value={m.id}>
136
+ <option key={m.name} value={m.name}>
89
137
  {m.name}
90
138
  </option>
91
139
  ))}
@@ -99,17 +147,14 @@ const MasterPrompt = observer(function MasterPrompt(p: { e: EnhancerSt }) {
99
147
  <button type="button" onClick={rename}>
100
148
  rename
101
149
  </button>
102
- <button type="button" onClick={() => p.e.deletePreset()} title="delete this master prompt">
103
- ✕
104
- </button>
105
- <button
106
- type="button"
107
- className="link"
108
- onClick={() => p.e.restoreDefaults()}
109
- title="re-add the shipped ones"
110
- >
111
- restore defaults
150
+ <button type="button" onClick={remove} data-tip="delete this master prompt file">
151
+ <Icon name="close" />
112
152
  </button>
153
+ <span className="hint">
154
+ {p.e.saveState === 'saving' ? 'saving…' : null}
155
+ {p.e.saveState === 'saved' ? 'autosaved to disk' : null}
156
+ {p.e.saveState === 'error' ? `🔴 save failed: ${p.e.saveError}` : null}
157
+ </span>
113
158
  </div>
114
159
  <textarea rows={8} value={preset.text} onChange={(ev) => p.e.setPresetText(ev.target.value)} />
115
160
  </div>
@@ -135,9 +180,11 @@ const Modal = observer(function Modal(p: { e: EnhancerSt }) {
135
180
  <div className="modal-overlay" onClick={() => e.close()}>
136
181
  <div className="modal" onClick={(ev) => ev.stopPropagation()}>
137
182
  <div className="modal-head">
138
- <b style={{ flex: 1 }}>✨ enhance prompt</b>
183
+ <b style={{ flex: 1 }}>
184
+ <Icon name="sparkle" /> enhance prompt
185
+ </b>
139
186
  <button type="button" onClick={() => e.close()}>
140
- ✕
187
+ <Icon name="close" />
141
188
  </button>
142
189
  </div>
143
190
  <div className="modal-body">
@@ -173,7 +220,7 @@ const Modal = observer(function Modal(p: { e: EnhancerSt }) {
173
220
  stop
174
221
  </button>
175
222
  ) : (
176
- <button type="button" className="primary" onClick={() => e.run()} title="⌘⏎ / ctrl+⏎">
223
+ <button type="button" className="primary" onClick={() => e.run()} data-tip="⌘⏎ / ctrl+⏎">
177
224
  enhance
178
225
  </button>
179
226
  )}
@@ -199,10 +246,10 @@ export const PromptEnhancer = observer(function PromptEnhancer(p: { v: VarSt; st
199
246
  <button
200
247
  type="button"
201
248
  className="link"
202
- title="rewrite this prompt with an llm"
249
+ data-tip="rewrite this prompt with an llm"
203
250
  onClick={() => e.openFor({ v: p.v, module: p.module })}
204
251
  >
205
- ✨ enhance
252
+ <Icon name="sparkle" /> enhance
206
253
  </button>
207
254
  {e.target === p.v ? <Modal e={e} /> : null}
208
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 ? (