@comfyorg/comfyui-desktop-bridge-types 0.8.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 +35 -0
- package/comfyDesktopBridge.d.ts +92 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,6 +39,41 @@ async function openModelAccessPage(url: string): Promise<void> {
|
|
|
39
39
|
every top-level member required, so Desktop's preload cannot claim the contract
|
|
40
40
|
while omitting part of it.
|
|
41
41
|
|
|
42
|
+
## Comfy pages hosted in Desktop's Apps view
|
|
43
|
+
|
|
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.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import type {
|
|
50
|
+
ComfyDesktopHostedAuthBridge,
|
|
51
|
+
ComfyDesktopHostedLocalBridge
|
|
52
|
+
} from '@comfyorg/comfyui-desktop-bridge-types'
|
|
53
|
+
|
|
54
|
+
declare global {
|
|
55
|
+
interface Window {
|
|
56
|
+
comfyDesktopAuth?: ComfyDesktopHostedAuthBridge
|
|
57
|
+
comfyDesktopLocal?: ComfyDesktopHostedLocalBridge
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The page reads the session with `getState()`, follows it with `onChanged()`,
|
|
63
|
+
asks for the workspace credential with `getWorkspaceToken(workspaceId)` each
|
|
64
|
+
time it calls Comfy Cloud, and starts a sign-in with `requestSignIn()`. It
|
|
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.
|
|
76
|
+
|
|
42
77
|
## Provenance
|
|
43
78
|
|
|
44
79
|
Generated from `src/types/comfyDesktopBridge.ts` in
|
package/comfyDesktopBridge.d.ts
CHANGED
|
@@ -174,6 +174,98 @@ export interface ComfyDesktop2AuthBridge {
|
|
|
174
174
|
amountCents?: number
|
|
175
175
|
): Promise<ComfyDesktop2BillingHandoff>
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Desktop's own Comfy account session, as a Comfy page hosted in Desktop's
|
|
179
|
+
* Apps view sees it. Desktop exposes it to that page as
|
|
180
|
+
* `window.comfyDesktopAuth`. The page can read the session, hold the
|
|
181
|
+
* workspace and partner-node credentials, and start a sign-in; it cannot sign
|
|
182
|
+
* Desktop out or switch workspace.
|
|
183
|
+
*/
|
|
184
|
+
export type ComfyDesktopHostedAuthBridge = Required<
|
|
185
|
+
Pick<
|
|
186
|
+
ComfyDesktop2AuthBridge,
|
|
187
|
+
'getState' | 'getWorkspaceToken' | 'getPartnerNodeToken' | 'requestSignIn' | 'onChanged'
|
|
188
|
+
>
|
|
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
|
+
}
|
|
177
269
|
export interface ComfyDesktop2TerminalBridge {
|
|
178
270
|
subscribe(installationId?: string): Promise<TerminalRestore>
|
|
179
271
|
unsubscribe(installationId?: string): Promise<void>
|