comfy-ts 2.20.0 → 2.20.2
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 +4 -2
- package/dist/cli.js +3 -3
- package/dist/{exampleAssets-j1f26nGc.js → exampleAssets-yBLaKXLq.js} +6 -2
- package/dist/{exampleAssets-j1f26nGc.js.map → exampleAssets-yBLaKXLq.js.map} +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/{run-run-QEoh7Wbh.js → run-run-C-dDD9Dc.js} +2 -2
- package/dist/{run-run-QEoh7Wbh.js.map → run-run-C-dDD9Dc.js.map} +1 -1
- package/dist/{run-tui-YxiSoNvK.js → run-tui-bsmja4hi.js} +2 -2
- package/dist/{run-tui-YxiSoNvK.js.map → run-tui-bsmja4hi.js.map} +1 -1
- package/dist/serve-web.js +28 -28
- package/dist/web.js +5 -1
- package/dist/web.js.map +1 -1
- package/package.json +3 -2
- package/src/cli/serve/web/state/RunSt.poll.test.ts +38 -0
- package/src/cli/serve/web/state/RunSt.ts +6 -2
- package/src/host/ComfyHost.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.20.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.20.2",
|
|
4
|
+
"description": "An efficient way to create, run, maintain and operate your ComfyUI workflows, for humans and agents. A TypeScript SDK typed from your own install, with a CLI, a terminal UI, a web panel and a guide for coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comfyui",
|
|
7
7
|
"generative-ai",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"build": "tsdown && bun scripts/build-serve-web.ts",
|
|
71
71
|
"build:watch": "tsdown --watch",
|
|
72
72
|
"test": "bun test --parallel --no-isolate",
|
|
73
|
+
"test:raw": "bun test",
|
|
73
74
|
"test:watch": "bun test --watch",
|
|
74
75
|
"typecheck": "tsc -p tsconfig.lib.json && tsc -p examples/web/tsconfig.json && tsc -p src/cli/serve/web/tsconfig.json",
|
|
75
76
|
"typecheck:full": "tsc --noEmit --tsBuildInfoFile node_modules/.cache/tsbuildinfo-typecheck.json && tsc -p examples/web/tsconfig.json && tsc -p src/cli/serve/web/tsconfig.json",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// the run poll: a prompt that samples in about a second must be read several times while it runs,
|
|
2
|
+
// or the panel never shows its latent; and once it is done, the panel asks nothing more
|
|
3
|
+
import { afterEach, beforeEach, expect, it } from 'bun:test'
|
|
4
|
+
import { RunSt } from 'src/cli/serve/web/state/RunSt.ts'
|
|
5
|
+
|
|
6
|
+
const realFetch = globalThis.fetch
|
|
7
|
+
let statusReads = 0
|
|
8
|
+
const json = (body: unknown): Response =>
|
|
9
|
+
new Response(JSON.stringify(body), { headers: { 'content-type': 'application/json' } })
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
statusReads = 0
|
|
13
|
+
globalThis.fetch = (async (input: string | URL | Request): Promise<Response> => {
|
|
14
|
+
const url = String(input instanceof Request ? input.url : input)
|
|
15
|
+
if (url.startsWith('/run/')) {
|
|
16
|
+
statusReads++
|
|
17
|
+
return json({ running: true, percent: 50, hasPreview: true, previewSeq: statusReads })
|
|
18
|
+
}
|
|
19
|
+
if (url.startsWith('/generate/')) {
|
|
20
|
+
await new Promise((r) => setTimeout(r, 400))
|
|
21
|
+
return json({ promptId: 'p1', module: 'm', draft: 'd', seeds: {}, outputs: [] })
|
|
22
|
+
}
|
|
23
|
+
return json({ runs: [], memory: { usedBytes: 0, budgetBytes: 1, outputs: 0, runs: 0 } })
|
|
24
|
+
}) as typeof fetch
|
|
25
|
+
})
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
globalThis.fetch = realFetch
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('reads the run status several times during a short run, and not at all once it is done', async () => {
|
|
31
|
+
const run = new RunSt()
|
|
32
|
+
run.enqueue({ module: 'm', draft: 'd', payload: {} })
|
|
33
|
+
while (run.queue.length > 0) await new Promise((r) => setTimeout(r, 20))
|
|
34
|
+
expect(statusReads).toBeGreaterThanOrEqual(2)
|
|
35
|
+
const atEnd = statusReads
|
|
36
|
+
await new Promise((r) => setTimeout(r, 300))
|
|
37
|
+
expect(statusReads).toBe(atEnd)
|
|
38
|
+
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// the run QUEUE + results. Clicking generate repeatedly enqueues; the drainer
|
|
2
2
|
// sends ONE prompt at a time so anything still pending can be dropped before it
|
|
3
3
|
// ever reaches the host: queued prompts must be clearable, singly or
|
|
4
|
-
// all). Progress + latent preview are polled
|
|
4
|
+
// all). Progress + latent preview are polled every RUN_POLL_MS while a prompt is in flight, never
|
|
5
|
+
// while idle
|
|
5
6
|
import { makeAutoObservable, observableShallow, runInAction } from 'mobx'
|
|
6
7
|
import {
|
|
7
8
|
deleteKeptResults,
|
|
@@ -29,6 +30,9 @@ export type QueueEntry = {
|
|
|
29
30
|
sent: boolean
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/** a sampler often ends within a second: a slower poll misses every latent frame of it */
|
|
34
|
+
const RUN_POLL_MS = 150
|
|
35
|
+
|
|
32
36
|
function sleep(ms: number): Promise<void> {
|
|
33
37
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
34
38
|
}
|
|
@@ -194,7 +198,7 @@ export class RunSt {
|
|
|
194
198
|
|
|
195
199
|
private async poll(module: string, gen: number): Promise<void> {
|
|
196
200
|
while (gen === this.pollGen) {
|
|
197
|
-
await sleep(
|
|
201
|
+
await sleep(RUN_POLL_MS)
|
|
198
202
|
if (gen !== this.pollGen) return
|
|
199
203
|
try {
|
|
200
204
|
const status = await fetchRunStatus({ module })
|
package/src/host/ComfyHost.ts
CHANGED
|
@@ -719,6 +719,8 @@ export class ComfyHost<ID extends string = string> {
|
|
|
719
719
|
* cannot be reached, which is itself the signal a caller watches for a restart */
|
|
720
720
|
checkSchemaDrift = async (p: { full: boolean }): Promise<SchemaDrift> => {
|
|
721
721
|
const loaded: Record<string, unknown> = this.schema.data.spec
|
|
722
|
+
// no schema loaded yet (a TUI probes a host before its first run loads one): nothing to compare
|
|
723
|
+
if (Object.keys(loaded).length === 0) return { nodes: null, models: [] }
|
|
722
724
|
const live: Record<string, unknown> = {}
|
|
723
725
|
if (p.full) Object.assign(live, await this.fetchJSON_<Record<string, unknown>>('/object_info'))
|
|
724
726
|
else
|