@comfyorg/comfyui-desktop-bridge-types 0.2.1 → 0.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.
@@ -14,7 +14,61 @@ export interface ComfyDownloadProgress {
14
14
  status: 'pending' | 'downloading' | 'paused' | 'completed' | 'error' | 'cancelled'
15
15
  error?: string
16
16
  isImage?: boolean
17
+ /**
18
+ * The template inputs this transfer serves, named by the host on every
19
+ * event. A retry mints a new job id, and a renderer that dropped the old
20
+ * mapping has no way back to it; naming the inputs here removes the need
21
+ * to correlate by id at all.
22
+ */
23
+ templateInputs?: ComfyTemplateInputReference[]
17
24
  }
25
+ export interface ComfyTemplateInputReference {
26
+ templateId: string
27
+ assetId: string
28
+ }
29
+ export interface ComfyTemplateInputAssetDownload {
30
+ downloadId: string
31
+ filename: string
32
+ progress: number
33
+ receivedBytes?: number
34
+ totalBytes?: number
35
+ status: ComfyDownloadProgress['status']
36
+ error?: string
37
+ }
38
+ export interface ComfyTemplateInputDownloadProgress extends ComfyTemplateInputAssetDownload {
39
+ /** Every template asset currently sharing this managed download job. */
40
+ templateInputs: ComfyTemplateInputReference[]
41
+ }
42
+ export interface ComfyTemplateInputAsset {
43
+ /** Opaque, template-scoped identifier accepted by `downloadTemplateInputAsset`. */
44
+ assetId: string
45
+ filename: string
46
+ mediaType: 'image' | 'video' | 'audio'
47
+ /** Desktop-resolved public URL for previewing this declared template asset. */
48
+ previewUrl: string
49
+ availability: 'present' | 'missing' | 'unknown'
50
+ /** Present when this exact asset destination already has a managed job. */
51
+ activeDownload?: ComfyTemplateInputAssetDownload
52
+ }
53
+ export type ComfyTemplateInputAssetDownloadResult =
54
+ | {
55
+ status: 'already-present'
56
+ /**
57
+ * No job exists for a file that is already on disk, so nothing would
58
+ * report it. Naming it lets the host emit one terminal progress event,
59
+ * which is the only channel a renderer watches.
60
+ */
61
+ filename: string
62
+ }
63
+ | {
64
+ status: 'accepted' | 'joined'
65
+ /** Admission snapshot seeds UI state even if the first IPC event raced ahead. */
66
+ download: ComfyTemplateInputAssetDownload
67
+ }
68
+ | {
69
+ status: 'not-started'
70
+ reason: 'invalid-request' | 'not-declared' | 'unavailable'
71
+ }
18
72
  export interface TerminalRestore {
19
73
  buffer: string[]
20
74
  size: {
@@ -51,6 +105,39 @@ export type ComfyDesktop2FirebaseAuthState =
51
105
  status: 'signed_in'
52
106
  userId: string
53
107
  }
108
+ /**
109
+ * Desktop's own Comfy account session, as the hosted local ComfyUI view sees it.
110
+ * `disabled` means Desktop does not share its session with this view (ops flag
111
+ * off, or the view is not a trusted loopback ComfyUI).
112
+ */
113
+ export type ComfyDesktop2AuthState =
114
+ | {
115
+ status: 'disabled'
116
+ }
117
+ | {
118
+ status: 'signed_out'
119
+ }
120
+ | {
121
+ status: 'signed_in'
122
+ /** Comfy user id (the access token's `sub`), not a Firebase uid. */
123
+ userId: string
124
+ email?: string
125
+ workspaceId?: string
126
+ }
127
+ export interface ComfyDesktop2AuthBridge {
128
+ getState(): Promise<ComfyDesktop2AuthState>
129
+ /** The workspace credential, only for an exact workspace Desktop's session
130
+ * is scoped to; null when signed out, disabled, or the scope is missing,
131
+ * malformed or different. The refresh token never leaves Desktop. */
132
+ getWorkspaceToken(workspaceId: string): Promise<string | null>
133
+ /** Runs Desktop's browser sign-in and resolves with the resulting state. */
134
+ requestSignIn(): Promise<ComfyDesktop2AuthState>
135
+ /** Signs Desktop out of its account (every view follows) and resolves with
136
+ * the resulting state; Desktop may keep the session if an install needs it. */
137
+ signOut(): Promise<ComfyDesktop2AuthState>
138
+ /** Fires when Desktop signs in, signs out or switches workspace. */
139
+ onChanged(callback: (state: ComfyDesktop2AuthState) => void): () => void
140
+ }
54
141
  export interface ComfyDesktop2TerminalBridge {
55
142
  subscribe(installationId?: string): Promise<TerminalRestore>
56
143
  unsubscribe(installationId?: string): Promise<void>
@@ -86,6 +173,19 @@ export interface ComfyDesktop2Bridge {
86
173
  openModelAccessPage?: (url: string) => Promise<boolean>
87
174
  downloadModel?: (url: string, filename: string, directory: string) => Promise<boolean>
88
175
  downloadAsset?: (url: string, filename: string, authToken?: string) => Promise<boolean>
176
+ /** Resolve only assets declared by this template. `null` means Desktop cannot
177
+ * authorize the caller or resolve the metadata; `[]` means the resolved
178
+ * template declares none. */
179
+ getTemplateInputAssets?: (templateId: string) => Promise<ComfyTemplateInputAsset[] | null>
180
+ /** Start or join the managed download for one declared template asset. */
181
+ downloadTemplateInputAsset?: (
182
+ templateId: string,
183
+ assetId: string
184
+ ) => Promise<ComfyTemplateInputAssetDownloadResult>
185
+ /** Download events decorated with the template asset identities that own the job. */
186
+ onTemplateInputDownloadProgress?: (
187
+ callback: (data: ComfyTemplateInputDownloadProgress) => void
188
+ ) => () => void
89
189
  pauseDownload?: (url: string) => Promise<boolean>
90
190
  resumeDownload?: (url: string) => Promise<boolean>
91
191
  cancelDownload?: (url: string) => Promise<boolean>
@@ -94,6 +194,8 @@ export interface ComfyDesktop2Bridge {
94
194
  Terminal?: ComfyDesktop2TerminalBridge
95
195
  Logs?: ComfyDesktop2LogsBridge
96
196
  Telemetry?: ComfyDesktop2TelemetryBridge
197
+ /** Absent on Desktop builds older than this bridge. */
198
+ Auth?: ComfyDesktop2AuthBridge
97
199
  }
98
200
  /**
99
201
  * The `-?` mapper intentionally requires every top-level bridge member.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comfyorg/comfyui-desktop-bridge-types",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript definitions for the Comfy Desktop hosted frontend bridge",
5
5
  "type": "module",
6
6
  "main": "./index.js",