comfy-ts 2.24.0 → 2.25.1

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.
Files changed (321) hide show
  1. package/dist/chunk-6mgjbrp6.js +579 -0
  2. package/dist/chunk-6mgjbrp6.js.map +17 -0
  3. package/dist/chunk-6tsg7fm5.js +1876 -0
  4. package/dist/chunk-6tsg7fm5.js.map +31 -0
  5. package/dist/chunk-dvxjvwe7.js +2593 -0
  6. package/dist/chunk-dvxjvwe7.js.map +29 -0
  7. package/dist/chunk-dw0t1nye.js +457 -0
  8. package/dist/chunk-dw0t1nye.js.map +16 -0
  9. package/dist/chunk-he70ewwx.js +444 -0
  10. package/dist/chunk-he70ewwx.js.map +13 -0
  11. package/dist/chunk-n22qz0j1.js +6663 -0
  12. package/dist/chunk-n22qz0j1.js.map +95 -0
  13. package/dist/chunk-n35nffm8.js +4777 -0
  14. package/dist/chunk-n35nffm8.js.map +51 -0
  15. package/dist/cli/serve/hostProtocol.d.cts +74 -0
  16. package/dist/cli/serve/hostProtocol.d.ts +74 -0
  17. package/dist/cli/tui-env.d.cts +2 -0
  18. package/dist/cli/tui-env.d.ts +2 -0
  19. package/dist/cli.js +494 -485
  20. package/dist/cli.js.map +16 -1
  21. package/dist/coreExports.d.cts +45 -0
  22. package/dist/coreExports.d.ts +45 -0
  23. package/dist/errors/InvalidPromptError.d.cts +10 -0
  24. package/dist/errors/InvalidPromptError.d.ts +10 -0
  25. package/dist/exampleAssets.d.cts +24 -0
  26. package/dist/exampleAssets.d.ts +24 -0
  27. package/dist/graph/ComfyNode.d.cts +109 -0
  28. package/dist/graph/ComfyNode.d.ts +109 -0
  29. package/dist/graph/ComfyNodeID.d.cts +15 -0
  30. package/dist/graph/ComfyNodeID.d.ts +15 -0
  31. package/dist/graph/ComfyNodeOutput.d.cts +21 -0
  32. package/dist/graph/ComfyNodeOutput.d.ts +21 -0
  33. package/dist/graph/NodeSlotSize.d.cts +4 -0
  34. package/dist/graph/NodeSlotSize.d.ts +4 -0
  35. package/dist/graph/autoValue.d.cts +16 -0
  36. package/dist/graph/autoValue.d.ts +16 -0
  37. package/dist/host/ComfyHost.d.cts +383 -0
  38. package/dist/host/ComfyHost.d.ts +383 -0
  39. package/dist/host/ComfyInstallType.d.cts +11 -0
  40. package/dist/host/ComfyInstallType.d.ts +11 -0
  41. package/dist/host/ComfyManager.d.cts +152 -0
  42. package/dist/host/ComfyManager.d.ts +152 -0
  43. package/dist/host/ComfyUploader.d.cts +42 -0
  44. package/dist/host/ComfyUploader.d.ts +42 -0
  45. package/dist/host/ComfyWorkflowBuilder.d.cts +19 -0
  46. package/dist/host/ComfyWorkflowBuilder.d.ts +19 -0
  47. package/dist/host/Requirements.d.cts +43 -0
  48. package/dist/host/Requirements.d.ts +43 -0
  49. package/dist/host/ResilientWebsocket.d.cts +122 -0
  50. package/dist/host/ResilientWebsocket.d.ts +122 -0
  51. package/dist/host/hostFile.d.cts +23 -0
  52. package/dist/host/hostFile.d.ts +23 -0
  53. package/dist/host/hostUrl.d.cts +22 -0
  54. package/dist/host/hostUrl.d.ts +22 -0
  55. package/dist/host/leastBusy.d.cts +9 -0
  56. package/dist/host/leastBusy.d.ts +9 -0
  57. package/dist/host/loraInfoCache.d.cts +110 -0
  58. package/dist/host/loraInfoCache.d.ts +110 -0
  59. package/dist/host/loraManagerApi.d.cts +106 -0
  60. package/dist/host/loraManagerApi.d.ts +106 -0
  61. package/dist/host/previewMethod.d.cts +5 -0
  62. package/dist/host/previewMethod.d.ts +5 -0
  63. package/dist/host/schemaDrift.d.cts +54 -0
  64. package/dist/host/schemaDrift.d.ts +54 -0
  65. package/dist/image-utils/_getPngMetadata.d.cts +5 -0
  66. package/dist/image-utils/_getPngMetadata.d.ts +5 -0
  67. package/dist/index.cjs +8197 -8509
  68. package/dist/index.cjs.map +124 -1
  69. package/dist/index.d.cts +4 -19116
  70. package/dist/index.d.ts +4 -19116
  71. package/dist/index.js +8129 -8390
  72. package/dist/index.js.map +124 -1
  73. package/dist/litegraph/CanonicalWorkflow.d.cts +75 -0
  74. package/dist/litegraph/CanonicalWorkflow.d.ts +75 -0
  75. package/dist/litegraph/LiteGraphGroup.d.cts +17 -0
  76. package/dist/litegraph/LiteGraphGroup.d.ts +17 -0
  77. package/dist/litegraph/LiteGraphJSON.d.cts +242 -0
  78. package/dist/litegraph/LiteGraphJSON.d.ts +242 -0
  79. package/dist/litegraph/LiteGraphLink.d.cts +48 -0
  80. package/dist/litegraph/LiteGraphLink.d.ts +48 -0
  81. package/dist/litegraph/LiteGraphLinkID.d.cts +6 -0
  82. package/dist/litegraph/LiteGraphLinkID.d.ts +6 -0
  83. package/dist/litegraph/LiteGraphNode.d.cts +76 -0
  84. package/dist/litegraph/LiteGraphNode.d.ts +76 -0
  85. package/dist/litegraph/LiteGraphNodeInput.d.cts +25 -0
  86. package/dist/litegraph/LiteGraphNodeInput.d.ts +25 -0
  87. package/dist/litegraph/LiteGraphNodeOutput.d.cts +20 -0
  88. package/dist/litegraph/LiteGraphNodeOutput.d.ts +20 -0
  89. package/dist/litegraph/LiteGraphSlotIndex.d.cts +6 -0
  90. package/dist/litegraph/LiteGraphSlotIndex.d.ts +6 -0
  91. package/dist/litegraph/LiteGraphSubgraphDef.d.cts +174 -0
  92. package/dist/litegraph/LiteGraphSubgraphDef.d.ts +174 -0
  93. package/dist/litegraph/convertFlowToLiteGraphJSON.d.cts +12 -0
  94. package/dist/litegraph/convertFlowToLiteGraphJSON.d.ts +12 -0
  95. package/dist/litegraph/expandSubgraphs.d.cts +27 -0
  96. package/dist/litegraph/expandSubgraphs.d.ts +27 -0
  97. package/dist/litegraph/normalizeWorkflow.d.cts +21 -0
  98. package/dist/litegraph/normalizeWorkflow.d.ts +21 -0
  99. package/dist/manager/ComfyRegistry.d.cts +54 -0
  100. package/dist/manager/ComfyRegistry.d.ts +54 -0
  101. package/dist/manager/generated/KnownComfyCustomNodeName.d.cts +1 -0
  102. package/dist/manager/generated/KnownComfyCustomNodeName.d.ts +1 -0
  103. package/dist/manager/generated/KnownComfyPluginTitle.d.cts +12109 -0
  104. package/dist/manager/generated/KnownComfyPluginTitle.d.ts +12109 -0
  105. package/dist/manager/generated/KnownComfyPluginURL.d.cts +1 -0
  106. package/dist/manager/generated/KnownComfyPluginURL.d.ts +1 -0
  107. package/dist/manager/generated/KnownModel_Base.d.cts +2 -0
  108. package/dist/manager/generated/KnownModel_Base.d.ts +2 -0
  109. package/dist/manager/generated/KnownModel_Name.d.cts +2842 -0
  110. package/dist/manager/generated/KnownModel_Name.d.ts +2842 -0
  111. package/dist/manager/generated/KnownModel_SavePath.d.cts +2 -0
  112. package/dist/manager/generated/KnownModel_SavePath.d.ts +2 -0
  113. package/dist/manager/generated/KnownModel_Type.d.cts +2 -0
  114. package/dist/manager/generated/KnownModel_Type.d.ts +2 -0
  115. package/dist/manager/installedView.d.cts +65 -0
  116. package/dist/manager/installedView.d.ts +65 -0
  117. package/dist/manager/json/custom-node-list.extra.d.cts +2 -0
  118. package/dist/manager/json/custom-node-list.extra.d.ts +2 -0
  119. package/dist/manager/json/model-list.extra.d.cts +2 -0
  120. package/dist/manager/json/model-list.extra.d.ts +2 -0
  121. package/dist/manager/loaders/parseReport.d.cts +24 -0
  122. package/dist/manager/loaders/parseReport.d.ts +24 -0
  123. package/dist/manager/loaders/step1_downloadComfyManagerJSONs.d.cts +1 -0
  124. package/dist/manager/loaders/step1_downloadComfyManagerJSONs.d.ts +1 -0
  125. package/dist/manager/loaders/step2_custom-node-list-loader.d.cts +2 -0
  126. package/dist/manager/loaders/step2_custom-node-list-loader.d.ts +2 -0
  127. package/dist/manager/loaders/step3_extension-node-map-loader.d.cts +2 -0
  128. package/dist/manager/loaders/step3_extension-node-map-loader.d.ts +2 -0
  129. package/dist/manager/loaders/step4_model-list-loader.d.cts +2 -0
  130. package/dist/manager/loaders/step4_model-list-loader.d.ts +2 -0
  131. package/dist/manager/loaders/step5_alter-list-loader.d.cts +2 -0
  132. package/dist/manager/loaders/step5_alter-list-loader.d.ts +2 -0
  133. package/dist/manager/loaders/step6_github-stats-loader.d.cts +2 -0
  134. package/dist/manager/loaders/step6_github-stats-loader.d.ts +2 -0
  135. package/dist/manager/types/ComfyManagerAPIFetchPolicy.d.cts +7 -0
  136. package/dist/manager/types/ComfyManagerAPIFetchPolicy.d.ts +7 -0
  137. package/dist/manager/types/ComfyManagerAPIModelList.d.cts +10 -0
  138. package/dist/manager/types/ComfyManagerAPIModelList.d.ts +10 -0
  139. package/dist/manager/types/ComfyManagerAPIPluginList.d.cts +33 -0
  140. package/dist/manager/types/ComfyManagerAPIPluginList.d.ts +33 -0
  141. package/dist/manager/types/ComfyManagerAlterInfo.d.cts +12 -0
  142. package/dist/manager/types/ComfyManagerAlterInfo.d.ts +12 -0
  143. package/dist/manager/types/ComfyManagerFileModelInfo.d.cts +10 -0
  144. package/dist/manager/types/ComfyManagerFileModelInfo.d.ts +10 -0
  145. package/dist/manager/types/ComfyManagerFilePluginContent.d.cts +11 -0
  146. package/dist/manager/types/ComfyManagerFilePluginContent.d.ts +11 -0
  147. package/dist/manager/types/ComfyManagerFilePluginList.d.cts +5 -0
  148. package/dist/manager/types/ComfyManagerFilePluginList.d.ts +5 -0
  149. package/dist/manager/types/ComfyManagerGithubStats.d.cts +7 -0
  150. package/dist/manager/types/ComfyManagerGithubStats.d.ts +7 -0
  151. package/dist/manager/types/ComfyManagerModelInfo.d.cts +12 -0
  152. package/dist/manager/types/ComfyManagerModelInfo.d.ts +12 -0
  153. package/dist/manager/types/ComfyManagerPluginContentMetadata.d.cts +10 -0
  154. package/dist/manager/types/ComfyManagerPluginContentMetadata.d.ts +10 -0
  155. package/dist/manager/types/ComfyManagerPluginEnums.d.cts +5 -0
  156. package/dist/manager/types/ComfyManagerPluginEnums.d.ts +5 -0
  157. package/dist/manager/types/ComfyManagerPluginInfo.d.cts +54 -0
  158. package/dist/manager/types/ComfyManagerPluginInfo.d.ts +54 -0
  159. package/dist/promptEnhancers.d.cts +22 -0
  160. package/dist/promptEnhancers.d.ts +22 -0
  161. package/dist/runner/ComfyExecution.d.cts +230 -0
  162. package/dist/runner/ComfyExecution.d.ts +230 -0
  163. package/dist/runner/ComfyExecutionStatus.d.cts +1 -0
  164. package/dist/runner/ComfyExecutionStatus.d.ts +1 -0
  165. package/dist/runner/ComfyWorkflow.d.cts +141 -0
  166. package/dist/runner/ComfyWorkflow.d.ts +141 -0
  167. package/dist/runner/ComfyWorkflowLayout.d.cts +17 -0
  168. package/dist/runner/ComfyWorkflowLayout.d.ts +17 -0
  169. package/dist/runner/ComfyWsApi.d.cts +2174 -0
  170. package/dist/runner/ComfyWsApi.d.ts +2174 -0
  171. package/dist/runner/MediaImage.d.cts +127 -0
  172. package/dist/runner/MediaImage.d.ts +127 -0
  173. package/dist/runner/comfyOrgApiKey.d.cts +21 -0
  174. package/dist/runner/comfyOrgApiKey.d.ts +21 -0
  175. package/dist/runner/describePromptRejection.d.cts +1 -0
  176. package/dist/runner/describePromptRejection.d.ts +1 -0
  177. package/dist/runner/ephemeral.d.cts +10 -0
  178. package/dist/runner/ephemeral.d.ts +10 -0
  179. package/dist/runner/historyReplay.d.cts +13 -0
  180. package/dist/runner/historyReplay.d.ts +13 -0
  181. package/dist/runner/mediaKinds.d.cts +7 -0
  182. package/dist/runner/mediaKinds.d.ts +7 -0
  183. package/dist/runner/outputPath.d.cts +40 -0
  184. package/dist/runner/outputPath.d.ts +40 -0
  185. package/dist/runner/outputs3d.d.cts +3 -0
  186. package/dist/runner/outputs3d.d.ts +3 -0
  187. package/dist/runner/wsBinaryFrame.d.cts +25 -0
  188. package/dist/runner/wsBinaryFrame.d.ts +25 -0
  189. package/dist/sdk-generator/ComfyNodeSchema.d.cts +25 -0
  190. package/dist/sdk-generator/ComfyNodeSchema.d.ts +25 -0
  191. package/dist/sdk-generator/ComfySchema.d.cts +74 -0
  192. package/dist/sdk-generator/ComfySchema.d.ts +74 -0
  193. package/dist/sdk-generator/ComfyUIObjectInfoTypes.d.cts +3072 -0
  194. package/dist/sdk-generator/ComfyUIObjectInfoTypes.d.ts +3072 -0
  195. package/dist/sdk-generator/Primitives.d.cts +12 -0
  196. package/dist/sdk-generator/Primitives.d.ts +12 -0
  197. package/dist/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.d.cts +2 -0
  198. package/dist/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.d.ts +2 -0
  199. package/dist/sdk-generator/_pythonModuleToNamespace.d.cts +1 -0
  200. package/dist/sdk-generator/_pythonModuleToNamespace.d.ts +1 -0
  201. package/dist/sdk-generator/_toQualifiedNodeKey.d.cts +1 -0
  202. package/dist/sdk-generator/_toQualifiedNodeKey.d.ts +1 -0
  203. package/dist/sdk-generator/comfy-api-json.d.cts +16 -0
  204. package/dist/sdk-generator/comfy-api-json.d.ts +16 -0
  205. package/dist/sdk-generator/comfyui-sdk-codegen.d.cts +23 -0
  206. package/dist/sdk-generator/comfyui-sdk-codegen.d.ts +23 -0
  207. package/dist/sdk-generator/comfyui-types.d.cts +55 -0
  208. package/dist/sdk-generator/comfyui-types.d.ts +55 -0
  209. package/dist/sdk-generator/inputWidgetKind.d.cts +80 -0
  210. package/dist/sdk-generator/inputWidgetKind.d.ts +80 -0
  211. package/dist/sdk-generator/litegraphToApiRequestPayload.d.cts +41 -0
  212. package/dist/sdk-generator/litegraphToApiRequestPayload.d.ts +41 -0
  213. package/dist/serve-web.js +51 -51
  214. package/dist/ssh-host-manager/ssh-config-manager.d.cts +17 -0
  215. package/dist/ssh-host-manager/ssh-config-manager.d.ts +17 -0
  216. package/dist/state.d.cts +80 -0
  217. package/dist/state.d.ts +80 -0
  218. package/dist/storage/ComfyStorage.d.cts +55 -0
  219. package/dist/storage/ComfyStorage.d.ts +55 -0
  220. package/dist/storage/nodeStorage.d.cts +2 -0
  221. package/dist/storage/nodeStorage.d.ts +2 -0
  222. package/dist/types/comfy-sdk.d.cts +85 -0
  223. package/dist/types/comfy-sdk.d.ts +85 -0
  224. package/dist/types/index.d.cts +65 -0
  225. package/dist/types/index.d.ts +65 -0
  226. package/dist/utils/CodeBuffer.d.cts +20 -0
  227. package/dist/utils/CodeBuffer.d.ts +20 -0
  228. package/dist/utils/ComfyColors.d.cts +14 -0
  229. package/dist/utils/ComfyColors.d.ts +14 -0
  230. package/dist/utils/ansi.d.cts +22 -0
  231. package/dist/utils/ansi.d.ts +22 -0
  232. package/dist/utils/bang.d.cts +9 -0
  233. package/dist/utils/bang.d.ts +9 -0
  234. package/dist/utils/deepCopyNaive.d.cts +1 -0
  235. package/dist/utils/deepCopyNaive.d.ts +1 -0
  236. package/dist/utils/downloadFile.d.cts +2 -0
  237. package/dist/utils/downloadFile.d.ts +2 -0
  238. package/dist/utils/escapeJSKey.d.cts +2 -0
  239. package/dist/utils/escapeJSKey.d.ts +2 -0
  240. package/dist/utils/exhaust.d.cts +1 -0
  241. package/dist/utils/exhaust.d.ts +1 -0
  242. package/dist/utils/extractErrorMessage.d.cts +2 -0
  243. package/dist/utils/extractErrorMessage.d.ts +2 -0
  244. package/dist/utils/githubRegexes.d.cts +2 -0
  245. package/dist/utils/githubRegexes.d.ts +2 -0
  246. package/dist/utils/hashArrayBuffer.d.cts +1 -0
  247. package/dist/utils/hashArrayBuffer.d.ts +1 -0
  248. package/dist/utils/isRecord.d.cts +2 -0
  249. package/dist/utils/isRecord.d.ts +2 -0
  250. package/dist/utils/lazySharp.d.cts +3 -0
  251. package/dist/utils/lazySharp.d.ts +3 -0
  252. package/dist/utils/log.d.cts +4 -0
  253. package/dist/utils/log.d.ts +4 -0
  254. package/dist/utils/loraTag.d.cts +8 -0
  255. package/dist/utils/loraTag.d.ts +8 -0
  256. package/dist/utils/matchesRegex.d.cts +2 -0
  257. package/dist/utils/matchesRegex.d.ts +2 -0
  258. package/dist/utils/printArkResultInConsole.d.cts +2 -0
  259. package/dist/utils/printArkResultInConsole.d.ts +2 -0
  260. package/dist/utils/safeName.d.cts +6 -0
  261. package/dist/utils/safeName.d.ts +6 -0
  262. package/dist/utils/sha1.d.cts +2 -0
  263. package/dist/utils/sha1.d.ts +2 -0
  264. package/dist/utils/softValidate.d.cts +2 -0
  265. package/dist/utils/softValidate.d.ts +2 -0
  266. package/dist/utils/stringifyReadable.d.cts +1 -0
  267. package/dist/utils/stringifyReadable.d.ts +1 -0
  268. package/dist/utils/toposort.d.cts +3 -0
  269. package/dist/utils/toposort.d.ts +3 -0
  270. package/dist/vars/ComfyVars.d.cts +607 -0
  271. package/dist/vars/ComfyVars.d.ts +607 -0
  272. package/dist/vars/DefinedWorkflow.d.cts +104 -0
  273. package/dist/vars/DefinedWorkflow.d.ts +104 -0
  274. package/dist/vars/lanes.d.cts +81 -0
  275. package/dist/vars/lanes.d.ts +81 -0
  276. package/dist/vars/loraEntry.d.cts +26 -0
  277. package/dist/vars/loraEntry.d.ts +26 -0
  278. package/dist/vars/loraKeywords.d.cts +19 -0
  279. package/dist/vars/loraKeywords.d.ts +19 -0
  280. package/dist/vars/outputWidgets.d.cts +33 -0
  281. package/dist/vars/outputWidgets.d.ts +33 -0
  282. package/dist/vars/presets.d.cts +9 -0
  283. package/dist/vars/presets.d.ts +9 -0
  284. package/dist/vars/promptSyntax.d.cts +98 -0
  285. package/dist/vars/promptSyntax.d.ts +98 -0
  286. package/dist/web.d.cts +2 -0
  287. package/dist/web.d.ts +2 -19160
  288. package/dist/web.js +8040 -8292
  289. package/dist/web.js.map +119 -1
  290. package/examples/depth-explorer/web/tsconfig.json +1 -2
  291. package/examples/upscale-explorer/web/tsconfig.json +1 -2
  292. package/examples/web/tsconfig.json +1 -4
  293. package/examples/world-explorer/web/tsconfig.json +1 -2
  294. package/package.json +27 -32
  295. package/src/cli/serve/web/components/SideMenu.tsx +1 -1
  296. package/src/cli/serve/web/components/controls/LorasControl.tsx +2 -0
  297. package/src/cli/serve/web/components/controls/RichSelect.tsx +1 -0
  298. package/src/cli/serve/web/state/RunSt.poll.test.ts +2 -1
  299. package/src/cli/serve/web/tsconfig.json +1 -2
  300. package/src/cli/serve/web/widgets/RelightWidget.tsx +1 -0
  301. package/src/cli/tui/state/HostSt.ts +1 -1
  302. package/src/host/loraManagerApi.ts +8 -3
  303. package/src/runner/ComfyExecution.ts +3 -1
  304. package/src/runner/ComfyWsApi.ts +2 -1
  305. package/src/storage/ComfyStorage.ts +5 -4
  306. package/src/types/comfy-sdk.ts +1 -0
  307. package/src/utils/ansi.ts +1 -0
  308. package/dist/ServeApp-fsHtW5zG.js +0 -2689
  309. package/dist/ServeApp-fsHtW5zG.js.map +0 -1
  310. package/dist/exampleAssets-DZynSkZm.js +0 -6674
  311. package/dist/exampleAssets-DZynSkZm.js.map +0 -1
  312. package/dist/findDefinedWorkflow-qyqFea7q.js +0 -625
  313. package/dist/findDefinedWorkflow-qyqFea7q.js.map +0 -1
  314. package/dist/run-run-Cn2JzKlE.js +0 -449
  315. package/dist/run-run-Cn2JzKlE.js.map +0 -1
  316. package/dist/run-serve-BhGegaCI.js +0 -464
  317. package/dist/run-serve-BhGegaCI.js.map +0 -1
  318. package/dist/run-tui-CrM4ijkH.js +0 -4569
  319. package/dist/run-tui-CrM4ijkH.js.map +0 -1
  320. package/dist/schemaDrift-BGYJZGMD.js +0 -2225
  321. package/dist/schemaDrift-BGYJZGMD.js.map +0 -1
@@ -0,0 +1,152 @@
1
+ /** 🔶 NAMING DISCLAIMER: I call a "custom node package" => "PLUGIN" */
2
+ import type { ComfyRegistry } from '../manager/ComfyRegistry.js';
3
+ import type { KnownComfyPluginTitle } from '../manager/generated/KnownComfyPluginTitle.js';
4
+ import type { KnownModel_Name } from '../manager/generated/KnownModel_Name.js';
5
+ import { type ManagerMirror } from '../manager/installedView.js';
6
+ import type { ComfyManagerAPIFetchPolicy } from '../manager/types/ComfyManagerAPIFetchPolicy.js';
7
+ import { type ComfyManagerAPIModelList } from '../manager/types/ComfyManagerAPIModelList.js';
8
+ import { type ComfyManagerAPIPluginList } from '../manager/types/ComfyManagerAPIPluginList.js';
9
+ import type { ComfyManagerModelInfo } from '../manager/types/ComfyManagerModelInfo.js';
10
+ import type { ComfyManagerPluginInfo } from '../manager/types/ComfyManagerPluginInfo.js';
11
+ import type { Maybe } from '../types/index.js';
12
+ import type { PluginInstallStatus, Requirements } from './Requirements.js';
13
+ /**
14
+ * the three ComfyUI-Manager servers in the field (agent/architecture.md, Manager HTTP client):
15
+ * `v3` the legacy custom node (bare routes), `v4-legacy-ui` the pip package under
16
+ * `--enable-manager-legacy-ui` (/v2), `v4` the pip package with its default ui (/v2, no lists)
17
+ */
18
+ export type ManagerGeneration = 'v3' | 'v4-legacy-ui' | 'v4';
19
+ export type ManagerApi = {
20
+ generation: ManagerGeneration;
21
+ version: string;
22
+ };
23
+ /** install waits poll the queue; `pollGraceMs`: how long the poll survives a host that does not answer */
24
+ export type ManagerTiming = {
25
+ pollMs: number;
26
+ installTimeoutMs: number;
27
+ pollGraceMs: number;
28
+ };
29
+ export declare const MANAGER_TIMING: ManagerTiming;
30
+ /** `unknown`: we lost sight of the task, the Manager may still be installing (agent/architecture.md) */
31
+ export type InstallOutcome = 'installed' | 'failed' | 'unknown';
32
+ export declare class ComfyManager {
33
+ host: {
34
+ getServerHostHTTP: () => string;
35
+ fetch: (route: string, init?: RequestInit, p?: {
36
+ apiPrefix?: boolean;
37
+ }) => Promise<Response>;
38
+ };
39
+ timing: ManagerTiming;
40
+ /** the mirror the lists are joined to; the registry by default */
41
+ mirror: () => ManagerMirror;
42
+ constructor(host: {
43
+ getServerHostHTTP: () => string;
44
+ fetch: (route: string, init?: RequestInit, p?: {
45
+ apiPrefix?: boolean;
46
+ }) => Promise<Response>;
47
+ }, timing?: ManagerTiming,
48
+ /** the mirror the lists are joined to; the registry by default */
49
+ mirror?: () => ManagerMirror);
50
+ get registry(): ComfyRegistry;
51
+ /** identifies install tasks of this client in the Manager queue (4.x requires one) */
52
+ readonly clientId: string;
53
+ private _api;
54
+ /** which Manager answers: probed once, remembered, forgotten on failure and on reboot */
55
+ api: () => Promise<ManagerApi>;
56
+ private probeApi;
57
+ /** the one place a Manager route gets its generation's spelling */
58
+ private route;
59
+ /** the one place the generations differ beyond a route's spelling */
60
+ private strategy;
61
+ configureLogging: (mi: boolean) => Promise<string>;
62
+ getModelInfoFinalFilePath: (mi: ComfyManagerModelInfo) => string;
63
+ waitForHostToBeBackOnline(maxAttempt: 10): Promise<true>;
64
+ rebootComfyUIAndUpdateHostPluginsAndModelsAfter10Seconds(): Promise<void>;
65
+ /**
66
+ * reboot the ComfyUI process (ComfyUI-Manager).
67
+ *
68
+ * The server dies mid-request, so a DROPPED CONNECTION is the success shape and the only
69
+ * one most callers ever see. A 404 is not: the route is POST from Manager V3 on, and a GET
70
+ * there answers 404 while the process keeps running. Both verbs are tried so a pre-V3
71
+ * Manager still reboots, and anything that is neither a disconnect nor a 404 throws with
72
+ * what the host actually said. The process may come back with another Manager, so the
73
+ * remembered generation is dropped.
74
+ */
75
+ restartComfyUI: () => Promise<void>;
76
+ fetchPluginsAndModels: () => Promise<void>;
77
+ modelList: Maybe<ComfyManagerAPIModelList>;
78
+ /** what the host has of our model mirror; a model absent from the list reads `unknown` */
79
+ fetchModels: () => Promise<ComfyManagerAPIModelList>;
80
+ fetchLogs: () => Promise<any>;
81
+ /** true only for a KNOWN install: false is "not known to be installed" (missing OR undecided), see `getModelStatus` */
82
+ isModelInstalled: (name: KnownModel_Name) => boolean;
83
+ modelsBeeingInstalled: Set<KnownModel_Name>;
84
+ /** queue the install, wait until the Manager ran it; true only once the model is verified installed (`installModelOutcome` tells failed from unknown) */
85
+ installModel: (model: ComfyManagerModelInfo) => Promise<boolean>;
86
+ installModelOutcome: (model: ComfyManagerModelInfo) => Promise<InstallOutcome>;
87
+ getModelStatus: (modelName: KnownModel_Name) => PluginInstallStatus;
88
+ /**
89
+ * you need to call `fetchPluginList()` to populate this field
90
+ */
91
+ pluginList: Maybe<ComfyManagerAPIPluginList>;
92
+ get titlesOfAllInstalledPlugins(): KnownComfyPluginTitle[];
93
+ /** true only for a KNOWN install: false is "not known to be installed" (missing OR undecided), see `getPluginStatus` */
94
+ isPluginInstalled: (title: KnownComfyPluginTitle) => boolean;
95
+ getPluginStatus: (title: KnownComfyPluginTitle) => PluginInstallStatus;
96
+ /** one requirement against the fetched lists; `unknown` when they cannot say, null when the mirror does not know it */
97
+ requirementStatus: (req: Requirements) => PluginInstallStatus | null;
98
+ /** `missing`: known not installed, the only requirements an install flow may queue; `undecided`: the lists cannot say */
99
+ checkRequirements: (requirements: Requirements[]) => {
100
+ missing: Requirements[];
101
+ undecided: Requirements[];
102
+ };
103
+ /** false only when a requirement is known missing; an undecided one passes with a warning */
104
+ matchRequirements: (requirements: Requirements[]) => boolean;
105
+ /** the host's plugin list in the public `custom_nodes` shape, titled like our mirror; absent = `unknown` */
106
+ fetchPlugins: (
107
+ /** @default: 'cache' */
108
+ mode?: ComfyManagerAPIFetchPolicy,
109
+ /** @default: true */
110
+ skipUpdate?: boolean) => Promise<ComfyManagerAPIPluginList>;
111
+ /** queue the install, wait until the Manager ran it; true only once the pack is verified installed (`installPluginOutcome` tells failed from unknown) */
112
+ installPlugin: (plugin: ComfyManagerPluginInfo) => Promise<boolean>;
113
+ installPluginOutcome: (plugin: ComfyManagerPluginInfo) => Promise<InstallOutcome>;
114
+ /** the Manager's own getlist (v3, v4 legacy ui), normalized */
115
+ private listedPlugins;
116
+ private fetchPluginWire;
117
+ private listedModels;
118
+ /** what is installed, as the Manager scans it, joined through its own registry id mappings */
119
+ private installedData;
120
+ /** v4 serves no list: our mirror against what is installed */
121
+ private installedPluginView;
122
+ /** v4 serves no model list: core ComfyUI's model folders against our mirror */
123
+ private installedModelView;
124
+ /** v3 and v4 legacy ui: the Manager's own list row for the pack, sent like its own ui does */
125
+ private enqueueListedPlugin;
126
+ /** v4: no list to take a row from, so the pack goes by repo name at nightly; resolves with that id */
127
+ private enqueuePluginTask;
128
+ /** v4: the task's own history entry says how it ended; the end state confirms a success */
129
+ private settleByHistory;
130
+ /**
131
+ * a worker lingers a few seconds after a drain, then exits; a start in that window answers 201
132
+ * "already running" and leaves the new task pending with no worker (seen live on 4.2.2, same loop
133
+ * in V3 and 4.4). So an idle queue that still holds work is started again.
134
+ */
135
+ private restartIdleQueue;
136
+ /** v3, v4 legacy ui: no per item result over http, so wait for the drain and look at the end state */
137
+ private settleByDrain;
138
+ /** the end state after the task ran: a host that does not answer here leaves the outcome unknown */
139
+ private endState;
140
+ private runInstall;
141
+ /**
142
+ * poll until `check` gives a value. A failed request is a blip: logged, and the poll goes on until
143
+ * `timing.pollGraceMs` passes without one good answer. Giving up, or the deadline, is an UNKNOWN
144
+ * outcome (the task may still run); only an `InstallFailed` from `check` ends the wait as a failure.
145
+ */
146
+ private waitFor;
147
+ /** json POST (the Manager's csrf guard refuses simple form types); the reply json, or null when empty */
148
+ private post;
149
+ private getJSON;
150
+ /** a GET whose shape the decision depends on: a mismatch throws instead of lying */
151
+ private getValid;
152
+ }
@@ -0,0 +1,42 @@
1
+ import type { ComfyImageName } from '../sdk-generator/comfyui-types.cjs';
2
+ import type { MediaImage } from '../runner/MediaImage.cjs';
3
+ import type { Maybe } from '../types/index.cjs';
4
+ import type { ComfyHost } from './ComfyHost.cjs';
5
+ export type ComfyUploadImageResult = {
6
+ name: ComfyImageName;
7
+ subfolder: string;
8
+ type: string;
9
+ };
10
+ export declare const ComfyUploadImageResult_ark: import("arktype/internal/variants/object.ts").ObjectType<{
11
+ name: ComfyImageName;
12
+ subfolder: string;
13
+ type: string;
14
+ }, {}>;
15
+ /** all those functions are kinda legacy */
16
+ export declare class ComfyUploader {
17
+ host: ComfyHost;
18
+ constructor(host: ComfyHost);
19
+ /** names this process already uploaded to this host: a LoadAudio or LoadVideo list is not
20
+ * reloaded after an upload, so without it every run re-sent the same file */
21
+ private uploaded;
22
+ /** upload an image (hash-named, deduped against the host's LoadImage list) */
23
+ uploadImage: (img: MediaImage, p: {
24
+ type?: Maybe<'input' | 'temp' | 'output'>;
25
+ override?: Maybe<boolean>;
26
+ subfolder?: string;
27
+ }) => Promise<ComfyImageName>;
28
+ /**
29
+ * THE upload path: any file a loader node reads from the host's input folder. ComfyUI routes
30
+ * audio and video through `/upload/image` too. `slot` is the loader input whose value list
31
+ * says the file is already there (`LoadImage.image`, `LoadAudio.audio`, `LoadVideo.file`)
32
+ */
33
+ uploadInput: (p: {
34
+ blob: Blob;
35
+ /** the name the file should get on the host, hash-derived by callers so reruns dedupe */
36
+ name: string;
37
+ slot: string;
38
+ type?: Maybe<'input' | 'temp' | 'output'>;
39
+ override?: Maybe<boolean>;
40
+ subfolder?: string;
41
+ }) => Promise<string>;
42
+ }
@@ -0,0 +1,42 @@
1
+ import type { ComfyImageName } from '../sdk-generator/comfyui-types.js';
2
+ import type { MediaImage } from '../runner/MediaImage.js';
3
+ import type { Maybe } from '../types/index.js';
4
+ import type { ComfyHost } from './ComfyHost.js';
5
+ export type ComfyUploadImageResult = {
6
+ name: ComfyImageName;
7
+ subfolder: string;
8
+ type: string;
9
+ };
10
+ export declare const ComfyUploadImageResult_ark: import("arktype/internal/variants/object.ts").ObjectType<{
11
+ name: ComfyImageName;
12
+ subfolder: string;
13
+ type: string;
14
+ }, {}>;
15
+ /** all those functions are kinda legacy */
16
+ export declare class ComfyUploader {
17
+ host: ComfyHost;
18
+ constructor(host: ComfyHost);
19
+ /** names this process already uploaded to this host: a LoadAudio or LoadVideo list is not
20
+ * reloaded after an upload, so without it every run re-sent the same file */
21
+ private uploaded;
22
+ /** upload an image (hash-named, deduped against the host's LoadImage list) */
23
+ uploadImage: (img: MediaImage, p: {
24
+ type?: Maybe<'input' | 'temp' | 'output'>;
25
+ override?: Maybe<boolean>;
26
+ subfolder?: string;
27
+ }) => Promise<ComfyImageName>;
28
+ /**
29
+ * THE upload path: any file a loader node reads from the host's input folder. ComfyUI routes
30
+ * audio and video through `/upload/image` too. `slot` is the loader input whose value list
31
+ * says the file is already there (`LoadImage.image`, `LoadAudio.audio`, `LoadVideo.file`)
32
+ */
33
+ uploadInput: (p: {
34
+ blob: Blob;
35
+ /** the name the file should get on the host, hash-derived by callers so reruns dedupe */
36
+ name: string;
37
+ slot: string;
38
+ type?: Maybe<'input' | 'temp' | 'output'>;
39
+ override?: Maybe<boolean>;
40
+ subfolder?: string;
41
+ }) => Promise<string>;
42
+ }
@@ -0,0 +1,19 @@
1
+ import type { ComfyWorkflow } from '../runner/ComfyWorkflow.cjs';
2
+ /**
3
+ * runtime builder: one factory method per node of the live schema, defined
4
+ * dynamically. The typed face is `SdkForHost<ID>['Builder']`, obtained via
5
+ * `workflow.builder` (see ComfyWorkflow). The index signature below is what
6
+ * makes the cast between the two legal.
7
+ */
8
+ export interface ComfyWorkflowBuilder {
9
+ [nodeName: string]: unknown;
10
+ }
11
+ export declare class ComfyWorkflowBuilder {
12
+ graph: ComfyWorkflow;
13
+ constructor(graph: ComfyWorkflow);
14
+ /**
15
+ * helper function to allocate an unique node Id while
16
+ * while respecting user provided metadata id if present.
17
+ */
18
+ private ___allocateNodeUID;
19
+ }
@@ -0,0 +1,19 @@
1
+ import type { ComfyWorkflow } from '../runner/ComfyWorkflow.js';
2
+ /**
3
+ * runtime builder: one factory method per node of the live schema, defined
4
+ * dynamically. The typed face is `SdkForHost<ID>['Builder']`, obtained via
5
+ * `workflow.builder` (see ComfyWorkflow). The index signature below is what
6
+ * makes the cast between the two legal.
7
+ */
8
+ export interface ComfyWorkflowBuilder {
9
+ [nodeName: string]: unknown;
10
+ }
11
+ export declare class ComfyWorkflowBuilder {
12
+ graph: ComfyWorkflow;
13
+ constructor(graph: ComfyWorkflow);
14
+ /**
15
+ * helper function to allocate an unique node Id while
16
+ * while respecting user provided metadata id if present.
17
+ */
18
+ private ___allocateNodeUID;
19
+ }
@@ -0,0 +1,43 @@
1
+ import type { KnownComfyCustomNodeName } from '../manager/generated/KnownComfyCustomNodeName.cjs';
2
+ import type { KnownComfyPluginTitle } from '../manager/generated/KnownComfyPluginTitle.cjs';
3
+ import type { KnownComfyPluginURL } from '../manager/generated/KnownComfyPluginURL.cjs';
4
+ import type { KnownModel_Base } from '../manager/generated/KnownModel_Base.cjs';
5
+ import type { KnownModel_Name } from '../manager/generated/KnownModel_Name.cjs';
6
+ import type { ComfyManagerModelInfo } from '../manager/types/ComfyManagerModelInfo.cjs';
7
+ import type { ComfyManagerPluginInfo } from '../manager/types/ComfyManagerPluginInfo.cjs';
8
+ /**
9
+ * comfyts-specific types to allow
10
+ * 2024-03-13 rvion: TODO: split outside of this file, add a new type-level config for
11
+ * project-specific FormNode metadata
12
+ */
13
+ export type Requirements = {
14
+ type: 'modelInCivitai';
15
+ civitaiModelId: string;
16
+ optional?: true;
17
+ base: KnownModel_Base;
18
+ } | {
19
+ type: 'modelInManager';
20
+ modelName: KnownModel_Name;
21
+ optional?: true;
22
+ } | {
23
+ type: 'modelCustom';
24
+ infos: ComfyManagerModelInfo;
25
+ optional?: true;
26
+ } | {
27
+ type: 'customNodesByTitle';
28
+ title: KnownComfyPluginTitle;
29
+ optional?: true;
30
+ } | {
31
+ type: 'customNodesByURI';
32
+ uri: KnownComfyPluginURL;
33
+ optional?: true;
34
+ } | {
35
+ type: 'customNodesByNodeKey';
36
+ nodeName: KnownComfyCustomNodeName;
37
+ optional?: true;
38
+ };
39
+ export type PluginInstallStatus = 'installed' | 'not-installed' | 'update-available' | 'unknown' | 'error';
40
+ export type PluginSuggestion = {
41
+ reason: string;
42
+ plugin: ComfyManagerPluginInfo;
43
+ };
@@ -0,0 +1,43 @@
1
+ import type { KnownComfyCustomNodeName } from '../manager/generated/KnownComfyCustomNodeName.js';
2
+ import type { KnownComfyPluginTitle } from '../manager/generated/KnownComfyPluginTitle.js';
3
+ import type { KnownComfyPluginURL } from '../manager/generated/KnownComfyPluginURL.js';
4
+ import type { KnownModel_Base } from '../manager/generated/KnownModel_Base.js';
5
+ import type { KnownModel_Name } from '../manager/generated/KnownModel_Name.js';
6
+ import type { ComfyManagerModelInfo } from '../manager/types/ComfyManagerModelInfo.js';
7
+ import type { ComfyManagerPluginInfo } from '../manager/types/ComfyManagerPluginInfo.js';
8
+ /**
9
+ * comfyts-specific types to allow
10
+ * 2024-03-13 rvion: TODO: split outside of this file, add a new type-level config for
11
+ * project-specific FormNode metadata
12
+ */
13
+ export type Requirements = {
14
+ type: 'modelInCivitai';
15
+ civitaiModelId: string;
16
+ optional?: true;
17
+ base: KnownModel_Base;
18
+ } | {
19
+ type: 'modelInManager';
20
+ modelName: KnownModel_Name;
21
+ optional?: true;
22
+ } | {
23
+ type: 'modelCustom';
24
+ infos: ComfyManagerModelInfo;
25
+ optional?: true;
26
+ } | {
27
+ type: 'customNodesByTitle';
28
+ title: KnownComfyPluginTitle;
29
+ optional?: true;
30
+ } | {
31
+ type: 'customNodesByURI';
32
+ uri: KnownComfyPluginURL;
33
+ optional?: true;
34
+ } | {
35
+ type: 'customNodesByNodeKey';
36
+ nodeName: KnownComfyCustomNodeName;
37
+ optional?: true;
38
+ };
39
+ export type PluginInstallStatus = 'installed' | 'not-installed' | 'update-available' | 'unknown' | 'error';
40
+ export type PluginSuggestion = {
41
+ reason: string;
42
+ plugin: ComfyManagerPluginInfo;
43
+ };
@@ -0,0 +1,122 @@
1
+ type Message = string | Uint8Array;
2
+ /** structural face of both transports (ws package AND browser WebSocket) */
3
+ export type WsLike = {
4
+ binaryType: string;
5
+ onmessage: ((event: WsMessageEvent) => void) | null;
6
+ onopen: ((event: unknown) => void) | null;
7
+ onclose: ((event: WsCloseEvent) => void) | null;
8
+ onerror: ((event: unknown) => void) | null;
9
+ send(data: Message): void;
10
+ close(): void;
11
+ /** the `ws` package only (a browser answers pings by itself and exposes none of these) */
12
+ ping?(): void;
13
+ on?(event: 'pong', cb: () => void): void;
14
+ terminate?(): void;
15
+ };
16
+ /** what both transports deliver with binaryType 'arraybuffer': string or ArrayBuffer in `data` */
17
+ export type WsMessageEvent = {
18
+ data: unknown;
19
+ };
20
+ export type WsCloseEvent = {
21
+ code: number;
22
+ reason: string;
23
+ };
24
+ type WsCtor = new (url: string, opts?: {
25
+ headers?: Record<string, string>;
26
+ }) => WsLike;
27
+ export type WsTransport = {
28
+ ctor: WsCtor;
29
+ supportsHeaders: boolean;
30
+ };
31
+ type WsDebugMessage = {
32
+ type: 'info' | 'error';
33
+ timestamp: number;
34
+ message: string;
35
+ };
36
+ export declare class ResilientWebSocketClient {
37
+ options: {
38
+ /** re-read on every connect */
39
+ url: () => string;
40
+ /** upgrade-request headers (auth: X-API-Key & co) — a thunk, re-read on every reconnect.
41
+ * On a headerless transport (browser) X-API-Key rides `?token=` instead
42
+ * (the probed Comfy Cloud contract); other headers throw loud. */
43
+ headers?: () => Record<string, string>;
44
+ onMessage: (event: WsMessageEvent) => void;
45
+ onConnectOrReconnect: () => void;
46
+ onClose: () => void;
47
+ /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
48
+ * reported here ONCE, the client goes permanently closed — never a retry storm */
49
+ onTransportDead?: (error: unknown) => void;
50
+ /**
51
+ * the socket closed WITHOUT ever opening: nothing is listening there.
52
+ * That is a definitive answer, not a blip, so it is reported instead of
53
+ * retried and the caller decides. The 2s retry loop exists to heal an
54
+ * ESTABLISHED session; spending it on a refused connect only makes every
55
+ * waiter sit for the full connect deadline. No callback = retry as before.
56
+ */
57
+ onFirstConnectFailed?: (error: unknown) => void;
58
+ /** tests only: a fake socket instead of the ws package / browser WebSocket */
59
+ transport?: WsTransport;
60
+ /** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
61
+ * socket would look open forever: every `heartbeatMs` it is pinged, and one without a
62
+ * pong since the last ping is dropped, which starts the reconnect. Default 15s */
63
+ heartbeatMs?: number;
64
+ /** pause before a reconnect. Default 2s */
65
+ reconnectMs?: number;
66
+ };
67
+ private url;
68
+ private currentWS?;
69
+ private messageBuffer;
70
+ isOpen: boolean;
71
+ debugMessages: WsDebugMessage[];
72
+ private addInfo;
73
+ private addError;
74
+ constructor(options: {
75
+ /** re-read on every connect */
76
+ url: () => string;
77
+ /** upgrade-request headers (auth: X-API-Key & co) — a thunk, re-read on every reconnect.
78
+ * On a headerless transport (browser) X-API-Key rides `?token=` instead
79
+ * (the probed Comfy Cloud contract); other headers throw loud. */
80
+ headers?: () => Record<string, string>;
81
+ onMessage: (event: WsMessageEvent) => void;
82
+ onConnectOrReconnect: () => void;
83
+ onClose: () => void;
84
+ /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
85
+ * reported here ONCE, the client goes permanently closed — never a retry storm */
86
+ onTransportDead?: (error: unknown) => void;
87
+ /**
88
+ * the socket closed WITHOUT ever opening: nothing is listening there.
89
+ * That is a definitive answer, not a blip, so it is reported instead of
90
+ * retried and the caller decides. The 2s retry loop exists to heal an
91
+ * ESTABLISHED session; spending it on a refused connect only makes every
92
+ * waiter sit for the full connect deadline. No callback = retry as before.
93
+ */
94
+ onFirstConnectFailed?: (error: unknown) => void;
95
+ /** tests only: a fake socket instead of the ws package / browser WebSocket */
96
+ transport?: WsTransport;
97
+ /** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
98
+ * socket would look open forever: every `heartbeatMs` it is pinged, and one without a
99
+ * pong since the last ping is dropped, which starts the reconnect. Default 15s */
100
+ heartbeatMs?: number;
101
+ /** pause before a reconnect. Default 2s */
102
+ reconnectMs?: number;
103
+ });
104
+ /** an established session heals by retrying; a first connect that never opened does not */
105
+ private hasEverOpened;
106
+ private reconnectTimeout?;
107
+ private heartbeat;
108
+ private permanentlyClosed;
109
+ private stopHeartbeat;
110
+ /** ping on a timer; no pong since the previous ping = the peer is gone, drop the socket */
111
+ private startHeartbeat;
112
+ /** close the socket cleanly, then reconnect as after any close: the server ends its handler first */
113
+ reconnect(): void;
114
+ /** close and stop reconnecting (lets a script exit cleanly) */
115
+ disconnectPermanently(): void;
116
+ /** headerless transports carry the api key as ?token= — everything else is refused loud */
117
+ private headerlessUrl;
118
+ private connect;
119
+ send(message: Message): void;
120
+ private flushMessageBuffer;
121
+ }
122
+ export {};
@@ -0,0 +1,122 @@
1
+ type Message = string | Uint8Array;
2
+ /** structural face of both transports (ws package AND browser WebSocket) */
3
+ export type WsLike = {
4
+ binaryType: string;
5
+ onmessage: ((event: WsMessageEvent) => void) | null;
6
+ onopen: ((event: unknown) => void) | null;
7
+ onclose: ((event: WsCloseEvent) => void) | null;
8
+ onerror: ((event: unknown) => void) | null;
9
+ send(data: Message): void;
10
+ close(): void;
11
+ /** the `ws` package only (a browser answers pings by itself and exposes none of these) */
12
+ ping?(): void;
13
+ on?(event: 'pong', cb: () => void): void;
14
+ terminate?(): void;
15
+ };
16
+ /** what both transports deliver with binaryType 'arraybuffer': string or ArrayBuffer in `data` */
17
+ export type WsMessageEvent = {
18
+ data: unknown;
19
+ };
20
+ export type WsCloseEvent = {
21
+ code: number;
22
+ reason: string;
23
+ };
24
+ type WsCtor = new (url: string, opts?: {
25
+ headers?: Record<string, string>;
26
+ }) => WsLike;
27
+ export type WsTransport = {
28
+ ctor: WsCtor;
29
+ supportsHeaders: boolean;
30
+ };
31
+ type WsDebugMessage = {
32
+ type: 'info' | 'error';
33
+ timestamp: number;
34
+ message: string;
35
+ };
36
+ export declare class ResilientWebSocketClient {
37
+ options: {
38
+ /** re-read on every connect */
39
+ url: () => string;
40
+ /** upgrade-request headers (auth: X-API-Key & co) — a thunk, re-read on every reconnect.
41
+ * On a headerless transport (browser) X-API-Key rides `?token=` instead
42
+ * (the probed Comfy Cloud contract); other headers throw loud. */
43
+ headers?: () => Record<string, string>;
44
+ onMessage: (event: WsMessageEvent) => void;
45
+ onConnectOrReconnect: () => void;
46
+ onClose: () => void;
47
+ /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
48
+ * reported here ONCE, the client goes permanently closed — never a retry storm */
49
+ onTransportDead?: (error: unknown) => void;
50
+ /**
51
+ * the socket closed WITHOUT ever opening: nothing is listening there.
52
+ * That is a definitive answer, not a blip, so it is reported instead of
53
+ * retried and the caller decides. The 2s retry loop exists to heal an
54
+ * ESTABLISHED session; spending it on a refused connect only makes every
55
+ * waiter sit for the full connect deadline. No callback = retry as before.
56
+ */
57
+ onFirstConnectFailed?: (error: unknown) => void;
58
+ /** tests only: a fake socket instead of the ws package / browser WebSocket */
59
+ transport?: WsTransport;
60
+ /** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
61
+ * socket would look open forever: every `heartbeatMs` it is pinged, and one without a
62
+ * pong since the last ping is dropped, which starts the reconnect. Default 15s */
63
+ heartbeatMs?: number;
64
+ /** pause before a reconnect. Default 2s */
65
+ reconnectMs?: number;
66
+ };
67
+ private url;
68
+ private currentWS?;
69
+ private messageBuffer;
70
+ isOpen: boolean;
71
+ debugMessages: WsDebugMessage[];
72
+ private addInfo;
73
+ private addError;
74
+ constructor(options: {
75
+ /** re-read on every connect */
76
+ url: () => string;
77
+ /** upgrade-request headers (auth: X-API-Key & co) — a thunk, re-read on every reconnect.
78
+ * On a headerless transport (browser) X-API-Key rides `?token=` instead
79
+ * (the probed Comfy Cloud contract); other headers throw loud. */
80
+ headers?: () => Record<string, string>;
81
+ onMessage: (event: WsMessageEvent) => void;
82
+ onConnectOrReconnect: () => void;
83
+ onClose: () => void;
84
+ /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
85
+ * reported here ONCE, the client goes permanently closed — never a retry storm */
86
+ onTransportDead?: (error: unknown) => void;
87
+ /**
88
+ * the socket closed WITHOUT ever opening: nothing is listening there.
89
+ * That is a definitive answer, not a blip, so it is reported instead of
90
+ * retried and the caller decides. The 2s retry loop exists to heal an
91
+ * ESTABLISHED session; spending it on a refused connect only makes every
92
+ * waiter sit for the full connect deadline. No callback = retry as before.
93
+ */
94
+ onFirstConnectFailed?: (error: unknown) => void;
95
+ /** tests only: a fake socket instead of the ws package / browser WebSocket */
96
+ transport?: WsTransport;
97
+ /** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
98
+ * socket would look open forever: every `heartbeatMs` it is pinged, and one without a
99
+ * pong since the last ping is dropped, which starts the reconnect. Default 15s */
100
+ heartbeatMs?: number;
101
+ /** pause before a reconnect. Default 2s */
102
+ reconnectMs?: number;
103
+ });
104
+ /** an established session heals by retrying; a first connect that never opened does not */
105
+ private hasEverOpened;
106
+ private reconnectTimeout?;
107
+ private heartbeat;
108
+ private permanentlyClosed;
109
+ private stopHeartbeat;
110
+ /** ping on a timer; no pong since the previous ping = the peer is gone, drop the socket */
111
+ private startHeartbeat;
112
+ /** close the socket cleanly, then reconnect as after any close: the server ends its handler first */
113
+ reconnect(): void;
114
+ /** close and stop reconnecting (lets a script exit cleanly) */
115
+ disconnectPermanently(): void;
116
+ /** headerless transports carry the api key as ?token= — everything else is refused loud */
117
+ private headerlessUrl;
118
+ private connect;
119
+ send(message: Message): void;
120
+ private flushMessageBuffer;
121
+ }
122
+ export {};
@@ -0,0 +1,23 @@
1
+ import { type ParsedHostBase } from './hostUrl.cjs';
2
+ import type { ComfyStorage } from '../storage/ComfyStorage.cjs';
3
+ export type HostFile = {
4
+ url: string;
5
+ };
6
+ export declare const HOST_FILE_NAME = "host.json";
7
+ /** true when the caller gave no address at all: the id alone asks for the saved one */
8
+ export declare function namesNoAddress(p: {
9
+ url?: string;
10
+ host?: string;
11
+ port?: number;
12
+ https?: boolean;
13
+ }): boolean;
14
+ export declare function hostFilePath(hostFolder: string): string;
15
+ export declare function writeHostFile(storage: ComfyStorage, hostFolder: string, file: HostFile): string;
16
+ /** the saved address of `id`, parsed; when there is none, the error text names the command that writes it */
17
+ export declare function readHostFile(storage: ComfyStorage, hostFolder: string, id: string): {
18
+ base: ParsedHostBase;
19
+ error: null;
20
+ } | {
21
+ base: null;
22
+ error: string;
23
+ };
@@ -0,0 +1,23 @@
1
+ import { type ParsedHostBase } from './hostUrl.js';
2
+ import type { ComfyStorage } from '../storage/ComfyStorage.js';
3
+ export type HostFile = {
4
+ url: string;
5
+ };
6
+ export declare const HOST_FILE_NAME = "host.json";
7
+ /** true when the caller gave no address at all: the id alone asks for the saved one */
8
+ export declare function namesNoAddress(p: {
9
+ url?: string;
10
+ host?: string;
11
+ port?: number;
12
+ https?: boolean;
13
+ }): boolean;
14
+ export declare function hostFilePath(hostFolder: string): string;
15
+ export declare function writeHostFile(storage: ComfyStorage, hostFolder: string, file: HostFile): string;
16
+ /** the saved address of `id`, parsed; when there is none, the error text names the command that writes it */
17
+ export declare function readHostFile(storage: ComfyStorage, hostFolder: string, id: string): {
18
+ base: ParsedHostBase;
19
+ error: null;
20
+ } | {
21
+ base: null;
22
+ error: string;
23
+ };