comfy-ts 2.11.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/README.md +1 -0
- package/dist/{LogsSt-qtFzOKpu.js → LogsSt-CUeo843w.js} +51 -7
- package/dist/LogsSt-CUeo843w.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +595 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +286 -46
- package/dist/index.d.ts +286 -46
- package/dist/index.js +591 -74
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BK7BA2dn.js → run-serve-DlRBv_Nk.js} +738 -58
- package/dist/run-serve-DlRBv_Nk.js.map +1 -0
- package/dist/{run-tui-CQyvMf0N.js → run-tui-B5uxm2_l.js} +43 -18
- package/dist/run-tui-B5uxm2_l.js.map +1 -0
- package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-E95iTF7E.js} +473 -60
- package/dist/schemaDrift-E95iTF7E.js.map +1 -0
- package/dist/serve-web.js +710 -174
- package/dist/{state--wrz0BQc.js → state-CUp2J1Zy.js} +126 -14
- package/dist/state-CUp2J1Zy.js.map +1 -0
- package/dist/web.d.ts +286 -46
- package/dist/web.js +591 -74
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/sdk.d.ts +163 -163
- package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
- package/examples/rvion/10-anima-t2i.cflow.ts +252 -0
- 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/extra/README.md +4 -0
- package/extra/comfyui-fresh-model-lists/README.md +25 -0
- package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
- package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
- package/package.json +15 -7
- package/src/cli/draftMeta.ts +39 -0
- package/src/cli/serve/ServeApp.ts +305 -30
- package/src/cli/serve/applyVarPayload.ts +50 -22
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/describeVar.ts +42 -6
- package/src/cli/serve/llmConfigShape.ts +51 -0
- package/src/cli/serve/llmConfigs.ts +52 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/tagList.ts +92 -0
- package/src/cli/serve/tagSource.ts +69 -0
- package/src/cli/serve/web/api.ts +72 -0
- package/src/cli/serve/web/components/App.tsx +485 -44
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +133 -31
- package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
- package/src/cli/serve/web/components/Icon.tsx +58 -2
- package/src/cli/serve/web/components/MenuButton.tsx +53 -0
- package/src/cli/serve/web/components/Omnibox.tsx +135 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
- package/src/cli/serve/web/components/SideMenu.tsx +414 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +46 -0
- package/src/cli/serve/web/components/VarIcon.tsx +24 -0
- package/src/cli/serve/web/components/VarsForm.tsx +223 -351
- package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
- package/src/cli/serve/web/components/controls/LorasControl.tsx +646 -317
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
- package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
- package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
- package/src/cli/serve/web/components/modKey.ts +2 -0
- package/src/cli/serve/web/llm.ts +23 -12
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +284 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +431 -101
- package/src/cli/serve/web/state/FormSt.ts +214 -30
- package/src/cli/serve/web/state/OmniboxSt.ts +59 -0
- package/src/cli/serve/web/state/WebSt.ts +364 -80
- package/src/cli/serve/web/state/choiceButtons.ts +61 -0
- 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 +16 -0
- package/src/cli/serve/web/state/history.ts +54 -0
- package/src/cli/serve/web/state/host.ts +5 -2
- package/src/cli/serve/web/state/keptLines.ts +53 -0
- package/src/cli/serve/web/state/latentMode.ts +20 -0
- package/src/cli/serve/web/state/loraSort.ts +18 -0
- package/src/cli/serve/web/state/moduleTree.ts +2 -2
- package/src/cli/serve/web/state/omnibox.ts +133 -0
- package/src/cli/serve/web/state/payload.ts +38 -58
- package/src/cli/serve/web/state/shortcuts.ts +103 -0
- package/src/cli/serve/web/state/sizeStars.ts +31 -0
- package/src/cli/serve/web/state/stableSlots.ts +21 -0
- package/src/cli/serve/web/state/varGroups.ts +24 -0
- package/src/cli/serve/web/styles.ts +653 -154
- package/src/cli/serve/webBundle.ts +54 -10
- package/src/cli/serve/workflowTags.ts +42 -0
- package/src/cli/serve/workspaceLabels.ts +23 -0
- package/src/cli/tui/components/PickerOverlays.tsx +9 -2
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
- package/src/cli/tui/state/DraftsSt.ts +28 -8
- package/src/cli/tui/state/EditorSt.ts +1 -1
- package/src/cli/tui/state/LorasSt.ts +1 -1
- package/src/cli/tui/state/PickerSt.ts +25 -7
- package/src/cli/tui/state/SettingsSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +10 -0
- package/src/coreExports.ts +21 -0
- package/src/host/ComfyHost.ts +17 -2
- package/src/host/ResilientWebsocket.ts +54 -4
- package/src/host/loraInfoCache.ts +6 -0
- 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/state.ts +5 -0
- package/src/utils/copyName.ts +12 -0
- package/src/vars/ComfyVars.ts +337 -67
- package/src/vars/DefinedWorkflow.ts +47 -20
- package/src/vars/lanes.ts +238 -0
- package/src/vars/loraEntry.ts +101 -0
- package/src/vars/promptSyntax.ts +382 -0
- package/dist/LogsSt-qtFzOKpu.js.map +0 -1
- package/dist/run-serve-BK7BA2dn.js.map +0 -1
- package/dist/run-tui-CQyvMf0N.js.map +0 -1
- package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
- package/dist/state--wrz0BQc.js.map +0 -1
- package/src/cli/serve/web/components/Sidebar.tsx +0 -66
|
@@ -18,11 +18,18 @@ import { basename, dirname, extname, join, resolve } from 'pathe'
|
|
|
18
18
|
import { applyVarPayload } from 'src/cli/serve/applyVarPayload.ts'
|
|
19
19
|
import { describeVar, type VarDescriptor } from 'src/cli/serve/describeVar.ts'
|
|
20
20
|
import { deletePromptEnhancer, listPromptEnhancers, writePromptEnhancer } from 'src/promptEnhancers.ts'
|
|
21
|
+
import { deleteLlmConfig, listLlmConfigs, writeLlmConfig } from 'src/cli/serve/llmConfigs.ts'
|
|
22
|
+
import { normalizeLlmConfig } from 'src/cli/serve/llmConfigShape.ts'
|
|
23
|
+
import { ENHANCE_KEY, isDraftMetaKey } from 'src/cli/draftMeta.ts'
|
|
21
24
|
import { managerOnlyLoraOptions } from 'src/cli/serve/managerOnlyLoras.ts'
|
|
25
|
+
import { resolveTagSource, TagSources } from 'src/cli/serve/tagSource.ts'
|
|
22
26
|
import { FAVICON_DATA_URI } from 'src/cli/serve/favicon.ts'
|
|
27
|
+
import { type TagNode, workflowTags } from 'src/cli/serve/workflowTags.ts'
|
|
28
|
+
import { workspaceLabels } from 'src/cli/serve/workspaceLabels.ts'
|
|
23
29
|
import { driftChanged, summarizeDrift } from 'src/host/schemaDrift.ts'
|
|
24
30
|
import { validSavePrefix, validStoreName } from 'src/utils/safeName.ts'
|
|
25
31
|
import { readServeSettings, writeServeSettings, type ServeSettings } from 'src/cli/serve/serveSettings.ts'
|
|
32
|
+
import { readTabs, SERVE_TABS_FILE, type DraftTab } from 'src/cli/serve/web/state/draftTabs.ts'
|
|
26
33
|
import { assembleLogChunks } from 'src/cli/tui/state/LogsSt.ts'
|
|
27
34
|
import { draftsDirForFile, listDraftsForFile } from 'src/cli/tui/state/DraftsSt.ts'
|
|
28
35
|
import {
|
|
@@ -33,6 +40,7 @@ import {
|
|
|
33
40
|
recordCivitaiMiss,
|
|
34
41
|
getLoraDisplayName,
|
|
35
42
|
getLoraInfo,
|
|
43
|
+
lorasMissingFromMirror,
|
|
36
44
|
getLoraPreviewUrl,
|
|
37
45
|
getLoraTriggerWords,
|
|
38
46
|
refreshLoraInfoCacheIfChanged,
|
|
@@ -77,6 +85,8 @@ export type ServeExecution = {
|
|
|
77
85
|
/** STRING outputs (PreviewAny, i.e. every llm graph). A text-only workflow has no images at
|
|
78
86
|
* all, so without these its run reply is empty and the panel shows nothing */
|
|
79
87
|
texts?: { nodeId: string; nodeKey: string | null; text: string }[]
|
|
88
|
+
/** audio files (SaveAudio*, PreviewAudio). absPath null = saving off, bytes the only copy */
|
|
89
|
+
audios?: { absPath: string | null; filename: string; mime: string; bytes: Uint8Array }[]
|
|
80
90
|
data: { id: string; error?: unknown }
|
|
81
91
|
/** live global progress (ComfyExecution has it; fakes may omit) — the /run/<module> poll reads it */
|
|
82
92
|
progressGlobal?: { percent: number }
|
|
@@ -160,6 +170,9 @@ class DownloadRefused extends Error {
|
|
|
160
170
|
|
|
161
171
|
const INPUT_DOWNLOAD_CAP = 50_000_000
|
|
162
172
|
const INPUT_DOWNLOAD_TIMEOUT_MS = 60_000
|
|
173
|
+
/** the danbooru list is ~3.5 MB; ten times that is still a tag list, beyond is a wrong url */
|
|
174
|
+
const TAG_LIST_CAP = 40_000_000
|
|
175
|
+
const TAG_LIST_TIMEOUT_MS = 120_000
|
|
163
176
|
|
|
164
177
|
/** read a reply STREAMING, aborting the moment it passes the cap. `arrayBuffer()` buffers the
|
|
165
178
|
* whole body first, so a chunked reply with no content-length could exhaust the process before
|
|
@@ -220,6 +233,12 @@ const CONTENT_TYPES: Record<string, string> = {
|
|
|
220
233
|
'.gif': 'image/gif',
|
|
221
234
|
'.mp4': 'video/mp4',
|
|
222
235
|
'.webm': 'video/webm',
|
|
236
|
+
'.flac': 'audio/flac',
|
|
237
|
+
'.mp3': 'audio/mpeg',
|
|
238
|
+
'.opus': 'audio/ogg',
|
|
239
|
+
'.ogg': 'audio/ogg',
|
|
240
|
+
'.wav': 'audio/wav',
|
|
241
|
+
'.m4a': 'audio/mp4',
|
|
223
242
|
'.json': 'application/json',
|
|
224
243
|
'.txt': 'text/plain',
|
|
225
244
|
}
|
|
@@ -257,10 +276,12 @@ const USAGE = [
|
|
|
257
276
|
'GET /drafts/<module>/<draft> — one draft with its stored values',
|
|
258
277
|
'POST /generate/<module>/<draft> with { ...vars } — run, blocking',
|
|
259
278
|
'POST /generate/<draft> — unqualified, when unambiguous',
|
|
279
|
+
'POST /preview/<module> with { ...draft values } — the workflow previews for those values, nothing is run',
|
|
260
280
|
'PUT /drafts/<module>/<draft> with { ...vars } — save (or duplicate to a new name) a draft',
|
|
261
281
|
'DELETE /drafts/<module>/<draft> — delete that draft file',
|
|
262
282
|
'GET /run/<module> — live run status · /run/<module>/preview — latent preview bytes',
|
|
263
283
|
'POST /upload with {"name","dataBase64"} — store a browser file for an image var',
|
|
284
|
+
'GET /tags/<module>/<var>?q=<text>&limit=<n> — tag completion from the list a prompt var declares (`tags`)',
|
|
264
285
|
'GET /hosts/<hostId>/drift[?full=1] — what changed on the host since the schema was loaded (model files; node types with full=1)',
|
|
265
286
|
'GET /lora-info/<hostId>/<lora> — display name + trigger words (local mirror)',
|
|
266
287
|
'POST /hosts/<hostId>/lora-civitai/<lora> — fetch its civitai metadata (trigger words) through the lora manager, then re-sync the mirror',
|
|
@@ -268,12 +289,15 @@ const USAGE = [
|
|
|
268
289
|
'GET /lora-about/<hostId>/<lora> — civitai description + example images (live from the extension)',
|
|
269
290
|
'GET /prompt-enhancers — the web ui master prompts (.comfy-ts/prompt-enhancers/*.md)',
|
|
270
291
|
'PUT /prompt-enhancers/<name> with {"text"} — write one · DELETE /prompt-enhancers/<name> — remove it',
|
|
292
|
+
'GET /llm-configs — the enhancer LLM configs (.comfy-ts/llm-configs/*.json)',
|
|
293
|
+
'PUT /llm-configs/<name> with {provider, baseUrl, model, effort, thinkingOnly} · DELETE /llm-configs/<name>',
|
|
271
294
|
'GET /settings — { saveToDisk } · PUT /settings with {"saveToDisk"} — write outputs to disk, or keep them in memory',
|
|
272
295
|
'GET /hosts — every host this process knows · PUT /hosts/<module> with {"host"} — run that workflow elsewhere',
|
|
273
296
|
'POST /hosts/<hostId>/<interrupt|clear-queue|restart|refresh-loras|refresh-schema> — act on a ComfyUI host',
|
|
274
297
|
'GET /hosts/<hostId>/ping — is that host answering right now (restart watch)',
|
|
275
298
|
'GET /hosts/<hostId>/logs — the last lines of that host console',
|
|
276
299
|
'GET /images/<promptId>/<ix> — an in-memory output (saving off), while the process lives',
|
|
300
|
+
'GET /audio/<promptId>/<ix> — the same for an in-memory audio output',
|
|
277
301
|
'GET /outputs/<path> — generated files',
|
|
278
302
|
]
|
|
279
303
|
|
|
@@ -306,14 +330,12 @@ const WEB_SHELL = `<!doctype html>
|
|
|
306
330
|
export class ServeApp {
|
|
307
331
|
private starter: ServeStarter
|
|
308
332
|
/** last SERVED seed per `module/draft/var` — '+'/'-' modes continue from it.
|
|
309
|
-
* draftBase remembers which DRAFT value the continuation grew from
|
|
310
|
-
*
|
|
311
|
-
* value wins and the
|
|
312
|
-
private seedState = new Map<string, { last: number; draftBase: number }>()
|
|
333
|
+
* draftBase remembers which DRAFT value the continuation grew from, served every seed
|
|
334
|
+
* the chain handed out: a draft holding one of them is the panel's write-back (it lags a
|
|
335
|
+
* queued run), anything else is a typed value, which wins and restarts the chain there */
|
|
336
|
+
private seedState = new Map<string, { last: number; draftBase: number; served: number[] }>()
|
|
313
337
|
/** per-module promise chain: vars are shared mutable state, apply→send is exclusive */
|
|
314
338
|
private chains = new Map<string, Promise<unknown>>()
|
|
315
|
-
/** the bundle is built at most once per process, first browser hit pays it */
|
|
316
|
-
private webJsCache: Promise<string | null> | null = null
|
|
317
339
|
/** saving + host overrides are live settings (the web ui flips them). LAZY: a ServeApp can
|
|
318
340
|
* be constructed before a comfyts instance is registered, and reading the file then would
|
|
319
341
|
* throw at construction time */
|
|
@@ -335,7 +357,12 @@ export class ServeApp {
|
|
|
335
357
|
starter?: ServeStarter
|
|
336
358
|
outputRoot?: string
|
|
337
359
|
loadErrors?: Record<string, string>
|
|
338
|
-
/**
|
|
360
|
+
/** where `.comfy-ts/` lives and the folder serve scanned: the menu's read-only cards.
|
|
361
|
+
* absent = the index leaves both out */
|
|
362
|
+
workspace?: string
|
|
363
|
+
root?: string
|
|
364
|
+
/** web ui bundle provider (run-serve wires loadOrBuildWebJs), called on every page load
|
|
365
|
+
* and owning its own cache; absent = api only */
|
|
339
366
|
webJs?: () => Promise<string | null>
|
|
340
367
|
} = {},
|
|
341
368
|
) {
|
|
@@ -364,8 +391,7 @@ export class ServeApp {
|
|
|
364
391
|
// the bundle resolves BEFORE the shell ships: a shell whose /web/app.js 404s is
|
|
365
392
|
// a blank dark page, the json index is a usable answer
|
|
366
393
|
if (segs.length === 0 && this.opts.webJs != null && req.accept?.includes('text/html') === true) {
|
|
367
|
-
|
|
368
|
-
const js = await this.webJsCache
|
|
394
|
+
const js = await this.opts.webJs()
|
|
369
395
|
if (js != null)
|
|
370
396
|
return {
|
|
371
397
|
status: 200,
|
|
@@ -374,7 +400,7 @@ export class ServeApp {
|
|
|
374
400
|
headers: NO_STORE,
|
|
375
401
|
}
|
|
376
402
|
}
|
|
377
|
-
if (segs.length === 0 || (segs[0] === 'drafts' && segs.length === 1)) return this.replyIndex()
|
|
403
|
+
if (segs.length === 0 || (segs[0] === 'drafts' && segs.length === 1)) return await this.replyIndex()
|
|
378
404
|
if (segs[0] === 'web' && segs[1] === 'app.js' && segs.length === 2) return await this.replyWebJs()
|
|
379
405
|
if (segs[0] === 'drafts' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
380
406
|
return this.replyDraft(segs[1], segs[2])
|
|
@@ -388,7 +414,11 @@ export class ServeApp {
|
|
|
388
414
|
if (segs[0] === 'lora-about' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
389
415
|
return await this.replyLoraAbout(segs[1], segs[2])
|
|
390
416
|
if (segs[0] === 'prompt-enhancers' && segs.length === 1) return this.replyPromptEnhancers()
|
|
417
|
+
if (segs[0] === 'llm-configs' && segs.length === 1) return this.replyLlmConfigs()
|
|
418
|
+
if (segs[0] === 'tags' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
419
|
+
return await this.replyTags(segs[1], segs[2], req.url)
|
|
391
420
|
if (segs[0] === 'settings' && segs.length === 1) return this.replySettings()
|
|
421
|
+
if (segs[0] === 'tabs' && segs.length === 1) return this.replyTabs()
|
|
392
422
|
if (segs[0] === 'hosts' && segs.length === 1) return this.replyHosts()
|
|
393
423
|
if (segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] === 'logs')
|
|
394
424
|
return await this.replyHostLogs(segs[1])
|
|
@@ -398,6 +428,8 @@ export class ServeApp {
|
|
|
398
428
|
return await this.replyHostDrift(segs[1], req.url.includes('full=1'))
|
|
399
429
|
if (segs[0] === 'images' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
400
430
|
return this.replyMemoryImage(`${segs[1]}/${segs[2]}`)
|
|
431
|
+
if (segs[0] === 'audio' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
432
|
+
return this.replyMemoryImage(`audio/${segs[1]}/${segs[2]}`)
|
|
401
433
|
if (segs[0] === 'outputs') return this.replyOutput(segs.slice(1))
|
|
402
434
|
return json(404, { error: `no route: GET ${path}`, usage: USAGE })
|
|
403
435
|
}
|
|
@@ -406,12 +438,15 @@ export class ServeApp {
|
|
|
406
438
|
if ('error' in target) return json(target.status, { error: target.error })
|
|
407
439
|
return await this.generate(target.mod, target.draft, req)
|
|
408
440
|
}
|
|
441
|
+
if (req.method === 'POST' && segs[0] === 'preview' && segs.length === 2 && segs[1] != null)
|
|
442
|
+
return await this.replyPreview(segs[1], req)
|
|
409
443
|
if (req.method === 'POST' && segs[0] === 'upload' && segs.length === 1) return this.replyUpload(req)
|
|
410
444
|
if (req.method === 'PUT' && segs[0] === 'drafts' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
411
445
|
return await this.replySaveDraft(segs[1], segs[2], req)
|
|
412
446
|
if (req.method === 'DELETE' && segs[0] === 'drafts' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
413
447
|
return await this.replyDeleteDraft(segs[1], segs[2])
|
|
414
448
|
if (req.method === 'PUT' && segs[0] === 'settings' && segs.length === 1) return this.replySaveSettings(req)
|
|
449
|
+
if (req.method === 'PUT' && segs[0] === 'tabs' && segs.length === 1) return this.replySaveTabs(req)
|
|
415
450
|
if (req.method === 'PUT' && segs[0] === 'hosts' && segs.length === 2 && segs[1] != null)
|
|
416
451
|
return this.replySetHost(segs[1], req)
|
|
417
452
|
if (req.method === 'POST' && segs[0] === 'hosts' && segs.length === 3 && segs[1] != null && segs[2] != null)
|
|
@@ -429,6 +464,10 @@ export class ServeApp {
|
|
|
429
464
|
return this.replySavePromptEnhancer(segs[1], req)
|
|
430
465
|
if (req.method === 'DELETE' && segs[0] === 'prompt-enhancers' && segs.length === 2 && segs[1] != null)
|
|
431
466
|
return this.replyDeletePromptEnhancer(segs[1])
|
|
467
|
+
if (req.method === 'PUT' && segs[0] === 'llm-configs' && segs.length === 2 && segs[1] != null)
|
|
468
|
+
return this.replySaveLlmConfig(segs[1], req)
|
|
469
|
+
if (req.method === 'DELETE' && segs[0] === 'llm-configs' && segs.length === 2 && segs[1] != null)
|
|
470
|
+
return this.replyDeleteLlmConfig(segs[1])
|
|
432
471
|
return json(404, { error: `no route: ${req.method} ${path}`, usage: USAGE })
|
|
433
472
|
} catch (e) {
|
|
434
473
|
console.error('[serve] request crashed:', e)
|
|
@@ -577,14 +616,54 @@ export class ServeApp {
|
|
|
577
616
|
(d) => `POST /generate/${encodeURIComponent(mod.key)}/${encodeURIComponent(d)}`,
|
|
578
617
|
),
|
|
579
618
|
vars,
|
|
619
|
+
// the names of the workflow's live previews: the panel asks POST /preview/<module>
|
|
620
|
+
previews: Object.keys(mod.dw.spec.previews ?? {}),
|
|
621
|
+
tags: this.tagsByModule.get(mod.key) ?? mod.dw.spec.tags ?? [],
|
|
580
622
|
}
|
|
581
623
|
}
|
|
582
624
|
|
|
583
|
-
|
|
625
|
+
/** per module, read once from a dry build: the omnibox searches and shows them */
|
|
626
|
+
private tagsByModule = new Map<string, string[]>()
|
|
627
|
+
|
|
628
|
+
private async tagsFor(mod: ServeModule): Promise<string[]> {
|
|
629
|
+
const known = this.tagsByModule.get(mod.key)
|
|
630
|
+
if (known != null) return known
|
|
631
|
+
const extra = mod.dw.spec.tags ?? []
|
|
632
|
+
const varKinds = mod.dw.entries().map(([, varDef]) => varDef.kind)
|
|
633
|
+
let tags: string[]
|
|
634
|
+
try {
|
|
635
|
+
const wf = await mod.dw.build({ dry: true })
|
|
636
|
+
const nodes: TagNode[] = wf.nodes.map((n) => ({
|
|
637
|
+
id: n.uid,
|
|
638
|
+
classType: n.json.class_type,
|
|
639
|
+
outputNode: n.$schema.raw.output_node,
|
|
640
|
+
outputTypes: n.$schema.outputs.map((o) => o.typeName),
|
|
641
|
+
links: Object.values(n.json.inputs).flatMap((v): [string, number][] =>
|
|
642
|
+
Array.isArray(v) && v.length === 2 && typeof v[1] === 'number' ? [[String(v[0]), v[1]]] : [],
|
|
643
|
+
),
|
|
644
|
+
}))
|
|
645
|
+
tags = workflowTags({ nodes, varKinds, extra })
|
|
646
|
+
} catch (e) {
|
|
647
|
+
console.error(`[serve] 🔴 tags for ${mod.key}: dry build failed, spec tags only: ${extractErrorMessage(e)}`)
|
|
648
|
+
tags = workflowTags({ nodes: [], varKinds, extra })
|
|
649
|
+
}
|
|
650
|
+
this.tagsByModule.set(mod.key, tags)
|
|
651
|
+
return tags
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
private async replyIndex(): Promise<ServeReply> {
|
|
655
|
+
for (const m of this.modules) await this.tagsFor(m)
|
|
584
656
|
return json(200, {
|
|
585
657
|
server: 'comfy-ts serve',
|
|
586
658
|
usage: USAGE,
|
|
587
659
|
workflows: this.modules.map((m) => this.describeModule(m)),
|
|
660
|
+
...(this.opts.workspace == null
|
|
661
|
+
? {}
|
|
662
|
+
: workspaceLabels({
|
|
663
|
+
workspace: this.opts.workspace,
|
|
664
|
+
root: this.opts.root ?? this.opts.workspace,
|
|
665
|
+
home: process.env.HOME ?? '',
|
|
666
|
+
})),
|
|
588
667
|
...(this.opts.loadErrors != null && Object.keys(this.opts.loadErrors).length > 0
|
|
589
668
|
? { loadErrors: this.opts.loadErrors }
|
|
590
669
|
: {}),
|
|
@@ -601,6 +680,34 @@ export class ServeApp {
|
|
|
601
680
|
return json(200, { ...this.describeModule(mod), draft, values: this.draftValues(mod, draft) })
|
|
602
681
|
}
|
|
603
682
|
|
|
683
|
+
/** the workflow's previews for the values the panel holds right now. The vars are SHARED
|
|
684
|
+
* state (a run reads them), so this runs under the module lock: load the values, compute,
|
|
685
|
+
* put the old values back. Nothing is queued, nothing is written */
|
|
686
|
+
private async replyPreview(key: string, req: ServeRequest): Promise<ServeReply> {
|
|
687
|
+
const mod = this.moduleByKey(key)
|
|
688
|
+
if (mod == null) return json(404, { error: `unknown workflow '${key}'` })
|
|
689
|
+
let values: unknown
|
|
690
|
+
try {
|
|
691
|
+
values = JSON.parse(req.body ?? '{}')
|
|
692
|
+
} catch (e) {
|
|
693
|
+
return json(400, { error: `body is not valid json: ${extractErrorMessage(e)}` })
|
|
694
|
+
}
|
|
695
|
+
if (values == null || typeof values !== 'object' || Array.isArray(values))
|
|
696
|
+
return json(400, { error: 'expects { "<var>": value, … }' })
|
|
697
|
+
const incoming = values as Record<string, unknown>
|
|
698
|
+
const previews = await this.exclusive(mod.key, () => {
|
|
699
|
+
const saved = mod.dw.entries().map(([k, v]) => [k, v.toJSON()] as const)
|
|
700
|
+
try {
|
|
701
|
+
for (const [k, v] of mod.dw.entries()) if (k in incoming) v.loadJSON(incoming[k])
|
|
702
|
+
return Promise.resolve(mod.dw.computePreviews())
|
|
703
|
+
} finally {
|
|
704
|
+
const byName = new Map(mod.dw.entries())
|
|
705
|
+
for (const [k, json] of saved) byName.get(k)?.loadJSON(json)
|
|
706
|
+
}
|
|
707
|
+
})
|
|
708
|
+
return json(200, { previews })
|
|
709
|
+
}
|
|
710
|
+
|
|
604
711
|
/** stored values (toJSON shapes); 'default' without a file falls back to descriptor defaults */
|
|
605
712
|
private draftValues(mod: ServeModule, draft: string): Record<string, unknown> {
|
|
606
713
|
const path = this.draftPath(mod, draft)
|
|
@@ -624,8 +731,7 @@ export class ServeApp {
|
|
|
624
731
|
|
|
625
732
|
private async replyWebJs(): Promise<ServeReply> {
|
|
626
733
|
if (this.opts.webJs == null) return json(404, { error: 'web ui not enabled on this server' })
|
|
627
|
-
|
|
628
|
-
const js = await this.webJsCache
|
|
734
|
+
const js = await this.opts.webJs()
|
|
629
735
|
if (js == null) return json(404, { error: 'web ui bundle unavailable — see the server log' })
|
|
630
736
|
return { status: 200, contentType: 'text/javascript; charset=utf-8', body: js, headers: NO_STORE }
|
|
631
737
|
}
|
|
@@ -670,7 +776,17 @@ export class ServeApp {
|
|
|
670
776
|
return json(400, { error: 'body must be a json object: { "<var>": value, … }' })
|
|
671
777
|
const values = parsed as Record<string, unknown>
|
|
672
778
|
const known = new Set(mod.dw.entries().map(([k]) => k))
|
|
673
|
-
|
|
779
|
+
// `$enhance` rides beside the values (src/cli/draftMeta.ts): a string map, checked whole
|
|
780
|
+
if (ENHANCE_KEY in values) {
|
|
781
|
+
const raw = values[ENHANCE_KEY]
|
|
782
|
+
const ok =
|
|
783
|
+
raw != null &&
|
|
784
|
+
typeof raw === 'object' &&
|
|
785
|
+
!Array.isArray(raw) &&
|
|
786
|
+
Object.values(raw).every((v) => typeof v === 'string')
|
|
787
|
+
if (!ok) return json(400, { error: `${ENHANCE_KEY} must be { "<prompt var>": "<intent>" }` })
|
|
788
|
+
}
|
|
789
|
+
const unknown = Object.keys(values).filter((k) => !known.has(k) && !isDraftMetaKey(k))
|
|
674
790
|
if (unknown.length > 0)
|
|
675
791
|
return json(400, { error: `unknown var(s) ${unknown.join(', ')} — vars: ${[...known].join(', ')}` })
|
|
676
792
|
// values are written VERBATIM (toJSON shapes, loadJSON re-validates on read) —
|
|
@@ -746,9 +862,18 @@ export class ServeApp {
|
|
|
746
862
|
if (action === 'refresh-loras') return await this.refreshLoraMirror(hostId, host)
|
|
747
863
|
if (action === 'refresh-schema') {
|
|
748
864
|
await host.fetchAndUpdateSchema()
|
|
749
|
-
//
|
|
750
|
-
//
|
|
751
|
-
//
|
|
865
|
+
// the ONE refresh re-reads the lora manager's list too, BEFORE the rebind reads it:
|
|
866
|
+
// a lora the host just learned gets its name, preview and trigger words in the same
|
|
867
|
+
// pass. A host without the extension, or one that fails the sweep, keeps its old
|
|
868
|
+
// list and the note says so; the schema refetch itself still stands
|
|
869
|
+
const unmirrored = lorasMissingFromMirror(host.schema.getLoras(), (n) => getLoraInfo(n, hostId) != null)
|
|
870
|
+
const synced = await this.refreshLoraMirror(hostId, host)
|
|
871
|
+
const lorasNote =
|
|
872
|
+
synced.status === 200
|
|
873
|
+
? unmirrored.length > 0
|
|
874
|
+
? `, lora list re-read (${unmirrored.length} new)`
|
|
875
|
+
: ', lora list re-read'
|
|
876
|
+
: ', the lora manager list could not be re-read'
|
|
752
877
|
const rebound = await this.rebindHostVars(hostId, host)
|
|
753
878
|
const nodes = host.schema.nodes.length
|
|
754
879
|
const loras = host.schema.getLoras().length
|
|
@@ -761,7 +886,7 @@ export class ServeApp {
|
|
|
761
886
|
host: hostId,
|
|
762
887
|
action,
|
|
763
888
|
stale: rebound.stale,
|
|
764
|
-
note: `schema refetched: ${nodes} node types, ${loras} loras, ${rebound.widened} lora var(s) changed${dropped}
|
|
889
|
+
note: `schema refetched: ${nodes} node types, ${loras} loras, ${rebound.widened} lora var(s) changed${dropped}${lorasNote}`,
|
|
765
890
|
})
|
|
766
891
|
}
|
|
767
892
|
if (action === 'restart') {
|
|
@@ -1003,7 +1128,7 @@ export class ServeApp {
|
|
|
1003
1128
|
const hit = this.memoryImages.get(key)
|
|
1004
1129
|
if (hit == null)
|
|
1005
1130
|
return json(404, {
|
|
1006
|
-
error: `no in-memory
|
|
1131
|
+
error: `no in-memory output '${key}' — it expired (only the last ${this.MEMORY_IMAGE_CAP} are kept) or the server restarted. Turn saving on to keep outputs.`,
|
|
1007
1132
|
})
|
|
1008
1133
|
return { status: 200, contentType: hit.contentType, body: hit.bytes }
|
|
1009
1134
|
}
|
|
@@ -1071,8 +1196,91 @@ export class ServeApp {
|
|
|
1071
1196
|
})
|
|
1072
1197
|
}
|
|
1073
1198
|
|
|
1199
|
+
// #region open draft tabs (the web ui's tab bar) ------------------------------
|
|
1200
|
+
/** held by the process, so every window and reload sees the same tabs, and mirrored to a file
|
|
1201
|
+
* under .comfy-ts/ (gitignored wholesale) so a restart keeps them. null = not read yet */
|
|
1202
|
+
private tabs: DraftTab[] | null = null
|
|
1203
|
+
|
|
1204
|
+
private tabsFile(): string {
|
|
1205
|
+
return join(comfyts.baseFolder, SERVE_TABS_FILE)
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
/** only drafts that still exist: a tab whose file was deleted elsewhere is dropped on read */
|
|
1209
|
+
private liveTabs(raw: unknown): DraftTab[] {
|
|
1210
|
+
return readTabs(
|
|
1211
|
+
raw,
|
|
1212
|
+
this.modules.map((m) => ({ module: m.key, drafts: this.draftsFor(m) })),
|
|
1213
|
+
)
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
private replyTabs(): ServeReply {
|
|
1217
|
+
if (this.tabs == null) {
|
|
1218
|
+
const path = this.tabsFile()
|
|
1219
|
+
let raw: unknown = []
|
|
1220
|
+
try {
|
|
1221
|
+
if (existsSync(path)) raw = JSON.parse(readFileSync(path, 'utf8'))
|
|
1222
|
+
} catch (e) {
|
|
1223
|
+
console.error(`[serve] 🔴 open tabs unreadable (${path}), starting with none:`, e)
|
|
1224
|
+
}
|
|
1225
|
+
this.tabs = this.liveTabs(raw)
|
|
1226
|
+
}
|
|
1227
|
+
this.tabs = this.liveTabs(this.tabs)
|
|
1228
|
+
return json(200, { tabs: this.tabs })
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
private replySaveTabs(req: ServeRequest): ServeReply {
|
|
1232
|
+
let parsed: unknown
|
|
1233
|
+
try {
|
|
1234
|
+
parsed = JSON.parse(req.body ?? '')
|
|
1235
|
+
} catch (e) {
|
|
1236
|
+
return json(400, { error: `body is not valid json: ${extractErrorMessage(e)}` })
|
|
1237
|
+
}
|
|
1238
|
+
const raw = parsed != null && typeof parsed === 'object' ? (parsed as { tabs?: unknown }).tabs : undefined
|
|
1239
|
+
if (!Array.isArray(raw) || raw.length > 100)
|
|
1240
|
+
return json(400, { error: 'expects { "tabs": [{ "module", "draft" }, …] }' })
|
|
1241
|
+
this.tabs = this.liveTabs(raw)
|
|
1242
|
+
try {
|
|
1243
|
+
mkdirSync(comfyts.baseFolder, { recursive: true })
|
|
1244
|
+
writeFileSync(this.tabsFile(), JSON.stringify(this.tabs, null, 2))
|
|
1245
|
+
} catch (e) {
|
|
1246
|
+
// kept for this process either way: only the restart loses them, and the reply says so
|
|
1247
|
+
console.error(`[serve] 🔴 open tabs not saved to ${this.tabsFile()}:`, e)
|
|
1248
|
+
return json(200, { tabs: this.tabs, warning: `not saved: ${extractErrorMessage(e)}` })
|
|
1249
|
+
}
|
|
1250
|
+
return json(200, { tabs: this.tabs })
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1074
1253
|
// #region prompt enhancers (the web ui's master prompts, as .md files) ------
|
|
1075
1254
|
/** the folder is seeded on the first read, so `refine-krea2-prompt.md` exists to be edited */
|
|
1255
|
+
/** tag lists by source, loaded on the first query and kept for the process */
|
|
1256
|
+
private tagSources = new TagSources({
|
|
1257
|
+
cacheDir: () => join(comfyts.baseFolder, 'cache', 'tags'),
|
|
1258
|
+
fetchText: async (url) => {
|
|
1259
|
+
const res = await fetch(url, { redirect: 'follow', signal: AbortSignal.timeout(TAG_LIST_TIMEOUT_MS) })
|
|
1260
|
+
if (!res.ok) throw new Error(`tag list download failed (http ${res.status}): ${url}`)
|
|
1261
|
+
return new TextDecoder().decode(await readCapped(res, TAG_LIST_CAP, url))
|
|
1262
|
+
},
|
|
1263
|
+
})
|
|
1264
|
+
|
|
1265
|
+
private async replyTags(modKey: string, varName: string, url: string): Promise<ServeReply> {
|
|
1266
|
+
const mod = this.moduleByKey(modKey)
|
|
1267
|
+
if (mod == null) return json(404, { error: `unknown workflow '${modKey}'` })
|
|
1268
|
+
const found = mod.dw.entries().find(([k]) => k === varName)?.[1]
|
|
1269
|
+
if (found == null) return json(404, { error: `workflow '${modKey}' has no var '${varName}'` })
|
|
1270
|
+
// cast: whitelist family 6, narrowed by kind
|
|
1271
|
+
const tags = found.kind === 'prompt' ? (found as PromptVar).tags : null
|
|
1272
|
+
if (tags == null) return json(404, { error: `var '${varName}' declares no tag list (v.prompt(…, { tags }))` })
|
|
1273
|
+
const params = new URLSearchParams(url.split('?')[1] ?? '')
|
|
1274
|
+
const limit = Math.min(100, Math.max(1, Number(params.get('limit') ?? '20') || 20))
|
|
1275
|
+
try {
|
|
1276
|
+
const list = await this.tagSources.load(resolveTagSource(tags.url, mod.file))
|
|
1277
|
+
return json(200, { hits: list.search(params.get('q') ?? '', limit) })
|
|
1278
|
+
} catch (e) {
|
|
1279
|
+
console.error(`[serve] 🔴 tag list for ${modKey}/${varName}: ${extractErrorMessage(e)}`)
|
|
1280
|
+
return json(502, { error: extractErrorMessage(e) })
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1076
1284
|
private replyPromptEnhancers(): ServeReply {
|
|
1077
1285
|
try {
|
|
1078
1286
|
return json(200, { enhancers: listPromptEnhancers() })
|
|
@@ -1115,6 +1323,46 @@ export class ServeApp {
|
|
|
1115
1323
|
return json(200, { ok: true, name, enhancers: listPromptEnhancers() })
|
|
1116
1324
|
}
|
|
1117
1325
|
|
|
1326
|
+
private replyLlmConfigs(): ServeReply {
|
|
1327
|
+
try {
|
|
1328
|
+
return json(200, { configs: listLlmConfigs() })
|
|
1329
|
+
} catch (e) {
|
|
1330
|
+
return json(500, { error: `llm-configs folder unreadable: ${extractErrorMessage(e)}` })
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
private replySaveLlmConfig(rawName: string, req: ServeRequest): ServeReply {
|
|
1335
|
+
const name = validStoreName(rawName)
|
|
1336
|
+
if (name == null)
|
|
1337
|
+
return json(400, { error: `invalid config name '${rawName}' — letters/digits then letters, digits, ". -_"` })
|
|
1338
|
+
let parsed: unknown
|
|
1339
|
+
try {
|
|
1340
|
+
parsed = JSON.parse(req.body ?? '')
|
|
1341
|
+
} catch (e) {
|
|
1342
|
+
return json(400, { error: `body is not valid json: ${extractErrorMessage(e)}` })
|
|
1343
|
+
}
|
|
1344
|
+
if (parsed == null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
1345
|
+
return json(400, { error: 'body must be { provider, baseUrl, model, effort, thinkingOnly }' })
|
|
1346
|
+
try {
|
|
1347
|
+
writeLlmConfig(name, normalizeLlmConfig(parsed))
|
|
1348
|
+
} catch (e) {
|
|
1349
|
+
return json(500, { error: `could not write llm config '${name}': ${extractErrorMessage(e)}` })
|
|
1350
|
+
}
|
|
1351
|
+
return json(200, { ok: true, name, configs: listLlmConfigs() })
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
private replyDeleteLlmConfig(rawName: string): ServeReply {
|
|
1355
|
+
const name = validStoreName(rawName)
|
|
1356
|
+
if (name == null) return json(400, { error: `invalid config name '${rawName}'` })
|
|
1357
|
+
try {
|
|
1358
|
+
deleteLlmConfig(name)
|
|
1359
|
+
} catch (e) {
|
|
1360
|
+
return json(500, { error: `could not delete llm config '${name}': ${extractErrorMessage(e)}` })
|
|
1361
|
+
}
|
|
1362
|
+
console.log(`[serve] llm config deleted: ${name}`)
|
|
1363
|
+
return json(200, { ok: true, name, configs: listLlmConfigs() })
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1118
1366
|
// #region live run state (web ui polling: progress + latent preview) --------
|
|
1119
1367
|
private liveRuns = new Map<string, ServeExecution>()
|
|
1120
1368
|
/** seq counts frames so the poller refetches only on a NEW one, not every tick */
|
|
@@ -1330,6 +1578,8 @@ export class ServeApp {
|
|
|
1330
1578
|
}
|
|
1331
1579
|
|
|
1332
1580
|
const produced = [`${execution.images.length} image(s)`]
|
|
1581
|
+
const audios = execution.audios ?? []
|
|
1582
|
+
if (audios.length > 0) produced.push(`${audios.length} audio(s)`)
|
|
1333
1583
|
if ((execution.texts ?? []).length > 0) produced.push(`${(execution.texts ?? []).length} text(s)`)
|
|
1334
1584
|
console.log(`[serve] 🟢 ${mod.key}/${draft} done in ${(durationMs / 1000).toFixed(1)}s · ${produced.join(' · ')}`)
|
|
1335
1585
|
|
|
@@ -1343,6 +1593,15 @@ export class ServeApp {
|
|
|
1343
1593
|
memoryKeys.set(ix, key)
|
|
1344
1594
|
}
|
|
1345
1595
|
|
|
1596
|
+
// same store as the images, own key space: the audio route adds the `audio/` prefix
|
|
1597
|
+
const audioKeys = new Map<number, string>()
|
|
1598
|
+
for (const [ix, a] of audios.entries()) {
|
|
1599
|
+
if (a.absPath != null) continue
|
|
1600
|
+
const key = `${execution.data.id}/${ix}`
|
|
1601
|
+
this.rememberMemoryImage(`audio/${key}`, a.bytes, a.filename)
|
|
1602
|
+
audioKeys.set(ix, key)
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1346
1605
|
// Accept: image/* → first image's bytes directly (curl -o, <img src>)
|
|
1347
1606
|
const first = execution.images[0]
|
|
1348
1607
|
if (req.accept?.includes('image/') && first != null) {
|
|
@@ -1378,6 +1637,20 @@ export class ServeApp {
|
|
|
1378
1637
|
: null,
|
|
1379
1638
|
absPath: img.absPath,
|
|
1380
1639
|
})),
|
|
1640
|
+
audios: audios.map((a, ix) => ({
|
|
1641
|
+
filename: a.filename,
|
|
1642
|
+
mime: a.mime,
|
|
1643
|
+
url:
|
|
1644
|
+
a.absPath != null
|
|
1645
|
+
? this.outputUrl(a.absPath)
|
|
1646
|
+
: audioKeys.has(ix)
|
|
1647
|
+
? `/audio/${(audioKeys.get(ix) ?? '')
|
|
1648
|
+
.split('/')
|
|
1649
|
+
.map((seg) => encodeURIComponent(seg))
|
|
1650
|
+
.join('/')}`
|
|
1651
|
+
: null,
|
|
1652
|
+
absPath: a.absPath,
|
|
1653
|
+
})),
|
|
1381
1654
|
})
|
|
1382
1655
|
}
|
|
1383
1656
|
|
|
@@ -1479,17 +1752,19 @@ export class ServeApp {
|
|
|
1479
1752
|
const seedVar = varDef as SeedVar
|
|
1480
1753
|
const stateKey = `${mod.key}/${draft}/${k}`
|
|
1481
1754
|
const draftValue = draftSeedValues.get(k) ?? seedVar.value
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1755
|
+
const prev = this.seedState.get(stateKey)
|
|
1756
|
+
const continues =
|
|
1757
|
+
!(k in payload) &&
|
|
1758
|
+
(seedVar.mode === '+' || seedVar.mode === '-') &&
|
|
1759
|
+
prev != null &&
|
|
1760
|
+
(prev.draftBase === draftValue || prev.served.includes(draftValue))
|
|
1761
|
+
if (!(k in payload) && seedVar.mode === '?') seedVar.randomize()
|
|
1762
|
+
if (continues) {
|
|
1763
|
+
seedVar.set(prev.last + (seedVar.mode === '+' ? 1 : -1))
|
|
1764
|
+
// bounded: a write-back never lags by more than the queue
|
|
1765
|
+
const served = [...prev.served, seedVar.value].slice(-256)
|
|
1766
|
+
this.seedState.set(stateKey, { last: seedVar.value, draftBase: prev.draftBase, served })
|
|
1767
|
+
} else this.seedState.set(stateKey, { last: seedVar.value, draftBase: draftValue, served: [seedVar.value] })
|
|
1493
1768
|
seeds[k] = seedVar.value
|
|
1494
1769
|
}
|
|
1495
1770
|
|