comfy-ts 1.2.0 → 1.4.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 +66 -0
- package/dist/DefinedWorkflow-C_QAxKr3.js +737 -0
- package/dist/DefinedWorkflow-C_QAxKr3.js.map +1 -0
- package/dist/DraftsSt-DcOTn0QR.js +434 -0
- package/dist/DraftsSt-DcOTn0QR.js.map +1 -0
- package/dist/cli.js +15 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +476 -202
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -40
- package/dist/index.d.ts +117 -59
- package/dist/index.js +468 -193
- package/dist/index.js.map +1 -1
- package/dist/run-serve-CN0DhrsA.js +638 -0
- package/dist/run-serve-CN0DhrsA.js.map +1 -0
- package/dist/{run-tui-BAdizWsO.js → run-tui-bN2hSD5i.js} +250 -447
- package/dist/run-tui-bN2hSD5i.js.map +1 -0
- package/dist/state-COlKYipO.js +4743 -0
- package/dist/state-COlKYipO.js.map +1 -0
- package/dist/web.d.ts +17340 -0
- package/dist/{state-BYbxDgfr.js → web.js} +1903 -1592
- package/dist/web.js.map +1 -0
- package/examples/web/example.ts +71 -0
- package/examples/web/index.html +77 -0
- package/examples/web/serve.ts +42 -0
- package/examples/web/tsconfig.json +15 -0
- package/package.json +10 -3
- package/src/cli/comfy-ts-cli.ts +15 -5
- package/src/cli/serve/ServeApp.ts +378 -0
- package/src/cli/serve/applyVarPayload.ts +119 -0
- package/src/cli/serve/describeVar.ts +74 -0
- package/src/cli/serve/run-serve.ts +169 -0
- package/src/cli/tui/components/StatusBar.tsx +1 -0
- package/src/cli/tui/components/TreePanel.tsx +17 -3
- package/src/cli/tui/components/TuiApp.tsx +7 -2
- package/src/cli/tui/components/VarsPanel.tsx +67 -34
- package/src/cli/tui/imageClipboard.ts +39 -0
- package/src/cli/tui/listWindow.ts +36 -0
- package/src/cli/tui/state/ExecSt.ts +48 -0
- package/src/cli/tui/state/TreeSt.ts +25 -0
- package/src/cli/tui/state/TuiSt.ts +34 -0
- package/src/coreExports.ts +118 -0
- package/src/host/ComfyHost.ts +23 -23
- package/src/host/ResilientWebsocket.ts +93 -47
- package/src/host/hostUrl.ts +2 -1
- package/src/host/loraManagerApi.ts +6 -7
- package/src/index.ts +8 -107
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +11 -7
- package/src/manager/loaders/step2_custom-node-list-loader.ts +4 -4
- package/src/manager/loaders/step3_extension-node-map-loader.ts +3 -3
- package/src/manager/loaders/step4_model-list-loader.ts +7 -7
- package/src/manager/loaders/step5_alter-list-loader.ts +2 -2
- package/src/manager/loaders/step6_github-stats-loader.ts +2 -2
- package/src/runner/ComfyExecution.ts +32 -12
- package/src/runner/MediaImage.ts +18 -30
- package/src/runner/outputPath.ts +75 -0
- package/src/sdk-generator/ComfySchema.ts +2 -2
- package/src/sdk-generator/inputWidgetKind.ts +50 -11
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +14 -7
- package/src/state.ts +13 -9
- package/src/storage/ComfyStorage.ts +144 -0
- package/src/storage/nodeStorage.ts +9 -0
- package/src/utils/downloadFile.ts +11 -69
- package/src/utils/hashArrayBuffer.ts +3 -4
- package/src/utils/lazySharp.ts +25 -0
- package/src/utils/sha1.ts +69 -0
- package/src/vars/ComfyVars.ts +13 -6
- package/src/vars/loraKeywords.ts +6 -6
- package/src/web.ts +13 -0
- package/dist/run-tui-BAdizWsO.js.map +0 -1
- package/dist/state-BYbxDgfr.js.map +0 -1
- package/src/utils/writeFile.ts +0 -16
package/README.md
CHANGED
|
@@ -309,11 +309,77 @@ bunx comfy-ts gen --id my-gpu --host http://127.0.0.1:8188
|
|
|
309
309
|
bunx comfy-ts outline # what's inside that 2MB sdk.d.ts?
|
|
310
310
|
bunx comfy-ts tui # your *.cflow.ts + bundled examples
|
|
311
311
|
bunx comfy-ts tui [dir | module] # scan just that
|
|
312
|
+
bunx comfy-ts serve [dir | module] # drafts as a local HTTP API (below)
|
|
312
313
|
```
|
|
313
314
|
|
|
314
315
|
Any reachable host: the box under your desk or a GPU machine across the
|
|
315
316
|
network, same command, same output.
|
|
316
317
|
|
|
318
|
+
## 🌐 Serve: drafts as an HTTP API
|
|
319
|
+
|
|
320
|
+
Hand-tune a draft in the TUI, then make it callable by anything that speaks
|
|
321
|
+
HTTP — a web frontend, curl, n8n, another service:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
bunx comfy-ts serve # every *.cflow.ts under cwd, port 8288
|
|
325
|
+
bunx comfy-ts serve ./flows # just that folder
|
|
326
|
+
bunx comfy-ts serve txt2img.cflow.ts # one workflow (routes shorten to /generate/<draft>)
|
|
327
|
+
bunx comfy-ts serve --port 9000 --bind 0.0.0.0 # pick port / expose beyond localhost
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Discover what's being served — same info the startup print shows, as JSON:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
curl http://127.0.0.1:8288/drafts # all workflows, their drafts, every var described
|
|
334
|
+
curl http://127.0.0.1:8288/drafts/txt2img/moody # one draft with its stored values
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Generate:
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
curl -X POST http://127.0.0.1:8288/generate/txt2img/default \
|
|
341
|
+
-H 'content-type: application/json' \
|
|
342
|
+
-d '{"prompt": "a red cube", "steps": 8}'
|
|
343
|
+
# → { "ok": true, "images": [{ "url": "/outputs/…png", … }], "seeds": … }
|
|
344
|
+
|
|
345
|
+
curl -X POST http://127.0.0.1:8288/generate/txt2img/moody \
|
|
346
|
+
-H 'accept: image/*' -d '{"seed": 42}' -o out.png # raw image bytes
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Draft values are the defaults, the JSON body overrides per request, and every
|
|
350
|
+
value is validated before anything is queued (wrong choice? the 400 lists the
|
|
351
|
+
allowed ones). `GET /drafts` self-describes every workflow, draft and var —
|
|
352
|
+
enough for a frontend to render a form. `Accept: image/*` returns the image
|
|
353
|
+
bytes directly (`curl … -H 'accept: image/*' -o out.png`). Drafts are
|
|
354
|
+
re-read on every request: keep the TUI open, tweak, next call uses the new
|
|
355
|
+
values. Binds to localhost only unless you say otherwise (`--bind`, `--port`).
|
|
356
|
+
|
|
357
|
+
## 🕸️ In the browser: `comfy-ts/web`
|
|
358
|
+
|
|
359
|
+
The same library runs in a browser bundle — define workflows, connect to a
|
|
360
|
+
host, run, get bytes back, no server in between:
|
|
361
|
+
|
|
362
|
+
```ts
|
|
363
|
+
import { ComfyTS } from 'comfy-ts/web'
|
|
364
|
+
|
|
365
|
+
const comfy = ComfyTS.create() // in-memory storage, native WebSocket
|
|
366
|
+
const host = comfy.host({ id: 'local', url: 'http://127.0.0.1:8188' })
|
|
367
|
+
await host.connect()
|
|
368
|
+
const wf = host.workflow()
|
|
369
|
+
// …build with wf.builder, run, then execution.images[0].getAsBlob()
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Nothing touches disk: schema caches and outputs live in an in-memory store
|
|
373
|
+
(pass `ComfyTS.create({ storage })` for your own backend). Types work the
|
|
374
|
+
same as everywhere else — include a generated `sdk.d.ts` in your tsconfig
|
|
375
|
+
and every node autocompletes.
|
|
376
|
+
|
|
377
|
+
The honest support matrix: **local/LAN hosts connect directly** when ComfyUI
|
|
378
|
+
is started with `--enable-cors-header '*'` (browser websocket auth rides
|
|
379
|
+
`?token=<api-key>` since browsers cannot set upgrade headers). **Comfy Cloud
|
|
380
|
+
sends no CORS headers today**, so cloud from a browser goes through
|
|
381
|
+
`comfy-ts serve` as the bridge. Runnable page: `bun examples/web/serve.ts`.
|
|
382
|
+
|
|
317
383
|
## 🌍 Hosts: local, LAN, Comfy Cloud, any provider
|
|
318
384
|
|
|
319
385
|
Every Comfy is supported, through one identical API. Same mechanism, same
|