@comfyorg/comfyui-desktop-bridge-types 0.9.0 → 0.11.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 +28 -5
- package/comfyDesktopBridge.d.ts +116 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,15 +41,20 @@ while omitting part of it.
|
|
|
41
41
|
|
|
42
42
|
## Comfy pages hosted in Desktop's Apps view
|
|
43
43
|
|
|
44
|
-
A Comfy page that Desktop shows in its Apps view gets
|
|
45
|
-
|
|
44
|
+
A Comfy page that Desktop shows in its Apps view gets two objects instead, and
|
|
45
|
+
nothing else of the bridge above: `window.comfyDesktopAuth`, Desktop's account
|
|
46
|
+
session, and `window.comfyDesktopLocal`, a ComfyUI on this computer.
|
|
46
47
|
|
|
47
48
|
```ts
|
|
48
|
-
import type {
|
|
49
|
+
import type {
|
|
50
|
+
ComfyDesktopHostedAuthBridge,
|
|
51
|
+
ComfyDesktopHostedLocalBridge
|
|
52
|
+
} from '@comfyorg/comfyui-desktop-bridge-types'
|
|
49
53
|
|
|
50
54
|
declare global {
|
|
51
55
|
interface Window {
|
|
52
56
|
comfyDesktopAuth?: ComfyDesktopHostedAuthBridge
|
|
57
|
+
comfyDesktopLocal?: ComfyDesktopHostedLocalBridge
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
```
|
|
@@ -57,8 +62,26 @@ declare global {
|
|
|
57
62
|
The page reads the session with `getState()`, follows it with `onChanged()`,
|
|
58
63
|
asks for the workspace credential with `getWorkspaceToken(workspaceId)` each
|
|
59
64
|
time it calls Comfy Cloud, and starts a sign-in with `requestSignIn()`. It
|
|
60
|
-
cannot sign Desktop out or switch workspace.
|
|
61
|
-
|
|
65
|
+
cannot sign Desktop out or switch workspace.
|
|
66
|
+
|
|
67
|
+
For a run on this computer the page asks `getLocal({ minVersion })` which of
|
|
68
|
+
the person's builds Desktop would use, starts it with `startLocal()`, and then
|
|
69
|
+
talks to it through `localFetch()`. Desktop forwards only the calls a run
|
|
70
|
+
needs, and only for runs the page started; `onLocalEvent()` carries ComfyUI's
|
|
71
|
+
updates for those runs. `localDownload()` saves a safetensors model from
|
|
72
|
+
Hugging Face into that build's models folder.
|
|
73
|
+
|
|
74
|
+
`openInComfy({ prompt, where, name, build })` opens a run's API-format
|
|
75
|
+
workflow in a ComfyUI window in Desktop: the build the page runs on (or the
|
|
76
|
+
build `build` names, an id from `localBuilds()`) for `where: 'local'`, or the
|
|
77
|
+
person's Comfy Cloud for `where: 'cloud'`. Desktop starts the build or shows
|
|
78
|
+
its window if needed, and resolves `{ opened: true }` once ComfyUI has loaded
|
|
79
|
+
the workflow, or `{ opened: false, error }` with the reason in words. Both
|
|
80
|
+
members are absent on Desktop builds that predate them, so a page checks for
|
|
81
|
+
them and keeps its file download as the fallback.
|
|
82
|
+
|
|
83
|
+
Both objects are absent in a browser, so a page keeps its own sign-in and its
|
|
84
|
+
own way to reach a local ComfyUI as the fallback.
|
|
62
85
|
|
|
63
86
|
## Provenance
|
|
64
87
|
|
package/comfyDesktopBridge.d.ts
CHANGED
|
@@ -187,6 +187,122 @@ export type ComfyDesktopHostedAuthBridge = Required<
|
|
|
187
187
|
'getState' | 'getWorkspaceToken' | 'getPartnerNodeToken' | 'requestSignIn' | 'onChanged'
|
|
188
188
|
>
|
|
189
189
|
>
|
|
190
|
+
/** What a hosted page needs from the ComfyUI on this computer. */
|
|
191
|
+
export interface ComfyDesktopLocalRequirements {
|
|
192
|
+
/** The oldest ComfyUI the page can run on, such as `0.41.0`. */
|
|
193
|
+
minVersion?: string
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The ComfyUI on this computer that Desktop uses for a hosted page.
|
|
197
|
+
* `running`: it answers now. `stopped`: one of the person's builds fits and
|
|
198
|
+
* `startLocal` starts it. `unsupported`: no build here can run the page, and
|
|
199
|
+
* `error` says why in words for the person.
|
|
200
|
+
*/
|
|
201
|
+
export interface ComfyDesktopLocalComfy {
|
|
202
|
+
state: 'running' | 'stopped' | 'unsupported'
|
|
203
|
+
/** True when it is one of the person's own builds. */
|
|
204
|
+
own?: boolean
|
|
205
|
+
name?: string
|
|
206
|
+
version?: string
|
|
207
|
+
/** The `client_id` Desktop listens with; updates for runs sent through `localFetch` arrive on `onLocalEvent`. */
|
|
208
|
+
clientId?: string
|
|
209
|
+
error?: string
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* One call to that ComfyUI. Desktop forwards only what a run needs:
|
|
213
|
+
* `GET /queue`, `GET /history/<run>`, `GET /view`, `GET /object_info/<node>`,
|
|
214
|
+
* `POST /prompt`, `POST /upload/image`, `POST /queue` to take a run out, and
|
|
215
|
+
* `POST /interrupt` to stop one. History, files, removal and stopping work
|
|
216
|
+
* only for runs the page started through this bridge.
|
|
217
|
+
*/
|
|
218
|
+
export interface ComfyDesktopLocalRequest {
|
|
219
|
+
method?: 'GET' | 'POST'
|
|
220
|
+
path: string
|
|
221
|
+
/** JSON text, or a file's bytes for `/upload/image`. */
|
|
222
|
+
body?: string | Uint8Array
|
|
223
|
+
/** The name to save an upload under. */
|
|
224
|
+
fileName?: string
|
|
225
|
+
}
|
|
226
|
+
/** ComfyUI's answer, or status 403 for a call Desktop does not forward. */
|
|
227
|
+
export interface ComfyDesktopLocalAnswer {
|
|
228
|
+
status: number
|
|
229
|
+
contentType: string
|
|
230
|
+
body: Uint8Array
|
|
231
|
+
}
|
|
232
|
+
/** A safetensors file on Hugging Face to save as `name` in the models folder `folder`. */
|
|
233
|
+
export interface ComfyDesktopLocalModel {
|
|
234
|
+
url: string
|
|
235
|
+
folder: string
|
|
236
|
+
name: string
|
|
237
|
+
}
|
|
238
|
+
export interface ComfyDesktopLocalDownload {
|
|
239
|
+
state: 'done' | 'failed' | 'cancelled'
|
|
240
|
+
error?: string
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A model download's progress (`type: 'download'`, with `name`, `done` and
|
|
244
|
+
* `total` bytes in `data`), or one ComfyUI socket message about a run the page
|
|
245
|
+
* started (`execution_start`, `executing`, `progress`, `progress_state`,
|
|
246
|
+
* `execution_success`, `execution_error`, `execution_interrupted`).
|
|
247
|
+
*/
|
|
248
|
+
export interface ComfyDesktopLocalEvent {
|
|
249
|
+
type: string
|
|
250
|
+
data?: Record<string, unknown>
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* A workflow a hosted page asks Desktop to open in a ComfyUI window.
|
|
254
|
+
* `prompt` is the API-format graph: an object of nodes that each have a
|
|
255
|
+
* `class_type` and `inputs`, at most 500 nodes and 1 MB. `where: 'local'`
|
|
256
|
+
* opens it in the build the page runs on, or in `build` (an id from
|
|
257
|
+
* `localBuilds`); `where: 'cloud'` opens it in the person's Comfy Cloud.
|
|
258
|
+
* `name` titles the workflow tab.
|
|
259
|
+
*/
|
|
260
|
+
export interface ComfyDesktopOpenInComfyRequest {
|
|
261
|
+
prompt: Record<string, unknown>
|
|
262
|
+
where: 'local' | 'cloud'
|
|
263
|
+
name: string
|
|
264
|
+
build?: string
|
|
265
|
+
}
|
|
266
|
+
/** Whether the workflow opened, and if not, why in words for the person. */
|
|
267
|
+
export type ComfyDesktopOpenInComfy =
|
|
268
|
+
| {
|
|
269
|
+
opened: true
|
|
270
|
+
}
|
|
271
|
+
| {
|
|
272
|
+
opened: false
|
|
273
|
+
error: string
|
|
274
|
+
}
|
|
275
|
+
/** One of the person's ComfyUI builds on this computer. */
|
|
276
|
+
export interface ComfyDesktopLocalBuild {
|
|
277
|
+
id: string
|
|
278
|
+
name: string
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* A ComfyUI on this computer, run by Desktop, for a Comfy page hosted in
|
|
282
|
+
* Desktop's Apps view. Desktop exposes it to that page as
|
|
283
|
+
* `window.comfyDesktopLocal`. The page builds and follows its own runs;
|
|
284
|
+
* Desktop finds or starts the ComfyUI, forwards the page's calls to it,
|
|
285
|
+
* downloads a model the page asks for and opens a run's workflow in a ComfyUI
|
|
286
|
+
* window.
|
|
287
|
+
*/
|
|
288
|
+
export interface ComfyDesktopHostedLocalBridge {
|
|
289
|
+
getLocal(want?: ComfyDesktopLocalRequirements): Promise<ComfyDesktopLocalComfy>
|
|
290
|
+
/** Starts the ComfyUI if it is stopped and resolves once it answers, or with the state and `error` if it could not start. */
|
|
291
|
+
startLocal(want?: ComfyDesktopLocalRequirements): Promise<ComfyDesktopLocalComfy>
|
|
292
|
+
/** Rejects when no ComfyUI is running to forward to. */
|
|
293
|
+
localFetch(request: ComfyDesktopLocalRequest): Promise<ComfyDesktopLocalAnswer>
|
|
294
|
+
/** Downloads into the running ComfyUI's models folder and resolves when the file is there. */
|
|
295
|
+
localDownload(model: ComfyDesktopLocalModel): Promise<ComfyDesktopLocalDownload>
|
|
296
|
+
onLocalEvent(callback: (event: ComfyDesktopLocalEvent) => void): () => void
|
|
297
|
+
/**
|
|
298
|
+
* Opens the workflow in a ComfyUI window in Desktop, starting the build or
|
|
299
|
+
* showing its window first if needed, and resolves once ComfyUI has loaded
|
|
300
|
+
* it. Absent on Desktop builds that predate it.
|
|
301
|
+
*/
|
|
302
|
+
openInComfy?(request: ComfyDesktopOpenInComfyRequest): Promise<ComfyDesktopOpenInComfy>
|
|
303
|
+
/** The person's ComfyUI builds on this computer. Absent on Desktop builds that predate it. */
|
|
304
|
+
localBuilds?(): Promise<ComfyDesktopLocalBuild[]>
|
|
305
|
+
}
|
|
190
306
|
export interface ComfyDesktop2TerminalBridge {
|
|
191
307
|
subscribe(installationId?: string): Promise<TerminalRestore>
|
|
192
308
|
unsubscribe(installationId?: string): Promise<void>
|