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.
- package/README.md +22 -13
- package/dist/{DefinedWorkflow-BJgt5t0x.js → DefinedWorkflow-BatWaZO1.js} +199 -16
- package/dist/DefinedWorkflow-BatWaZO1.js.map +1 -0
- package/dist/{DraftsSt-dizp3VcC.js → LogsSt-DFxzQfDc.js} +152 -4
- package/dist/LogsSt-DFxzQfDc.js.map +1 -0
- package/dist/cli.js +8 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +288 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +128 -7
- package/dist/index.d.ts +128 -7
- package/dist/index.js +286 -37
- package/dist/index.js.map +1 -1
- package/dist/run-serve-_nrvJYyt.js +1948 -0
- package/dist/run-serve-_nrvJYyt.js.map +1 -0
- package/dist/{run-tui-idFhdO4f.js → run-tui-BPw-SZYW.js} +107 -158
- package/dist/run-tui-BPw-SZYW.js.map +1 -0
- package/dist/serve-web.js +434 -81
- package/dist/{state-C90kdjtB.js → state-B-boDz-Z.js} +184 -45
- package/dist/state-B-boDz-Z.js.map +1 -0
- package/dist/web.d.ts +112 -7
- package/dist/web.js +239 -36
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/comfy-cloud/sdk.d.ts +4066 -321
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +18 -2
- package/examples/rvion/07-local-llm-text-gen.cflow.ts +220 -0
- package/examples/web/tsconfig.json +7 -1
- package/extra/README.md +32 -0
- package/extra/comfyui-textgen-stream/README.md +35 -0
- package/extra/comfyui-textgen-stream/__init__.py +166 -0
- package/extra/scripts/fetch_text_encoder.py +137 -0
- package/package.json +6 -3
- package/src/cli/comfy-ts-cli.ts +4 -2
- package/src/cli/serve/ServeApp.ts +825 -43
- package/src/cli/serve/applyVarPayload.ts +10 -3
- package/src/cli/serve/describeVar.ts +47 -7
- package/src/cli/serve/managerOnlyLoras.ts +27 -0
- package/src/cli/serve/run-serve.ts +58 -29
- package/src/cli/serve/serveSettings.ts +86 -0
- package/src/cli/serve/startupPrint.ts +111 -0
- package/src/cli/serve/web/api.ts +120 -1
- package/src/cli/serve/web/components/App.tsx +61 -22
- package/src/cli/serve/web/components/Gallery.tsx +243 -30
- package/src/cli/serve/web/components/Icon.tsx +160 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +85 -38
- package/src/cli/serve/web/components/Sidebar.tsx +43 -19
- package/src/cli/serve/web/components/VarsForm.tsx +440 -80
- package/src/cli/serve/web/components/controls/BasicControls.tsx +38 -5
- package/src/cli/serve/web/components/controls/ImageControl.tsx +3 -2
- package/src/cli/serve/web/components/controls/LorasControl.tsx +498 -81
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +60 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +38 -20
- package/src/cli/serve/web/components/controls/SizeControl.tsx +3 -2
- package/src/cli/serve/web/llm.ts +254 -0
- package/src/cli/serve/web/logWeb.ts +6 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +261 -157
- package/src/cli/serve/web/state/FormSt.ts +70 -18
- package/src/cli/serve/web/state/RunSt.ts +22 -1
- package/src/cli/serve/web/state/WebSt.ts +542 -13
- package/src/cli/serve/web/state/lightbox.ts +44 -0
- package/src/cli/serve/web/state/moduleTree.ts +52 -0
- package/src/cli/serve/web/state/payload.ts +44 -2
- package/src/cli/serve/web/state/urlSelection.ts +53 -0
- package/src/cli/serve/web/styles.ts +415 -57
- package/src/cli/serve/web/tsconfig.json +4 -0
- package/src/cli/tui/components/PickerOverlays.tsx +37 -0
- package/src/cli/tui/components/StatusBar.tsx +14 -1
- package/src/cli/tui/components/TuiApp.tsx +5 -2
- package/src/cli/tui/state/HostSt.ts +3 -2
- package/src/cli/tui/state/PickerSt.ts +48 -2
- package/src/cli/tui/state/TreeSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +2 -1
- package/src/coreExports.ts +8 -1
- package/src/graph/ComfyNode.ts +58 -1
- package/src/host/ComfyHost.ts +13 -2
- package/src/host/ComfyManager.ts +31 -13
- package/src/host/loraInfoCache.ts +35 -1
- package/src/host/loraManagerApi.ts +94 -0
- package/src/index.ts +2 -0
- package/src/promptEnhancers.ts +102 -0
- package/src/runner/ComfyExecution.ts +61 -6
- package/src/runner/ComfyWorkflow.ts +18 -4
- package/src/runner/ComfyWsApi.ts +3 -0
- package/src/runner/describePromptRejection.ts +34 -0
- package/src/sdk-generator/ComfySchema.ts +17 -4
- package/src/sdk-generator/comfyui-sdk-codegen.ts +56 -2
- package/src/state.ts +6 -0
- package/src/utils/ansi.ts +13 -0
- package/src/utils/matchesRegex.ts +13 -0
- package/src/utils/safeName.ts +29 -0
- package/src/utils/stringMap.ts +9 -0
- package/src/vars/ComfyVars.ts +61 -10
- package/src/vars/presets.ts +17 -0
- package/dist/DefinedWorkflow-BJgt5t0x.js.map +0 -1
- package/dist/DraftsSt-dizp3VcC.js.map +0 -1
- package/dist/run-serve-CVu39RNd.js +0 -1002
- package/dist/run-serve-CVu39RNd.js.map +0 -1
- package/dist/run-tui-idFhdO4f.js.map +0 -1
- package/dist/state-C90kdjtB.js.map +0 -1
- package/src/cli/serve/web/openrouter.ts +0 -142
|
@@ -18,10 +18,10 @@ export class VarSt {
|
|
|
18
18
|
constructor(
|
|
19
19
|
public readonly name: string,
|
|
20
20
|
public readonly desc: VarDescriptor,
|
|
21
|
-
public
|
|
21
|
+
public initial: unknown,
|
|
22
22
|
) {
|
|
23
23
|
this.value = initial
|
|
24
|
-
makeAutoObservable(this, { value: observableRef, name: false, desc: false
|
|
24
|
+
makeAutoObservable(this, { value: observableRef, name: false, desc: false })
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
set(value: unknown): void {
|
|
@@ -29,6 +29,14 @@ export class VarSt {
|
|
|
29
29
|
this.dirty = true
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/** a value the RUN reported, not one you typed: it re-baselines, so the row is not marked
|
|
33
|
+
* changed and revert-all does not offer to undo something nobody did */
|
|
34
|
+
setFromRun(value: unknown): void {
|
|
35
|
+
this.value = value
|
|
36
|
+
this.initial = value
|
|
37
|
+
this.dirty = false
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
setUploadedUrl(url: string | null): void {
|
|
33
41
|
this.uploadedUrl = url
|
|
34
42
|
}
|
|
@@ -53,8 +61,14 @@ export class FormSt {
|
|
|
53
61
|
private disposers: IReactionDisposer[] = []
|
|
54
62
|
/** saves are chained so two PUTs can never land out of order */
|
|
55
63
|
private saveChain: Promise<boolean> = Promise.resolve(true)
|
|
56
|
-
/** the values json the server last
|
|
64
|
+
/** the values json the server last CONFIRMED — what is really on disk */
|
|
57
65
|
private lastSaved: string
|
|
66
|
+
/** the values json last HANDED to the chain, confirmed or still in flight. save() no-ops
|
|
67
|
+
* against this one, never against lastSaved: while a PUT is open the disk does not hold
|
|
68
|
+
* lastSaved any more, so editing back to it wrote nothing and the in-flight value won */
|
|
69
|
+
private lastQueued: string
|
|
70
|
+
/** identity of the newest queued write, so a rollback cannot claim someone else's */
|
|
71
|
+
private queueSeq = 0
|
|
58
72
|
|
|
59
73
|
constructor(
|
|
60
74
|
public readonly moduleKey: string,
|
|
@@ -68,9 +82,10 @@ export class FormSt {
|
|
|
68
82
|
)
|
|
69
83
|
// seeded from the RAW reply, not the normalized values: when normalizeInitial heals
|
|
70
84
|
// something (a stale lora key), the form is already out of sync with the file and the
|
|
71
|
-
// next save() must actually send
|
|
85
|
+
// next save() must actually send, otherwise the server keeps building the stale record
|
|
72
86
|
this.lastSaved = JSON.stringify(Object.fromEntries(this.vars.map((v) => [v.name, values[v.name]])))
|
|
73
|
-
|
|
87
|
+
this.lastQueued = this.lastSaved
|
|
88
|
+
makeAutoObservable<FormSt, 'disposers' | 'saveChain' | 'lastSaved' | 'lastQueued' | 'queueSeq'>(this, {
|
|
74
89
|
vars: false,
|
|
75
90
|
moduleKey: false,
|
|
76
91
|
draft: false,
|
|
@@ -78,6 +93,8 @@ export class FormSt {
|
|
|
78
93
|
disposers: false,
|
|
79
94
|
saveChain: false,
|
|
80
95
|
lastSaved: false,
|
|
96
|
+
lastQueued: false,
|
|
97
|
+
queueSeq: false,
|
|
81
98
|
})
|
|
82
99
|
// the persistence idiom: the values json is change-detector AND payload
|
|
83
100
|
this.disposers.push(
|
|
@@ -89,11 +106,16 @@ export class FormSt {
|
|
|
89
106
|
)
|
|
90
107
|
}
|
|
91
108
|
|
|
92
|
-
|
|
109
|
+
/** stop the autosave. `flush: false` is the DELETE path: flushing there would write the
|
|
110
|
+
* draft file back milliseconds after the server removed it */
|
|
111
|
+
dispose(p: { flush?: boolean } = {}): void {
|
|
93
112
|
for (const d of this.disposers) d()
|
|
94
113
|
this.disposers = []
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
if (p.flush === false) return
|
|
115
|
+
// a draft switch inside the debounce window must not lose the edit. Compared against
|
|
116
|
+
// lastQueued, like save() itself: lastSaved lags behind an in-flight write, so a revert
|
|
117
|
+
// made while one is open looked identical to "already written" and was dropped
|
|
118
|
+
if (JSON.stringify(this.valuesJSON()) !== this.lastQueued) void this.save()
|
|
97
119
|
}
|
|
98
120
|
|
|
99
121
|
/** tab-close/hide flush. keepalive survives page teardown, so this one does NOT ride
|
|
@@ -101,7 +123,10 @@ export class FormSt {
|
|
|
101
123
|
* server answers: a failed flush must stay dirty so the next save() retries it */
|
|
102
124
|
flushKeepalive(): void {
|
|
103
125
|
const encoded = JSON.stringify(this.valuesJSON())
|
|
104
|
-
|
|
126
|
+
// lastQueued, not lastSaved: nothing runs after this one, so a revert made while a PUT
|
|
127
|
+
// was open would be lost for good rather than merely delayed
|
|
128
|
+
if (encoded === this.lastQueued) return
|
|
129
|
+
this.lastQueued = encoded
|
|
105
130
|
void saveDraft(
|
|
106
131
|
{ module: this.moduleKey, draft: this.draft, values: JSON.parse(encoded) as Record<string, unknown> },
|
|
107
132
|
{ keepalive: true },
|
|
@@ -109,10 +134,12 @@ export class FormSt {
|
|
|
109
134
|
() =>
|
|
110
135
|
runInAction(() => {
|
|
111
136
|
this.lastSaved = encoded
|
|
137
|
+
this.lastQueued = encoded
|
|
112
138
|
this.saveState = 'saved'
|
|
113
139
|
}),
|
|
114
140
|
(e: unknown) =>
|
|
115
141
|
runInAction(() => {
|
|
142
|
+
if (this.lastQueued === encoded) this.lastQueued = this.lastSaved
|
|
116
143
|
this.saveState = 'error'
|
|
117
144
|
this.saveError = e instanceof Error ? e.message : String(e)
|
|
118
145
|
}),
|
|
@@ -128,6 +155,32 @@ export class FormSt {
|
|
|
128
155
|
return payloadSnapshot(this.vars.map((v) => ({ name: v.name, kind: v.desc.kind, value: v.value })))
|
|
129
156
|
}
|
|
130
157
|
|
|
158
|
+
/** the keywords the ACTIVE loras will prepend to this prompt, in the ORDER THE RUN USES.
|
|
159
|
+
* that order is the var's option list (LorasVar.activeNames filters `names`), NOT the
|
|
160
|
+
* record's insertion order: walking the record showed the keywords in drag order while the
|
|
161
|
+
* prompt that ran used the enum order, so the preview and the run disagreed the moment you
|
|
162
|
+
* reordered a card. Computed here rather than fetched: it must follow every toggle live */
|
|
163
|
+
loraKeywordsFor(promptVar: VarSt): string[] {
|
|
164
|
+
const sourceName = promptVar.desc.keywordsFrom
|
|
165
|
+
if (sourceName == null) return []
|
|
166
|
+
const source = this.vars.find((v) => v.name === sourceName)
|
|
167
|
+
if (source == null) return []
|
|
168
|
+
const keywords = source.desc.optionKeywords ?? {}
|
|
169
|
+
const record = (source.value != null && typeof source.value === 'object' ? source.value : {}) as Record<
|
|
170
|
+
string,
|
|
171
|
+
unknown
|
|
172
|
+
>
|
|
173
|
+
const out: string[] = []
|
|
174
|
+
for (const name of source.desc.options ?? []) {
|
|
175
|
+
const st = record[name]
|
|
176
|
+
// same rule as the graph: only loras that are ON contribute
|
|
177
|
+
if (st == null || st === false) continue
|
|
178
|
+
const kw = keywords[name]
|
|
179
|
+
if (kw != null && kw !== '' && !out.includes(kw)) out.push(kw)
|
|
180
|
+
}
|
|
181
|
+
return out
|
|
182
|
+
}
|
|
183
|
+
|
|
131
184
|
get dirtyCount(): number {
|
|
132
185
|
return this.vars.filter((v) => v.dirty).length
|
|
133
186
|
}
|
|
@@ -135,15 +188,10 @@ export class FormSt {
|
|
|
135
188
|
/** persist the draft now. Resolves FALSE on failure — generate() must not run stale inputs */
|
|
136
189
|
save(): Promise<boolean> {
|
|
137
190
|
const encoded = JSON.stringify(this.valuesJSON())
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.saveState = 'saved'
|
|
143
|
-
this.saveError = null
|
|
144
|
-
})
|
|
145
|
-
return Promise.resolve(true)
|
|
146
|
-
}
|
|
191
|
+
// already on its way (or landed): ride the chain, so generate() waits for that write
|
|
192
|
+
if (encoded === this.lastQueued) return this.lastSaved === encoded ? Promise.resolve(true) : this.saveChain
|
|
193
|
+
this.lastQueued = encoded
|
|
194
|
+
const seq = ++this.queueSeq
|
|
147
195
|
runInAction(() => {
|
|
148
196
|
this.saveState = 'saving'
|
|
149
197
|
})
|
|
@@ -162,6 +210,10 @@ export class FormSt {
|
|
|
162
210
|
return true
|
|
163
211
|
} catch (e) {
|
|
164
212
|
runInAction(() => {
|
|
213
|
+
// by seq, not by value: a newer save carrying the same json must keep its marker
|
|
214
|
+
if (this.queueSeq === seq) this.lastQueued = this.lastSaved
|
|
215
|
+
// a failed chain must not be handed to the next no-op caller as a stale false
|
|
216
|
+
this.saveChain = Promise.resolve(true)
|
|
165
217
|
this.saveState = 'error'
|
|
166
218
|
this.saveError = e instanceof Error ? e.message : String(e)
|
|
167
219
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// the run QUEUE + results. Clicking generate repeatedly enqueues; the drainer
|
|
2
2
|
// sends ONE prompt at a time so anything still pending can be dropped before it
|
|
3
|
-
// ever reaches the host
|
|
3
|
+
// ever reaches the host: queued prompts must be clearable, singly or
|
|
4
4
|
// all). Progress + latent preview are polled ~700ms while a prompt is in flight
|
|
5
5
|
import { makeAutoObservable, observableShallow, runInAction } from 'mobx'
|
|
6
6
|
import { fetchRunStatus, postGenerate, type GenerateOk } from 'src/cli/serve/web/api.ts'
|
|
@@ -25,6 +25,12 @@ export class RunSt {
|
|
|
25
25
|
error: string | null = null
|
|
26
26
|
results: RunResult[] = []
|
|
27
27
|
progressPercent: number | null = null
|
|
28
|
+
/** what the host is doing right now, in the node's own unit — `TextGenerate 427/1024`.
|
|
29
|
+
* A text graph has no latent preview and no image, so this is all there is to watch */
|
|
30
|
+
progressNode: string | null = null
|
|
31
|
+
progressCount: { value: number; max: number } | null = null
|
|
32
|
+
/** what a streaming node has produced SO FAR — replacement semantics, newest wins */
|
|
33
|
+
progressText: string | null = null
|
|
28
34
|
hasPreview = false
|
|
29
35
|
/** the server's frame seq — the <img> cache-buster, changes only on a NEW frame */
|
|
30
36
|
previewTick = 0
|
|
@@ -33,6 +39,10 @@ export class RunSt {
|
|
|
33
39
|
/** staleness guard for the poll loop (mobx-mechanics: counters, not flags) */
|
|
34
40
|
private pollGen = 0
|
|
35
41
|
|
|
42
|
+
/** what a finished run's seeds should do to the form. Set by WebSt: RunSt owns the queue,
|
|
43
|
+
* not the draft */
|
|
44
|
+
onSeeds: ((p: { module: string; draft: string; seeds: Record<string, number> }) => void) | null = null
|
|
45
|
+
|
|
36
46
|
constructor() {
|
|
37
47
|
makeAutoObservable(this, { queue: observableShallow, results: observableShallow })
|
|
38
48
|
}
|
|
@@ -85,6 +95,9 @@ export class RunSt {
|
|
|
85
95
|
// replace-by-copy keeps the one array idiom of this store
|
|
86
96
|
this.queue = this.queue.map((e) => (e.id === next.id ? { ...e, sent: true } : e))
|
|
87
97
|
this.progressPercent = null
|
|
98
|
+
this.progressNode = null
|
|
99
|
+
this.progressCount = null
|
|
100
|
+
this.progressText = null
|
|
88
101
|
this.hasPreview = false
|
|
89
102
|
})
|
|
90
103
|
const gen = ++this.pollGen
|
|
@@ -95,6 +108,8 @@ export class RunSt {
|
|
|
95
108
|
// capped: full-size <img>s per run would eat the tab
|
|
96
109
|
this.results = [{ ...result, at: new Date().toLocaleTimeString() }, ...this.results].slice(0, 20)
|
|
97
110
|
})
|
|
111
|
+
// named, because the panel may be on another draft by the time this resolves
|
|
112
|
+
this.onSeeds?.({ module: next.module, draft: next.draft, seeds: result.seeds })
|
|
98
113
|
} catch (e) {
|
|
99
114
|
runInAction(() => {
|
|
100
115
|
this.error = e instanceof Error ? e.message : String(e)
|
|
@@ -107,6 +122,9 @@ export class RunSt {
|
|
|
107
122
|
runInAction(() => {
|
|
108
123
|
this.queue = this.queue.filter((e) => e.id !== next.id)
|
|
109
124
|
this.progressPercent = null
|
|
125
|
+
this.progressNode = null
|
|
126
|
+
this.progressCount = null
|
|
127
|
+
this.progressText = null
|
|
110
128
|
this.hasPreview = false
|
|
111
129
|
})
|
|
112
130
|
}
|
|
@@ -125,6 +143,9 @@ export class RunSt {
|
|
|
125
143
|
runInAction(() => {
|
|
126
144
|
if (gen !== this.pollGen) return
|
|
127
145
|
this.progressPercent = status.percent
|
|
146
|
+
this.progressNode = status.node ?? null
|
|
147
|
+
this.progressCount = status.nodeProgress ?? null
|
|
148
|
+
this.progressText = status.progressText ?? null
|
|
128
149
|
this.hasPreview = status.hasPreview
|
|
129
150
|
this.previewTick = status.previewSeq ?? 0
|
|
130
151
|
})
|