@comfyorg/comfyui-desktop-bridge-types 0.9.0 → 0.10.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 +19 -5
- package/comfyDesktopBridge.d.ts +79 -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,17 @@ 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
|
+
Both objects are absent in a browser, so a page keeps its own sign-in and its
|
|
75
|
+
own way to reach a local ComfyUI as the fallback.
|
|
62
76
|
|
|
63
77
|
## Provenance
|
|
64
78
|
|
package/comfyDesktopBridge.d.ts
CHANGED
|
@@ -187,6 +187,85 @@ 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 ComfyUI on this computer, run by Desktop, for a Comfy page hosted in
|
|
254
|
+
* Desktop's Apps view. Desktop exposes it to that page as
|
|
255
|
+
* `window.comfyDesktopLocal`. The page builds and follows its own runs;
|
|
256
|
+
* Desktop finds or starts the ComfyUI, forwards the page's calls to it and
|
|
257
|
+
* downloads a model the page asks for.
|
|
258
|
+
*/
|
|
259
|
+
export interface ComfyDesktopHostedLocalBridge {
|
|
260
|
+
getLocal(want?: ComfyDesktopLocalRequirements): Promise<ComfyDesktopLocalComfy>
|
|
261
|
+
/** Starts the ComfyUI if it is stopped and resolves once it answers, or with the state and `error` if it could not start. */
|
|
262
|
+
startLocal(want?: ComfyDesktopLocalRequirements): Promise<ComfyDesktopLocalComfy>
|
|
263
|
+
/** Rejects when no ComfyUI is running to forward to. */
|
|
264
|
+
localFetch(request: ComfyDesktopLocalRequest): Promise<ComfyDesktopLocalAnswer>
|
|
265
|
+
/** Downloads into the running ComfyUI's models folder and resolves when the file is there. */
|
|
266
|
+
localDownload(model: ComfyDesktopLocalModel): Promise<ComfyDesktopLocalDownload>
|
|
267
|
+
onLocalEvent(callback: (event: ComfyDesktopLocalEvent) => void): () => void
|
|
268
|
+
}
|
|
190
269
|
export interface ComfyDesktop2TerminalBridge {
|
|
191
270
|
subscribe(installationId?: string): Promise<TerminalRestore>
|
|
192
271
|
unsubscribe(installationId?: string): Promise<void>
|