comfy-ts 2.12.0 → 2.13.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/dist/{LogsSt-U1H0mP1m.js → LogsSt-CUeo843w.js} +18 -4
- package/dist/LogsSt-CUeo843w.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +123 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -16
- package/dist/index.d.ts +96 -16
- package/dist/index.js +123 -12
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BeAznay5.js → run-serve-DlRBv_Nk.js} +281 -19
- package/dist/run-serve-DlRBv_Nk.js.map +1 -0
- package/dist/{run-tui-BTGjvnKk.js → run-tui-B5uxm2_l.js} +4 -4
- package/dist/{run-tui-BTGjvnKk.js.map → run-tui-B5uxm2_l.js.map} +1 -1
- package/dist/{schemaDrift-Cg39vs53.js → schemaDrift-E95iTF7E.js} +4 -1
- package/dist/{schemaDrift-Cg39vs53.js.map → schemaDrift-E95iTF7E.js.map} +1 -1
- package/dist/serve-web.js +291 -129
- package/dist/{state-C7REnHan.js → state-CUp2J1Zy.js} +122 -14
- package/dist/state-CUp2J1Zy.js.map +1 -0
- package/dist/web.d.ts +96 -16
- package/dist/web.js +123 -12
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/sdk.d.ts +163 -163
- package/examples/rvion/10-anima-t2i.cflow.ts +48 -25
- package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
- package/examples/rvion/stableAudio3Prompts.ts +19 -0
- package/package.json +2 -2
- package/src/cli/serve/ServeApp.ts +157 -18
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/web/api.ts +24 -0
- package/src/cli/serve/web/components/App.tsx +305 -156
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +44 -19
- package/src/cli/serve/web/components/Icon.tsx +40 -0
- package/src/cli/serve/web/components/Omnibox.tsx +70 -20
- package/src/cli/serve/web/components/SideMenu.tsx +414 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +3 -2
- package/src/cli/serve/web/components/VarsForm.tsx +70 -351
- package/src/cli/serve/web/components/controls/LorasControl.tsx +24 -22
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +6 -3
- package/src/cli/serve/web/state/EnhancerSt.ts +17 -2
- package/src/cli/serve/web/state/FormSt.ts +22 -2
- package/src/cli/serve/web/state/OmniboxSt.ts +3 -1
- package/src/cli/serve/web/state/WebSt.ts +172 -33
- package/src/cli/serve/web/state/draftNames.ts +16 -0
- package/src/cli/serve/web/state/draftTabs.ts +75 -0
- package/src/cli/serve/web/state/generateButton.ts +1 -1
- package/src/cli/serve/web/state/omnibox.ts +82 -18
- package/src/cli/serve/web/state/shortcuts.ts +56 -7
- package/src/cli/serve/web/styles.ts +242 -82
- package/src/cli/serve/workflowTags.ts +42 -0
- package/src/cli/serve/workspaceLabels.ts +23 -0
- package/src/cli/tui/state/DraftsSt.ts +10 -6
- package/src/coreExports.ts +1 -0
- package/src/host/ComfyHost.ts +17 -2
- package/src/host/ResilientWebsocket.ts +54 -4
- package/src/runner/ComfyExecution.ts +60 -0
- package/src/runner/ComfyWorkflow.ts +4 -0
- package/src/runner/ComfyWsApi.ts +2 -0
- package/src/runner/MediaImage.ts +2 -2
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
- package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
- package/src/utils/copyName.ts +12 -0
- package/src/vars/DefinedWorkflow.ts +7 -1
- package/dist/LogsSt-U1H0mP1m.js.map +0 -1
- package/dist/run-serve-BeAznay5.js.map +0 -1
- package/dist/state-C7REnHan.js.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// search tags of a workflow, read from its built graph. PURE, tests/serve-workflow-tags.test.ts.
|
|
2
|
+
// the graph is the truth: a file named t2a that grew a video output says video
|
|
3
|
+
|
|
4
|
+
/** one node of a built graph, reduced to what tagging reads */
|
|
5
|
+
export type TagNode = {
|
|
6
|
+
id: string
|
|
7
|
+
classType: string
|
|
8
|
+
outputNode: boolean
|
|
9
|
+
/** the node's output slot types, by index */
|
|
10
|
+
outputTypes: readonly string[]
|
|
11
|
+
/** the inputs linked to another node's output: [producer id, output index] */
|
|
12
|
+
links: readonly (readonly [string, number])[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** display order: what the workflow makes first, then how it works, then free tags */
|
|
16
|
+
const MEDIA_BY_TYPE: Record<string, string> = { IMAGE: 'image', AUDIO: 'audio', VIDEO: 'video', STRING: 'text' }
|
|
17
|
+
const MEDIA_ORDER = ['image', 'audio', 'video', 'text']
|
|
18
|
+
|
|
19
|
+
export function workflowTags(p: {
|
|
20
|
+
nodes: readonly TagNode[]
|
|
21
|
+
varKinds: readonly string[]
|
|
22
|
+
extra?: readonly string[]
|
|
23
|
+
}): string[] {
|
|
24
|
+
const byId = new Map(p.nodes.map((n) => [n.id, n]))
|
|
25
|
+
const media = new Set<string>()
|
|
26
|
+
for (const node of p.nodes) {
|
|
27
|
+
if (!node.outputNode) continue
|
|
28
|
+
for (const [producerId, ix] of node.links) {
|
|
29
|
+
const type = byId.get(producerId)?.outputTypes[ix]
|
|
30
|
+
const tag = type == null ? undefined : MEDIA_BY_TYPE[type]
|
|
31
|
+
if (tag != null) media.add(tag)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const out = MEDIA_ORDER.filter((t) => media.has(t))
|
|
35
|
+
if (p.nodes.some((n) => /textgenerate/i.test(n.classType))) out.push('llm')
|
|
36
|
+
if (p.varKinds.includes('image')) out.push('edit')
|
|
37
|
+
for (const tag of p.extra ?? []) {
|
|
38
|
+
const t = tag.trim().toLowerCase()
|
|
39
|
+
if (t !== '' && !out.includes(t)) out.push(t)
|
|
40
|
+
}
|
|
41
|
+
return out
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// the menu column's two read-only cards. PURE, tests/serve-workspace-labels.test.ts.
|
|
2
|
+
// the full path is what a click copies; the label is what fits in a 220px card
|
|
3
|
+
|
|
4
|
+
export type PathLabel = { path: string; label: string }
|
|
5
|
+
|
|
6
|
+
function tilde(path: string, home: string): string {
|
|
7
|
+
if (home === '' || home === '/') return path
|
|
8
|
+
if (path === home) return '~'
|
|
9
|
+
return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function workspaceLabels(p: { workspace: string; root: string; home: string }): {
|
|
13
|
+
workspace: PathLabel
|
|
14
|
+
root: PathLabel
|
|
15
|
+
} {
|
|
16
|
+
const ws = p.workspace.replace(/\/+$/, '')
|
|
17
|
+
const root = p.root.replace(/\/+$/, '')
|
|
18
|
+
const rootLabel = root === ws ? '.' : root.startsWith(`${ws}/`) ? root.slice(ws.length + 1) : tilde(root, p.home)
|
|
19
|
+
return {
|
|
20
|
+
workspace: { path: ws, label: tilde(ws, p.home) },
|
|
21
|
+
root: { path: root, label: rootLabel },
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -12,6 +12,7 @@ import { makeAutoObservable, reaction } from 'mobx'
|
|
|
12
12
|
import { dirname, join } from 'pathe'
|
|
13
13
|
import { moduleName } from 'src/cli/tui/treeRows.ts'
|
|
14
14
|
import { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'
|
|
15
|
+
import { copyName } from 'src/utils/copyName.ts'
|
|
15
16
|
import type { TuiMode, TuiSt } from 'src/cli/tui/state/TuiSt.ts'
|
|
16
17
|
import { isDraftRecord, preserveDraftMeta } from 'src/cli/draftMeta.ts'
|
|
17
18
|
|
|
@@ -24,12 +25,15 @@ export function draftsDirForFile(file: string): string {
|
|
|
24
25
|
return comfyts.resolveFromDrafts(draftKeyForFile(file))
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function listDraftsInDir(dir: string): string[] {
|
|
28
|
+
export function listDraftsInDir(dir: string): string[] {
|
|
28
29
|
if (!existsSync(dir)) return []
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return (
|
|
31
|
+
readdirSync(dir)
|
|
32
|
+
.filter((f) => f.endsWith('.json'))
|
|
33
|
+
.map((f) => f.slice(0, -'.json'.length))
|
|
34
|
+
// numeric: copy counters read 1, 2, 11, never 1, 11, 2
|
|
35
|
+
.sort((a, b) => a.localeCompare(b, 'en', { numeric: true }))
|
|
36
|
+
)
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
/** draft names stored for a workflow module (fs read — pair with DraftsSt.version for reactivity) */
|
|
@@ -231,7 +235,7 @@ export class DraftsSt {
|
|
|
231
235
|
promptDuplicate(name: string, file?: string, returnMode: TuiMode = 'nav'): void {
|
|
232
236
|
this.st.editor.beginCustom({
|
|
233
237
|
title: `duplicate draft '${name}'`,
|
|
234
|
-
initial:
|
|
238
|
+
initial: copyName(name, listDraftsInDir(this.dirFor(file))),
|
|
235
239
|
onCommit: (raw) => {
|
|
236
240
|
const ok = this.duplicate(name, raw, file)
|
|
237
241
|
if (ok && returnMode === 'overlay-drafts') this.begin()
|
package/src/coreExports.ts
CHANGED
package/src/host/ComfyHost.ts
CHANGED
|
@@ -628,9 +628,24 @@ export class ComfyHost<ID extends string = string> {
|
|
|
628
628
|
return this.postJSON_('/queue', { clear: true })
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
-
/** interrupt the
|
|
631
|
+
/** a repeat interrupt for the same running prompt inside this window reuses the first request */
|
|
632
|
+
interruptCoalesceMs = 3000
|
|
633
|
+
private _lastInterrupt: { promptID: PromptID | null; at: number; req: Promise<void> } | null = null
|
|
634
|
+
|
|
635
|
+
/** interrupt the CURRENTLY RUNNING prompt. A burst of /interrupt posts can make the ComfyUI
|
|
636
|
+
* python process quit, so repeats for the same prompt are coalesced into one request */
|
|
632
637
|
interrupt = (): Promise<void> => {
|
|
633
|
-
|
|
638
|
+
const now = Date.now()
|
|
639
|
+
const last = this._lastInterrupt
|
|
640
|
+
if (last != null && last.promptID === this.activePromptID && now - last.at < this.interruptCoalesceMs)
|
|
641
|
+
return last.req
|
|
642
|
+
const req = this.postJSON_('/interrupt', {})
|
|
643
|
+
this._lastInterrupt = { promptID: this.activePromptID, at: now, req }
|
|
644
|
+
// a failed request must not swallow the retry
|
|
645
|
+
req.catch(() => {
|
|
646
|
+
if (this._lastInterrupt?.req === req) this._lastInterrupt = null
|
|
647
|
+
})
|
|
648
|
+
return req
|
|
634
649
|
}
|
|
635
650
|
|
|
636
651
|
// HISTORY SCRUB (architecture.md item 14) -------------------------------------------
|
|
@@ -17,6 +17,10 @@ export type WsLike = {
|
|
|
17
17
|
onerror: ((event: unknown) => void) | null
|
|
18
18
|
send(data: Message): void
|
|
19
19
|
close(): void
|
|
20
|
+
/** the `ws` package only (a browser answers pings by itself and exposes none of these) */
|
|
21
|
+
ping?(): void
|
|
22
|
+
on?(event: 'pong', cb: () => void): void
|
|
23
|
+
terminate?(): void
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
/** what both transports deliver with binaryType 'arraybuffer': string or ArrayBuffer in `data` */
|
|
@@ -25,7 +29,7 @@ export type WsCloseEvent = { code: number; reason: string }
|
|
|
25
29
|
|
|
26
30
|
type WsCtor = new (url: string, opts?: { headers?: Record<string, string> }) => WsLike
|
|
27
31
|
|
|
28
|
-
type WsTransport = { ctor: WsCtor; supportsHeaders: boolean }
|
|
32
|
+
export type WsTransport = { ctor: WsCtor; supportsHeaders: boolean }
|
|
29
33
|
|
|
30
34
|
let transportPromise: Promise<WsTransport> | null = null
|
|
31
35
|
|
|
@@ -92,6 +96,14 @@ export class ResilientWebSocketClient {
|
|
|
92
96
|
* waiter sit for the full connect deadline. No callback = retry as before.
|
|
93
97
|
*/
|
|
94
98
|
onFirstConnectFailed?: (error: unknown) => void
|
|
99
|
+
/** tests only: a fake socket instead of the ws package / browser WebSocket */
|
|
100
|
+
transport?: WsTransport
|
|
101
|
+
/** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
|
|
102
|
+
* socket would look open forever: every `heartbeatMs` it is pinged, and one without a
|
|
103
|
+
* pong since the last ping is dropped, which starts the reconnect. Default 15s */
|
|
104
|
+
heartbeatMs?: number
|
|
105
|
+
/** pause before a reconnect. Default 2s */
|
|
106
|
+
reconnectMs?: number
|
|
95
107
|
},
|
|
96
108
|
) {
|
|
97
109
|
this.url = options.url()
|
|
@@ -102,12 +114,46 @@ export class ResilientWebSocketClient {
|
|
|
102
114
|
private hasEverOpened: boolean = false
|
|
103
115
|
|
|
104
116
|
private reconnectTimeout?: Maybe<ReturnType<typeof setTimeout>>
|
|
117
|
+
private heartbeat: ReturnType<typeof setInterval> | null = null
|
|
105
118
|
private permanentlyClosed: boolean = false
|
|
106
119
|
|
|
120
|
+
private stopHeartbeat(): void {
|
|
121
|
+
if (this.heartbeat != null) clearInterval(this.heartbeat)
|
|
122
|
+
this.heartbeat = null
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** ping on a timer; no pong since the previous ping = the peer is gone, drop the socket */
|
|
126
|
+
private startHeartbeat(ws: WsLike): void {
|
|
127
|
+
this.stopHeartbeat()
|
|
128
|
+
if (typeof ws.ping !== 'function' || typeof ws.on !== 'function') return
|
|
129
|
+
let awaitingPong = false
|
|
130
|
+
ws.on('pong', () => {
|
|
131
|
+
awaitingPong = false
|
|
132
|
+
})
|
|
133
|
+
const ms = this.options.heartbeatMs ?? 15_000
|
|
134
|
+
this.heartbeat = setInterval(() => {
|
|
135
|
+
if (ws !== this.currentWS) return this.stopHeartbeat()
|
|
136
|
+
if (awaitingPong) {
|
|
137
|
+
this.addError(`no pong within ${ms}ms: the host is gone, dropping the socket to reconnect`)
|
|
138
|
+
this.stopHeartbeat()
|
|
139
|
+
if (typeof ws.terminate === 'function') ws.terminate()
|
|
140
|
+
else ws.close()
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
awaitingPong = true
|
|
144
|
+
try {
|
|
145
|
+
ws.ping?.()
|
|
146
|
+
} catch (e) {
|
|
147
|
+
this.addError(`ping failed: ${extractErrorMessage(e)}`)
|
|
148
|
+
}
|
|
149
|
+
}, ms)
|
|
150
|
+
}
|
|
151
|
+
|
|
107
152
|
/** close and stop reconnecting (lets a script exit cleanly) */
|
|
108
153
|
disconnectPermanently(): void {
|
|
109
154
|
this.permanentlyClosed = true
|
|
110
155
|
if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout)
|
|
156
|
+
this.stopHeartbeat()
|
|
111
157
|
this.currentWS?.close()
|
|
112
158
|
this.currentWS = null
|
|
113
159
|
this.isOpen = false
|
|
@@ -133,6 +179,7 @@ export class ResilientWebSocketClient {
|
|
|
133
179
|
|
|
134
180
|
// cleanup a possible re-connection timeout for an other url
|
|
135
181
|
if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout)
|
|
182
|
+
this.stopHeartbeat()
|
|
136
183
|
|
|
137
184
|
this.currentWS = null
|
|
138
185
|
if (prevWS) {
|
|
@@ -142,7 +189,7 @@ export class ResilientWebSocketClient {
|
|
|
142
189
|
|
|
143
190
|
let ws: WsLike
|
|
144
191
|
try {
|
|
145
|
-
const transport = await resolveWsTransport()
|
|
192
|
+
const transport = this.options.transport ?? (await resolveWsTransport())
|
|
146
193
|
if (this.permanentlyClosed) return // closed while the transport resolved
|
|
147
194
|
const headers = this.options.headers?.() ?? {}
|
|
148
195
|
ws = transport.supportsHeaders
|
|
@@ -171,11 +218,13 @@ export class ResilientWebSocketClient {
|
|
|
171
218
|
this.isOpen = true
|
|
172
219
|
this.options.onConnectOrReconnect()
|
|
173
220
|
this.flushMessageBuffer()
|
|
221
|
+
this.startHeartbeat(ws)
|
|
174
222
|
}
|
|
175
223
|
|
|
176
224
|
ws.onclose = (event: WsCloseEvent): void => {
|
|
177
225
|
if (ws !== this.currentWS) return
|
|
178
226
|
this.isOpen = false
|
|
227
|
+
this.stopHeartbeat()
|
|
179
228
|
this.options.onClose()
|
|
180
229
|
if (this.permanentlyClosed) return
|
|
181
230
|
this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`)
|
|
@@ -187,8 +236,9 @@ export class ResilientWebSocketClient {
|
|
|
187
236
|
)
|
|
188
237
|
return
|
|
189
238
|
}
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
239
|
+
const wait = this.options.reconnectMs ?? 2000
|
|
240
|
+
this.addInfo(`⏱️ reconnecting in ${wait / 1000} seconds...`)
|
|
241
|
+
this.reconnectTimeout = setTimeout(() => void this.connect(), wait)
|
|
192
242
|
}
|
|
193
243
|
|
|
194
244
|
ws.onerror = (event: unknown): void => {
|
|
@@ -36,6 +36,30 @@ export type ComfyExecutionData = {
|
|
|
36
36
|
status?: ComfyExecutionStatus | null
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** one audio file an output node published, downloaded as the server wrote it.
|
|
40
|
+
* `absPath` is null when saving is off: `bytes` is then the only copy */
|
|
41
|
+
export type ComfyAudioOutput = {
|
|
42
|
+
nodeId: ComfyNodeId
|
|
43
|
+
filename: string
|
|
44
|
+
mime: string
|
|
45
|
+
bytes: Uint8Array
|
|
46
|
+
absPath: AbsolutePath | null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const AUDIO_MIMES: Record<string, string> = {
|
|
50
|
+
flac: 'audio/flac',
|
|
51
|
+
mp3: 'audio/mpeg',
|
|
52
|
+
opus: 'audio/ogg',
|
|
53
|
+
ogg: 'audio/ogg',
|
|
54
|
+
wav: 'audio/wav',
|
|
55
|
+
m4a: 'audio/mp4',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function audioMime(filename: string): string {
|
|
59
|
+
const ext = filename.split('.').pop()?.toLowerCase() ?? ''
|
|
60
|
+
return AUDIO_MIMES[ext] ?? 'application/octet-stream'
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
/** one text output as an output node published it (`nodeKey` is null when the node left the snapshot) */
|
|
40
64
|
export type ComfyTextOutput = {
|
|
41
65
|
nodeId: ComfyNodeId
|
|
@@ -142,6 +166,7 @@ export class ComfyExecution {
|
|
|
142
166
|
if (!this.logProgress) return
|
|
143
167
|
const p = this.progress
|
|
144
168
|
const outputs = [`${this.images.length} image(s)`]
|
|
169
|
+
if (this.audios.length > 0) outputs.push(`${this.audios.length} audio(s)`)
|
|
145
170
|
if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`)
|
|
146
171
|
const line = `${this.status === 'Failure' ? '🔴' : '🟢'} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1000).toFixed(1)}s · ${outputs.join(' · ')}`
|
|
147
172
|
if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`)
|
|
@@ -239,9 +264,44 @@ export class ComfyExecution {
|
|
|
239
264
|
)
|
|
240
265
|
}
|
|
241
266
|
}
|
|
267
|
+
for (const audio of msg.data.output?.audio ?? []) {
|
|
268
|
+
this.pendingPromises.push(
|
|
269
|
+
this.retrieveAudio(audio, promptNodeID).catch((e: unknown) => {
|
|
270
|
+
console.error(`🔴 failed to retrieve ${audio.filename}:`, e)
|
|
271
|
+
this.audioErrors.push({ audio, error: e })
|
|
272
|
+
}),
|
|
273
|
+
)
|
|
274
|
+
}
|
|
242
275
|
}
|
|
243
276
|
private pendingPromises: Promise<void>[] = []
|
|
244
277
|
|
|
278
|
+
/** audio retrievals that failed (their files are missing from `audios`) */
|
|
279
|
+
audioErrors: { audio: ComfyImageInfo; error: unknown }[] = []
|
|
280
|
+
|
|
281
|
+
/** audio files retrieved for this execution, in arrival order (final once `done` resolves) */
|
|
282
|
+
audios: ComfyAudioOutput[] = []
|
|
283
|
+
|
|
284
|
+
private retrieveAudio = async (info: ComfyImageInfo, promptNodeID: ComfyNodeId): Promise<void> => {
|
|
285
|
+
const response = await this.host.fetchFile('/view?' + new URLSearchParams(info).toString())
|
|
286
|
+
const bytes = new Uint8Array(await response.arrayBuffer())
|
|
287
|
+
const mime = audioMime(info.filename)
|
|
288
|
+
const sf = this.save
|
|
289
|
+
if (sf == null) {
|
|
290
|
+
this.audios.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: null })
|
|
291
|
+
return
|
|
292
|
+
}
|
|
293
|
+
const promptPrefix = this.workflow.data.apiJson?.[promptNodeID]?.inputs['filename_prefix']
|
|
294
|
+
const written = await this.encodeAndWrite({
|
|
295
|
+
bytes,
|
|
296
|
+
// never re-encoded: `save.format` is an image setting
|
|
297
|
+
sf: { ...sf, format: 'raw' },
|
|
298
|
+
filenamePrefix: typeof promptPrefix === 'string' ? promptPrefix : undefined,
|
|
299
|
+
subfolder: info.subfolder,
|
|
300
|
+
filename: info.filename,
|
|
301
|
+
})
|
|
302
|
+
this.audios.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: written.path })
|
|
303
|
+
}
|
|
304
|
+
|
|
245
305
|
/** image retrievals that failed (their images are missing from `images`);
|
|
246
306
|
* `image` is null for SaveImageWebsocket frames (no server-side file info exists) */
|
|
247
307
|
imageErrors: { image: Maybe<ComfyImageInfo>; error: unknown }[] = []
|
|
@@ -96,6 +96,10 @@ export class ComfyWorkflow<ID extends string = string> {
|
|
|
96
96
|
this.outputFolder = join(comfyts.outputPath, `workflow-${this.id}`)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** a dry build: media loads name the local file by its hash and upload nothing, so a graph
|
|
100
|
+
* can be built only to be read (serve derives workflow tags this way) */
|
|
101
|
+
dry = false
|
|
102
|
+
|
|
99
103
|
/** nodes, in creation order */
|
|
100
104
|
nodes: ComfyNode[] = []
|
|
101
105
|
|
package/src/runner/ComfyWsApi.ts
CHANGED
|
@@ -64,6 +64,8 @@ const tempScope = scope({
|
|
|
64
64
|
output: {
|
|
65
65
|
'previews?': [{ filepath: 'string' }, '[]'],
|
|
66
66
|
'images?': 'ComfyImageInfo[]',
|
|
67
|
+
// SaveAudio*, PreviewAudio: same file triple as an image
|
|
68
|
+
'audio?': 'ComfyImageInfo[]',
|
|
67
69
|
// ui payload of a text output node (PreviewAny, and how TextGenerate
|
|
68
70
|
// results reach the client); entries are soft, non-strings are dropped
|
|
69
71
|
'text?': 'unknown[]',
|
package/src/runner/MediaImage.ts
CHANGED
|
@@ -118,7 +118,7 @@ export class MediaImage {
|
|
|
118
118
|
loadInWorkflow_viaLoadImageNode = async <WID extends string>(
|
|
119
119
|
workflow: ComfyWorkflow<WID>,
|
|
120
120
|
): Promise<NodeOf<WID, 'LoadImage'>> => {
|
|
121
|
-
const enumName = await this.uploadAndReturnEnumName(workflow.host)
|
|
121
|
+
const enumName = workflow.dry ? this.enumName : await this.uploadAndReturnEnumName(workflow.host)
|
|
122
122
|
const img = bang(workflow.builderBase.LoadImage, 'host has no LoadImage node')({ image: enumName })
|
|
123
123
|
// sanctioned cast: uploaded names are runtime-known; the node itself is the host's LoadImage
|
|
124
124
|
return img as NodeOf<WID, 'LoadImage'>
|
|
@@ -131,7 +131,7 @@ export class MediaImage {
|
|
|
131
131
|
/** workflow to load image as mask into */
|
|
132
132
|
workflow: ComfyWorkflow<WID>,
|
|
133
133
|
): Promise<NodeOf<WID, 'LoadImageMask'>> => {
|
|
134
|
-
const enumName = await this.uploadAndReturnEnumName(workflow.host)
|
|
134
|
+
const enumName = workflow.dry ? this.enumName : await this.uploadAndReturnEnumName(workflow.host)
|
|
135
135
|
const mask = bang(
|
|
136
136
|
workflow.builderBase.LoadImageMask,
|
|
137
137
|
'host has no LoadImageMask node',
|
|
@@ -14,16 +14,16 @@ export const ComfyUIObjectInfoScope = scope({
|
|
|
14
14
|
'hidden?': 'string[]',
|
|
15
15
|
},
|
|
16
16
|
output: 'ComfyInputType[]',
|
|
17
|
-
output_is_list: 'boolean[]',
|
|
17
|
+
output_is_list: '(boolean | null)[]',
|
|
18
18
|
output_name: 'string[]',
|
|
19
19
|
name: 'string',
|
|
20
|
-
display_name: 'string',
|
|
20
|
+
display_name: 'string | null',
|
|
21
21
|
description: 'string',
|
|
22
22
|
/** */
|
|
23
23
|
python_module: 'string',
|
|
24
24
|
category: 'string',
|
|
25
25
|
output_node: 'boolean',
|
|
26
|
-
'output_tooltips?': 'string[]',
|
|
26
|
+
'output_tooltips?': '(string | null)[]',
|
|
27
27
|
// Stability Flags
|
|
28
28
|
'deprecated?': 'boolean',
|
|
29
29
|
'experimental?': 'boolean',
|
|
@@ -47,8 +47,8 @@ export const ComfyUIObjectInfoScope = scope({
|
|
|
47
47
|
'tooltip?': 'string | null | ComfyInputOpts_advanced',
|
|
48
48
|
'multiline?': 'boolean | null',
|
|
49
49
|
|
|
50
|
-
//
|
|
51
|
-
'default?': 'boolean | number | string | null | number[]',
|
|
50
|
+
// number[] and object: widget defaults like a size pair, a curve, a trim window
|
|
51
|
+
'default?': 'boolean | number | string | null | number[] | object',
|
|
52
52
|
|
|
53
53
|
'forceInput?': 'boolean | null',
|
|
54
54
|
'min?': 'number | null',
|
|
@@ -211,7 +211,7 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
|
|
|
211
211
|
// #region Builder ----------------------------------------------------------------------------
|
|
212
212
|
p(`interface Builder {`)
|
|
213
213
|
for (const n of nodes) {
|
|
214
|
-
const baseDescription = `displayName="${n.raw.display_name}" category="${n.category}" name="${n.nameInComfy}" output=[${n.outputs.map((o) => o.outKey).join(', ')}]`
|
|
214
|
+
const baseDescription = `displayName="${n.raw.display_name ?? n.nameInComfy}" category="${n.category}" name="${n.nameInComfy}" output=[${n.outputs.map((o) => o.outKey).join(', ')}]`
|
|
215
215
|
if (n.raw.description) {
|
|
216
216
|
p(` /**`)
|
|
217
217
|
p(
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** the default name of a duplicate: a trailing number is incremented (`shot 007` → `shot 008`,
|
|
2
|
+
* zero padding kept), anything else gets `-2`. Never returns a name in `taken` */
|
|
3
|
+
export function copyName(name: string, taken: readonly string[]): string {
|
|
4
|
+
const m = /^(.*?)(\d+)$/.exec(name)
|
|
5
|
+
if (m == null) return copyName(`${name}-1`, taken)
|
|
6
|
+
const prefix = m[1] ?? ''
|
|
7
|
+
const digits = m[2] ?? ''
|
|
8
|
+
for (let n = Number(digits) + 1; ; n++) {
|
|
9
|
+
const candidate = `${prefix}${String(n).padStart(digits.length, '0')}`
|
|
10
|
+
if (!taken.includes(candidate)) return candidate
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -37,6 +37,9 @@ export type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {
|
|
|
37
37
|
* live while the vars are edited (the serve panel: a foldable block under generate). Use the
|
|
38
38
|
* function build uses, so a preview is what the run sends, never a paraphrase of it */
|
|
39
39
|
previews?: Record<string, (vars: VarValues<V>) => string>
|
|
40
|
+
/** free search tags for the serve omnibox, added to the ones read from the graph
|
|
41
|
+
* (`image`, `audio`, `video`, `text`, `llm`, `edit`) */
|
|
42
|
+
tags?: string[]
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/** type predicate (not a cast): a VarsSpec is a plain record, never callable */
|
|
@@ -121,13 +124,16 @@ export class DefinedWorkflow<ID extends string = string, V extends VarsSpec = Va
|
|
|
121
124
|
* build() for copy/export never advances). `p.host` substitutes the host
|
|
122
125
|
* the graph is built against (TUI host override): node/model availability
|
|
123
126
|
* there surfaces as workflow.problems / server validation, by design.
|
|
127
|
+
* `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.
|
|
124
128
|
*/
|
|
125
|
-
async build(p: { advance?: boolean; host?: ComfyHost<ID
|
|
129
|
+
async build(p: { advance?: boolean; host?: ComfyHost<ID>; dry?: boolean } = {}): Promise<ComfyWorkflow<ID>> {
|
|
126
130
|
const host = p.host ?? this.host
|
|
127
131
|
const wf = host.workflow({ id: this.spec.id })
|
|
132
|
+
wf.dry = p.dry === true
|
|
128
133
|
const values = varValues(this.vars)
|
|
129
134
|
if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun()
|
|
130
135
|
await this.spec.build(wf.builder, values, wf)
|
|
136
|
+
if (wf.dry) return wf
|
|
131
137
|
this.lastWorkflow = wf
|
|
132
138
|
return wf
|
|
133
139
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogsSt-U1H0mP1m.js","names":[],"sources":["../src/cli/tui/discoverWorkflows.ts","../src/cli/tui/findDefinedWorkflow.ts","../src/cli/tui/treeRows.ts","../src/cli/draftMeta.ts","../src/cli/tui/state/DraftsSt.ts","../src/utils/mojibake.ts","../src/cli/tui/state/LogsSt.ts"],"sourcesContent":["import { readdirSync } from 'node:fs'\nimport { join } from 'pathe'\n\n/**\n * recursive scan for the workflow-module naming convention. Entries BELOW a\n * node_modules segment are skipped: packaged examples arrive via\n * bundledExamplesDir (src/exampleAssets.ts — symlinked layouts like pnpm would\n * otherwise list them twice, un-deduped, as the user's own files), and\n * third-party packages shipping *.cflow.ts are not this project's workflows. A\n * scan root that is ITSELF inside node_modules still works (the filter is\n * relative to the root).\n */\nexport function scanCflowFiles(dir: string): string[] {\n const hits = readdirSync(dir, { recursive: true })\n .map((f) => String(f))\n .filter((f) => !f.split('/').includes('node_modules'))\n .map((f) => join(dir, f))\n .filter((f) => f.endsWith('.cflow.ts') || f.endsWith('.cflow.tsx'))\n return hits.sort()\n}\n\nexport type WorkflowDiscovery = {\n /** every module the tree lists, user files first, bundled examples last */\n files: string[]\n /** the subset that came from the PACKAGED examples (grouped apart in the tree) */\n bundled: Set<string>\n}\n\n/**\n * PURE merge of the scan with the packaged examples (headless-tested). An\n * explicit target keeps its scope only. Bundled files ALWAYS group under the\n * bundled section, also when the scan already found them (repo dev: ./examples\n * is under cwd) — dedupe relies on the caller passing realpath-normalized\n * strings on both sides.\n */\nexport function mergeWorkflowSources(p: {\n explicitTarget: boolean\n scanned: string[]\n bundledFiles: string[]\n}): WorkflowDiscovery {\n if (p.explicitTarget) return { files: p.scanned, bundled: new Set() }\n const bundled = new Set(p.bundledFiles)\n const userFiles = p.scanned.filter((f) => !bundled.has(f))\n return { files: [...userFiles, ...p.bundledFiles], bundled }\n}\n","import { DefinedWorkflow } from 'src/vars/DefinedWorkflow.ts'\n\n/**\n * instanceof first; duck-type fallback covers a second copy of the library in\n * the module graph (linked dev setups, npm dedupe misses)\n */\nexport function findDefinedWorkflow(mod: Record<string, unknown>): DefinedWorkflow | null {\n const isDefined = (x: unknown): x is DefinedWorkflow =>\n x instanceof DefinedWorkflow ||\n (typeof x === 'object' &&\n x != null &&\n 'spec' in x &&\n typeof (x as DefinedWorkflow).run === 'function' &&\n typeof (x as DefinedWorkflow).entries === 'function')\n return [mod.default, ...Object.values(mod)].find(isDefined) ?? null\n}\n","import { basename, dirname } from 'pathe'\n\n/**\n * PURE tree-shaping layer under TreeSt (headless-tested): turns the flat\n * discovered file list into hierarchy rows (directory nodes + files), applies\n * the `/` substring filter, and owns the per-family color assignment.\n */\n\nexport type FileTreeRow =\n | { kind: 'dir'; path: string; label: string; depth: number; expanded: boolean }\n | { kind: 'file'; file: string; name: string; depth: number }\n\n/** module display name — also the drafts folder key (DraftsSt delegates here) */\nexport function moduleName(file: string): string {\n return basename(file).replace(/\\.cflow\\.tsx?$/, '')\n}\n\n/** the color word: everything before the first `-` (`flux1-i2i` → `flux1`) */\nexport function familyOf(name: string): string {\n const dash = name.indexOf('-')\n return dash === -1 ? name : name.slice(0, dash)\n}\n\n/** hue-spread so CONSECUTIVE families land on clearly distinct colors */\nexport const FAMILY_PALETTE: string[] = [\n '#61afef', // blue\n '#e5c07b', // amber\n '#c678dd', // magenta\n '#98c379', // green\n '#e06c75', // rose\n '#56b6c2', // teal\n '#d19a66', // orange\n '#a5b4fc', // lavender\n '#a5e075', // lime\n '#f28fad', // pink\n]\n\n/** family → color, palette cycled in first-appearance order over the FULL\n * (unfiltered) file list — stable while filtering/folding */\nexport function assignFamilyColors(files: string[]): Map<string, string> {\n const colors = new Map<string, string>()\n for (const file of files) {\n const family = familyOf(moduleName(file))\n if (colors.has(family)) continue\n colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? '#61afef')\n }\n return colors\n}\n\ntype DirNode = {\n /** deepest real directory path of this node (unique row key) */\n path: string\n label: string\n files: string[]\n dirs: Map<string, DirNode>\n}\n\nfunction commonDir(files: string[]): string {\n const first = files[0]\n if (first == null) return ''\n let prefix = dirname(first).split('/')\n for (const f of files.slice(1)) {\n const segs = dirname(f).split('/')\n let i = 0\n while (i < prefix.length && i < segs.length && prefix[i] === segs[i]) i++\n prefix = prefix.slice(0, i)\n }\n return prefix.join('/')\n}\n\nfunction insert(root: DirNode, rootDir: string, file: string): void {\n const rel = dirname(file).slice(rootDir.length).replace(/^\\//, '')\n const segs = rel === '' ? [] : rel.split('/')\n let node = root\n for (const seg of segs) {\n let child = node.dirs.get(seg)\n if (child == null) {\n child = { path: `${node.path}/${seg}`, label: seg, files: [], dirs: new Map() }\n node.dirs.set(seg, child)\n }\n node = child\n }\n node.files.push(file)\n}\n\n/** a dir holding NOTHING but one subdir shows as one `a/b` row */\nfunction mergeChains(node: DirNode): void {\n // snapshot: the loop rewrites node.dirs entries while iterating\n const entries = [...node.dirs]\n for (const [key, child] of entries) {\n mergeChains(child)\n if (child.files.length === 0 && child.dirs.size === 1) {\n const only = [...child.dirs.values()][0]!\n const label = `${child.label}/${only.label}`\n node.dirs.delete(key)\n // re-key by the MERGED label: keying by only.label could clobber a\n // real sibling dir of the same name (segments never contain '/')\n node.dirs.set(label, { ...only, label })\n }\n }\n}\n\nfunction matches(file: string, rootDir: string, filter: string): boolean {\n if (filter === '') return true\n // dir path + module name, NOT the raw filename: '.cflow.ts' matching\n // everything would make the filter useless for 'ts', 'flow', '.'\n const haystack = `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase()\n return haystack.includes(filter.toLowerCase())\n}\n\nfunction emit(p: {\n node: DirNode\n depth: number\n rootDir: string\n collapsedDirs: Set<string>\n filter: string\n out: FileTreeRow[]\n}): void {\n for (const file of p.node.files) {\n if (!matches(file, p.rootDir, p.filter)) continue\n p.out.push({ kind: 'file', file, name: moduleName(file), depth: p.depth })\n }\n for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {\n const kept: FileTreeRow[] = []\n // a collapsed dir still ignores its fold while a filter narrows the tree\n const expanded = p.filter !== '' || !p.collapsedDirs.has(dir.path)\n emit({ ...p, node: dir, depth: p.depth + 1, out: kept })\n if (p.filter !== '' && kept.length === 0) continue // prune filtered-empty dirs\n p.out.push({ kind: 'dir', path: dir.path, label: dir.label, depth: p.depth, expanded })\n if (expanded) p.out.push(...kept)\n }\n}\n\n/**\n * hierarchy rows over the discovered files: user files under their common\n * root, packaged examples LAST under one foldable 'comfy-ts examples' node.\n */\nexport function buildFileRows(p: {\n userFiles: string[]\n bundledFiles: string[]\n collapsedDirs: Set<string>\n filter: string\n}): FileTreeRow[] {\n const out: FileTreeRow[] = []\n if (p.userFiles.length > 0) {\n const rootDir = commonDir(p.userFiles)\n const root: DirNode = { path: rootDir, label: '', files: [], dirs: new Map() }\n for (const f of p.userFiles) insert(root, rootDir, f)\n mergeChains(root)\n emit({ node: root, depth: 0, rootDir, collapsedDirs: p.collapsedDirs, filter: p.filter, out })\n }\n if (p.bundledFiles.length > 0) {\n const rootDir = commonDir(p.bundledFiles)\n const root: DirNode = { path: rootDir, label: 'comfy-ts examples', files: [], dirs: new Map() }\n for (const f of p.bundledFiles) insert(root, rootDir, f)\n mergeChains(root)\n const kept: FileTreeRow[] = []\n const expanded = p.filter !== '' || !p.collapsedDirs.has(rootDir)\n emit({ node: root, depth: 1, rootDir, collapsedDirs: p.collapsedDirs, filter: p.filter, out: kept })\n if (p.filter !== '' && kept.length === 0) return out\n out.push({ kind: 'dir', path: rootDir, label: root.label, depth: 0, expanded })\n if (expanded) out.push(...kept)\n }\n return out\n}\n","// what a draft file carries BESIDE its var values: keys starting with `$`, never a var name (a var\n// is an identifier). Today one: `$enhance`, the enhancer's input per prompt (per lane in lanes\n// mode), so each draft keeps its own intent next to the prompt it refines. Every reader walks\n// the workflow's vars and ignores these keys; every writer keeps them (preserveDraftMeta). PURE,\n// the browser bundle and the TUI both import it\nexport const ENHANCE_KEY = '$enhance'\n\n/** where one intent lives in `$enhance`: the var, or `var#lane` for one lane */\nexport function intentKey(varName: string, lane: number | null): string {\n return lane == null ? varName : `${varName}#${lane}`\n}\n\n/** `$enhance` as a clean string map: a hand-broken entry drops, the rest stays */\nexport function readIntents(raw: unknown): Record<string, string> {\n if (raw == null || typeof raw !== 'object' || Array.isArray(raw)) return {}\n const out: Record<string, string> = {}\n for (const [k, v] of Object.entries(raw)) if (typeof v === 'string' && v !== '') out[k] = v\n return out\n}\n\n/** a parsed draft file: a json object, never an array or a scalar */\nexport function isDraftRecord(raw: unknown): raw is Record<string, unknown> {\n return raw != null && typeof raw === 'object' && !Array.isArray(raw)\n}\n\nexport function isDraftMetaKey(key: string): boolean {\n return key === ENHANCE_KEY\n}\n\n/** a writer that knows only the var values keeps what the file already carried beside them */\nexport function preserveDraftMeta(\n previous: Record<string, unknown> | null,\n next: Record<string, unknown>,\n): Record<string, unknown> {\n if (previous == null) return next\n const out = { ...next }\n for (const [k, v] of Object.entries(previous)) if (isDraftMetaKey(k) && !(k in out)) out[k] = v\n return out\n}\n","import {\n copyFileSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs'\nimport { makeAutoObservable, reaction } from 'mobx'\nimport { dirname, join } from 'pathe'\nimport { moduleName } from 'src/cli/tui/treeRows.ts'\nimport { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'\nimport type { TuiMode, TuiSt } from 'src/cli/tui/state/TuiSt.ts'\nimport { isDraftRecord, preserveDraftMeta } from 'src/cli/draftMeta.ts'\n\n/** module basename (`01-txt2img`) keys the draft folder — knowable for EVERY tree file without importing it */\nexport function draftKeyForFile(file: string): string {\n return moduleName(file)\n}\n\nexport function draftsDirForFile(file: string): string {\n return comfyts.resolveFromDrafts(draftKeyForFile(file))\n}\n\nfunction listDraftsInDir(dir: string): string[] {\n if (!existsSync(dir)) return []\n return readdirSync(dir)\n .filter((f) => f.endsWith('.json'))\n .map((f) => f.slice(0, -'.json'.length))\n .sort()\n}\n\n/** draft names stored for a workflow module (fs read — pair with DraftsSt.version for reactivity) */\nexport function listDraftsForFile(file: string): string[] {\n return listDraftsInDir(draftsDirForFile(file))\n}\n\n/**\n * named var-value snapshots at `.comfy-ts/drafts/<module-basename>/<name>.json`\n * (LOCAL state, gitignored). The active draft autosaves debounced; the TUI is\n * ALWAYS in a draft (`default` unless another one is activated).\n */\nexport class DraftsSt {\n constructor(private st: TuiSt) {\n makeAutoObservable<DraftsSt, 'st'>(this, { st: false })\n // active-draft autosave: var values + draft name are observable\n this.st.disposers.push(\n reaction(\n () => (this.active == null ? null : JSON.stringify(this.snapshot())),\n (json) => {\n if (json != null && this.active != null) this.write(this.active, json)\n },\n { delay: this.st.timing.autosaveMs },\n ),\n )\n }\n\n /** ALWAYS set after construction; null only transiently while activate() loads values */\n active: string | null = null\n list: string[] = []\n ix: number = 0\n /** bumped on every fs write/rename so fs-derived getters (tree rows) recompute */\n version: number = 0\n\n private get dir(): string {\n const cur = this.st.workflows.currentPath\n return cur != null ? draftsDirForFile(cur) : comfyts.resolveFromDrafts(this.st.wf.spec.id ?? 'workflow')\n }\n\n private snapshot(): Record<string, unknown> {\n // toJSON so seed persists {mode, value}; other vars round-trip their value\n return Object.fromEntries(this.st.entries.map(([k, varDef]) => [k, varDef.toJSON()]))\n }\n\n // the TUI knows only the var values: what the panel stored beside them ($enhance) stays\n private write(name: string, json: string): void {\n const path = join(this.dir, `${name}.json`)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, keepDraftMeta(path, json))\n this.version++\n }\n\n /** module key of the currently loaded workflow (settings.lastDraft is keyed by it) */\n private get moduleKey(): string {\n return this.st.moduleKey\n }\n\n /** switch to a draft: load its stored values when the file exists, else it starts from current values */\n activate(name: string): void {\n this.active = null // the autosave expression must not see old values under the new name\n const path = join(this.dir, `${name}.json`)\n if (existsSync(path)) {\n try {\n const values: Record<string, unknown> = JSON.parse(readFileSync(path, 'utf8'))\n for (const [k, varDef] of this.st.entries) if (k in values) varDef.loadJSON(values[k])\n } catch (e) {\n this.st.exec.error = extractErrorMessage(e)\n }\n }\n this.active = name\n this.st.settings.rememberDraft(this.moduleKey, name)\n }\n\n /** open the draft this workflow was last in (settings), else 'default' */\n activateRemembered(): void {\n const remembered = this.st.settings.lastDraft[this.moduleKey]\n if (remembered != null && remembered !== 'default' && existsSync(join(this.dir, `${remembered}.json`)))\n this.activate(remembered)\n else this.activate('default')\n }\n\n /** every workflow starts in a draft; kept for callers that want 'default' explicitly */\n activateDefault(): void {\n this.activate('default')\n }\n\n // ---- draft CRUD (also drives the tree's draft rows — `file` overrides the target workflow) ----\n\n private dirFor(file: string | undefined): string {\n return file != null ? draftsDirForFile(file) : this.dir\n }\n\n /** true when ops on `file` touch the ACTIVE draft bookkeeping */\n private isCurrent(file: string | undefined): boolean {\n return file == null || file === this.st.workflows.currentPath\n }\n\n private validName(rawName: string): string | null {\n const name = rawName.trim()\n if (/^[\\w][\\w .-]*$/.test(name)) return name\n this.st.exec.notice = `invalid draft name: '${rawName}'`\n return null\n }\n\n /** create a NEW draft from the current var values (current workflow only) */\n createNamed(rawName: string): boolean {\n const name = this.validName(rawName)\n if (name == null) return false\n if (existsSync(join(this.dir, `${name}.json`))) {\n this.st.exec.notice = `draft '${name}' already exists`\n return false\n }\n this.write(name, JSON.stringify(this.snapshot(), null, 2))\n this.active = name\n this.st.settings.rememberDraft(this.moduleKey, name)\n this.st.exec.notice = `new draft: ${name} (autosaves)`\n return true\n }\n\n rename(oldName: string, rawName: string, file?: string): boolean {\n const newName = this.validName(rawName)\n if (newName == null) return false\n if (newName === oldName) return true\n const dir = this.dirFor(file)\n const to = join(dir, `${newName}.json`)\n if (existsSync(to)) {\n this.st.exec.notice = `draft '${newName}' already exists`\n return false\n }\n const from = join(dir, `${oldName}.json`)\n if (existsSync(from)) renameSync(from, to)\n else if (this.isCurrent(file)) this.write(newName, JSON.stringify(this.snapshot(), null, 2))\n if (this.isCurrent(file) && this.active === oldName) {\n this.active = newName\n this.st.settings.rememberDraft(this.moduleKey, newName)\n }\n this.version++\n this.st.exec.notice = `draft renamed: ${oldName} → ${newName}`\n return true\n }\n\n duplicate(name: string, rawName: string, file?: string): boolean {\n const newName = this.validName(rawName)\n if (newName == null) return false\n const dir = this.dirFor(file)\n const from = join(dir, `${name}.json`)\n const to = join(dir, `${newName}.json`)\n if (!existsSync(from)) {\n this.st.exec.notice = `draft '${name}' has no file yet (edit a var first)`\n return false\n }\n if (existsSync(to)) {\n this.st.exec.notice = `draft '${newName}' already exists`\n return false\n }\n copyFileSync(from, to)\n this.version++\n this.st.exec.notice = `draft duplicated: ${name} → ${newName}`\n return true\n }\n\n deleteDraft(name: string, file?: string): void {\n const path = join(this.dirFor(file), `${name}.json`)\n if (existsSync(path)) rmSync(path)\n this.version++\n // deleting the draft you are IN falls back to default\n if (this.isCurrent(file) && this.active === name) this.activateDefault()\n this.st.exec.notice = `draft deleted: ${name}`\n }\n\n // ---- name prompts (ONE mechanism: EditorSt custom session → PromptOverlay) ----\n\n promptNew(returnMode: TuiMode = 'nav'): void {\n this.st.editor.beginCustom({\n title: 'new draft (from current values)',\n initial: '',\n onCommit: (raw) => {\n const ok = this.createNamed(raw)\n if (ok && returnMode === 'overlay-drafts') this.begin()\n return ok\n },\n returnMode,\n })\n }\n\n promptRename(name: string, file?: string, returnMode: TuiMode = 'nav'): void {\n this.st.editor.beginCustom({\n title: `rename draft '${name}'`,\n initial: name,\n onCommit: (raw) => {\n const ok = this.rename(name, raw, file)\n if (ok && returnMode === 'overlay-drafts') this.begin()\n return ok\n },\n returnMode,\n })\n }\n\n promptDuplicate(name: string, file?: string, returnMode: TuiMode = 'nav'): void {\n this.st.editor.beginCustom({\n title: `duplicate draft '${name}'`,\n initial: `${name}-copy`,\n onCommit: (raw) => {\n const ok = this.duplicate(name, raw, file)\n if (ok && returnMode === 'overlay-drafts') this.begin()\n return ok\n },\n returnMode,\n })\n }\n\n /** f2 in nav: rename the ACTIVE draft */\n beginRename(): void {\n this.promptRename(this.active ?? 'default')\n }\n\n begin(): void {\n this.list = listDraftsInDir(this.dir)\n this.st.mode = 'overlay-drafts'\n const ix = this.active == null ? -1 : this.list.indexOf(this.active)\n // row 0 = \"new draft\", rows 1.. = existing drafts\n this.ix = ix === -1 ? 0 : ix + 1\n }\n\n move(delta: number): void {\n const len = this.list.length + 1\n this.ix = (this.ix + delta + len) % len\n }\n\n /** draft name under the overlay cursor (row 0 is 'new') */\n get selectedName(): string | null {\n return this.ix === 0 ? null : (this.list[this.ix - 1] ?? null)\n }\n\n commit(): void {\n if (this.ix === 0) return this.promptNew('overlay-drafts')\n const name = this.selectedName\n if (name == null) return\n this.activate(name)\n this.st.exec.notice = `draft: ${name} (autosaves)`\n this.st.mode = 'nav'\n }\n}\n\n/** the new json, plus the `$` keys the file on disk already carried (src/cli/draftMeta.ts) */\nfunction keepDraftMeta(path: string, json: string): string {\n if (!existsSync(path)) return json\n let previous: unknown\n try {\n previous = JSON.parse(readFileSync(path, 'utf8'))\n } catch {\n return json\n }\n const next: unknown = JSON.parse(json)\n if (!isDraftRecord(previous) || !isDraftRecord(next)) return json\n return JSON.stringify(preserveDraftMeta(previous, next), null, 2)\n}\n","// cp1252's 0x80-0x9F specials, unicode → original byte (the rest is latin1: code = byte)\nconst CP1252_REVERSE: Record<string, number> = {\n '€': 0x80,\n '‚': 0x82,\n ƒ: 0x83,\n '„': 0x84,\n '…': 0x85,\n '†': 0x86,\n '‡': 0x87,\n ˆ: 0x88,\n '‰': 0x89,\n Š: 0x8a,\n '‹': 0x8b,\n Œ: 0x8c,\n Ž: 0x8e,\n '‘': 0x91,\n '’': 0x92,\n '“': 0x93,\n '”': 0x94,\n '•': 0x95,\n '–': 0x96,\n '—': 0x97,\n '˜': 0x98,\n '™': 0x99,\n š: 0x9a,\n '›': 0x9b,\n œ: 0x9c,\n ž: 0x9e,\n Ÿ: 0x9f,\n}\n\n/**\n * repair UTF-8 that was decoded as cp1252 (a Windows server re-reading its own\n * output: `█` E2 96 88 arrives as `â–ˆ`). Reverses the cp1252 map back to\n * bytes and re-decodes as UTF-8; any unmappable char or invalid byte sequence\n * means the text was NOT mojibake — the original is returned untouched.\n */\nexport function repairMojibake(s: string): string {\n let suspicious = false\n for (let i = 0; i < s.length; i++) {\n if (s.charCodeAt(i) > 0x7f) {\n suspicious = true\n break\n }\n }\n if (!suspicious) return s\n const bytes = new Uint8Array(s.length)\n for (let i = 0; i < s.length; i++) {\n const code = s.charCodeAt(i)\n if (code <= 0xff) {\n bytes[i] = code\n continue\n }\n const mapped = CP1252_REVERSE[s[i] ?? '']\n if (mapped == null) return s\n bytes[i] = mapped\n }\n const decoded = Buffer.from(bytes).toString('utf8')\n return decoded.includes('�') ? s : decoded\n}\n","import { makeAutoObservable, runInAction } from 'mobx'\nimport { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'\nimport { stripAnsi } from 'src/utils/ansi.ts'\nimport { repairMojibake } from 'src/utils/mojibake.ts'\nimport type { LogEntry } from 'src/runner/ComfyWsApi.ts'\nimport type { ComfyHost } from 'src/host/ComfyHost.ts'\nimport type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'\n\nconst MAX_LINES = 400\n\n/** fold write chunks into p.lines (mutated), returns the new partial tail.\n * `\\n` commits a line, `\\r` resets the partial (tqdm redraws collapse to\n * their last state), ANSI stripped, blank lines dropped. */\nexport function assembleLogChunks(p: { lines: string[]; partial: string; entries: LogEntry[] }): string {\n let partial = p.partial\n for (const entry of p.entries) {\n for (const piece of stripAnsi(repairMojibake(entry.m)).split(/(\\r\\n|\\n|\\r)/)) {\n if (piece === '\\n' || piece === '\\r\\n') {\n if (partial.trim() !== '') p.lines.push(partial)\n partial = ''\n } else if (piece === '\\r') {\n partial = ''\n } else if (piece !== '') {\n partial += piece\n }\n }\n }\n return partial\n}\n\n/** server console mirror: /internal/logs/raw backfill + ws 'logs' stream.\n * Entries are write CHUNKS, not lines — assembled here (`\\n` commits,\n * `\\r` resets the partial, so tqdm redraws collapse to their last state). */\nexport class LogsSt {\n constructor(private st: TuiSt) {\n makeAutoObservable<LogsSt, 'st'>(this, { st: false })\n this.attach(this.st.wf.host)\n this.st.disposers.push(() => {\n if (this.attached != null) {\n this.attached.onLogs = null\n this.attached.onSession = null\n }\n })\n }\n\n lines: string[] = []\n /** chunk tail not yet closed by \\n — rendered live (tqdm progress) */\n partial: string = ''\n\n private attached: ComfyHost | null = null\n\n /** follow the CURRENT workflow's host (re-called on workflow switch) */\n attach(host: ComfyHost): void {\n if (this.attached === host) return\n if (this.attached != null) {\n this.attached.onLogs = null\n this.attached.onSession = null\n // best-effort: switched-away hosts stay connected (loadedHosts), so\n // without this their ws keeps carrying chunks nobody reads; the\n // server drops the sub on disconnect anyway, hence the swallowed error\n if (this.attached.isConnected && this.attached.comfySessionId !== 'temp') {\n void this.attached.subscribeLogs({ enabled: false, clientId: this.attached.comfySessionId }).catch(() => {})\n }\n }\n this.attached = host\n this.lines = []\n this.partial = ''\n host.onLogs = (p) => this.feed(p.entries)\n // per-sid server state: every (re)connect needs a fresh subscribe\n host.onSession = (sid) => void this.hydrate(host, sid)\n if (host.isConnected && host.comfySessionId !== 'temp') void this.hydrate(host, host.comfySessionId)\n }\n\n /** backfill BEFORE subscribe: entries emitted in the gap are lost, which is\n * the right trade — the reverse order would clobber streamed entries at the\n * reset, and the backfill re-covers the recent past anyway */\n private async hydrate(host: ComfyHost, sid: string): Promise<void> {\n try {\n const raw = await host.fetchRawLogs()\n // attach() switched hosts or the sid rolled again mid-fetch: stale snapshot\n if (this.attached !== host || host.comfySessionId !== sid) return\n runInAction(() => {\n this.lines = []\n this.partial = ''\n })\n this.feed(raw.entries)\n await host.subscribeLogs({ enabled: true, clientId: sid })\n } catch (e) {\n if (this.attached !== host) return\n // the panel is the loud surface: stream failures land as a log line\n this.feed([{ t: '', m: `[comfy-ts] server log stream unavailable: ${extractErrorMessage(e)}\\n` }])\n }\n }\n\n feed(entries: LogEntry[]): void {\n runInAction(() => {\n this.partial = assembleLogChunks({ lines: this.lines, partial: this.partial, entries })\n if (this.lines.length > MAX_LINES) this.lines.splice(0, this.lines.length - MAX_LINES)\n })\n }\n\n /** last rows to render, live partial included */\n tail(n: number): string[] {\n const rows = this.partial.trim() !== '' ? [...this.lines, this.partial] : this.lines\n return rows.slice(-n)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,eAAe,KAAuB;CAMnD,OALa,YAAY,KAAK,EAAE,WAAW,KAAK,CAAC,CAAC,CAC9C,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,CACrB,QAAQ,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,cAAc,CAAC,CAAC,CACrD,KAAK,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,CACxB,QAAQ,MAAM,EAAE,SAAS,WAAW,KAAK,EAAE,SAAS,YAAY,CAC1D,CAAC,CAAC,KAAK;AACpB;;;;;;;;AAgBA,SAAgB,qBAAqB,GAIf;CACnB,IAAI,EAAE,gBAAgB,OAAO;EAAE,OAAO,EAAE;EAAS,yBAAS,IAAI,IAAI;CAAE;CACpE,MAAM,UAAU,IAAI,IAAI,EAAE,YAAY;CAEtC,OAAO;EAAE,OAAO,CAAC,GADC,EAAE,QAAQ,QAAQ,MAAM,CAAC,QAAQ,IAAI,CAAC,CAC5B,GAAG,GAAG,EAAE,YAAY;EAAG;CAAQ;AAC9D;;;;;;;ACtCA,SAAgB,oBAAoB,KAAsD;CACvF,MAAM,aAAa,MAChB,aAAa,mBACZ,OAAO,MAAM,YACX,KAAK,QACL,UAAU,KACV,OAAQ,EAAsB,QAAQ,cACtC,OAAQ,EAAsB,YAAY;CAChD,OAAO,CAAC,IAAI,SAAS,GAAG,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,KAA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