comfy-ts 0.4.0 → 1.1.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 +385 -255
- package/dist/DefinedWorkflow-BYyu5dK9.js +669 -0
- package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
- package/dist/cli.js +4106 -152
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1560 -333
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7826 -467
- package/dist/index.d.ts +7808 -449
- package/dist/index.js +1550 -333
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-SDSJo1Qf.js → run-tui-DZ22HDHI.js} +631 -657
- package/dist/run-tui-DZ22HDHI.js.map +1 -0
- package/examples/01-txt2img.cflow.ts +50 -0
- package/examples/02-img2img-upload.cflow.ts +55 -0
- package/examples/03-export-workflow-json.cflow.ts +56 -0
- package/examples/04-krea2-turbo-t2i.cflow.ts +125 -0
- package/examples/05-comfy-cloud.cflow.ts +51 -0
- package/examples/README.md +30 -0
- package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
- package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
- package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/cloudHost.ts +41 -0
- package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
- package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
- package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
- package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
- package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
- package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
- package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
- package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
- package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
- package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
- package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
- package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
- package/examples/comfy-cloud/sdk.d.ts +123062 -0
- package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
- package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
- package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
- package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
- package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
- package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
- package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
- package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
- package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
- package/examples/images/README.md +18 -0
- package/examples/images/bear_1024x1024.jpg +0 -0
- package/examples/images/deer_768x1344.jpg +0 -0
- package/examples/images/dog_512x512.jpg +0 -0
- package/examples/images/lioness_768x768.jpg +0 -0
- package/examples/images/pug_200x300.jpg +0 -0
- package/examples/images/walrus_1344x768.jpg +0 -0
- package/guide-for-agents.md +172 -0
- package/package.json +20 -4
- package/src/cli/comfy-ts-cli.ts +19 -2
- package/src/cli/gen.ts +21 -12
- package/src/cli/tui/components/PreviewPanel.tsx +9 -8
- package/src/cli/tui/components/StatusBar.tsx +11 -0
- package/src/cli/tui/components/TreePanel.tsx +15 -2
- package/src/cli/tui/components/TuiApp.tsx +18 -0
- package/src/cli/tui/discoverWorkflows.ts +45 -0
- package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
- package/src/cli/tui/imagePicker/fsListing.ts +46 -0
- package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
- package/src/cli/tui/run-tui.tsx +52 -23
- package/src/cli/tui/state/HostSt.ts +2 -3
- package/src/cli/tui/state/LorasSt.ts +14 -36
- package/src/cli/tui/state/PreviewSt.ts +28 -2
- package/src/cli/tui/state/TreeSt.ts +30 -6
- package/src/cli/tui/state/TuiSt.ts +27 -3
- package/src/cli/tui/state/WorkflowsSt.ts +15 -1
- package/src/exampleAssets.ts +56 -0
- package/src/graph/ComfyNode.ts +4 -1
- package/src/host/ComfyHost.ts +203 -77
- package/src/host/ComfyManager.ts +10 -9
- package/src/host/ComfyUploader.ts +1 -2
- package/src/host/ResilientWebsocket.ts +3 -1
- package/src/host/hostUrl.ts +59 -0
- package/src/host/loraManagerApi.ts +5 -4
- package/src/index.ts +27 -1
- package/src/litegraph/CanonicalWorkflow.ts +77 -0
- package/src/litegraph/LiteGraphGroup.ts +9 -7
- package/src/litegraph/LiteGraphJSON.ts +34 -13
- package/src/litegraph/LiteGraphLink.ts +32 -2
- package/src/litegraph/LiteGraphNode.ts +18 -33
- package/src/litegraph/LiteGraphNodeInput.ts +10 -8
- package/src/litegraph/LiteGraphNodeOutput.ts +2 -3
- package/src/litegraph/LiteGraphSubgraphDef.ts +74 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +4 -4
- package/src/litegraph/expandSubgraphs.ts +352 -0
- package/src/litegraph/normalizeWorkflow.ts +141 -0
- package/src/manager/ComfyRegistry.ts +37 -9
- package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
- package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
- package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
- package/src/manager/generated/KnownModel_Base.ts +23 -7
- package/src/manager/generated/KnownModel_FileName.ts +421 -0
- package/src/manager/generated/KnownModel_Name.ts +421 -0
- package/src/manager/generated/KnownModel_SavePath.ts +34 -8
- package/src/manager/generated/KnownModel_Type.ts +18 -14
- package/src/manager/json/alter-list.json +221 -221
- package/src/manager/json/custom-node-list.json +61020 -21946
- package/src/manager/json/extension-node-map.json +81077 -31176
- package/src/manager/json/github-stats.json +29321 -12601
- package/src/manager/json/model-list.json +5935 -4997
- package/src/manager/loaders/parseReport.ts +55 -0
- package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
- package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
- package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
- package/src/manager/loaders/step4_model-list-loader.ts +25 -36
- package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
- package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
- package/src/manager/script-update-manager.bun.ts +9 -1
- package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
- package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
- package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
- package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
- package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
- package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
- package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
- package/src/runner/ComfyExecution.ts +4 -5
- package/src/runner/ComfyWorkflow.ts +2 -2
- package/src/runner/wsBinaryFrame.ts +48 -0
- package/src/sdk-generator/ComfySchema.ts +14 -1
- package/src/sdk-generator/Primitives.ts +6 -24
- package/src/sdk-generator/comfy-api-json.ts +3 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
- package/src/sdk-generator/inputWidgetKind.ts +196 -0
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +372 -96
- package/src/state.ts +13 -2
- package/src/vars/ComfyVars.ts +82 -2
- package/src/vars/DefinedWorkflow.ts +7 -2
- package/dist/log-CdfgILde.js +0 -10
- package/dist/log-CdfgILde.js.map +0 -1
- package/dist/run-tui-SDSJo1Qf.js.map +0 -1
- package/src/utils/tryExtracting.ts +0 -41
|
@@ -8,7 +8,15 @@ console.clear()
|
|
|
8
8
|
console.log(chalk.bold.greenBright('UPDADING COMFY MANAGER JSONS'))
|
|
9
9
|
|
|
10
10
|
// should take care of the code generation
|
|
11
|
-
await ComfyRegistry.DownloadAndUpdate(!skipDL)
|
|
11
|
+
const registry = await ComfyRegistry.DownloadAndUpdate(!skipDL)
|
|
12
|
+
|
|
13
|
+
console.log(chalk.bold.greenBright('REGISTRY TOTALS'))
|
|
14
|
+
console.log(` plugins (by title): ${registry.plugins_byTitle.size}`)
|
|
15
|
+
console.log(` plugin repo urls: ${registry.plugins_byFile.size}`)
|
|
16
|
+
console.log(` custom node keys: ${registry.plugins_byNodeKey.size}`)
|
|
17
|
+
console.log(` models: ${registry.knownModels.size}`)
|
|
18
|
+
console.log(` alterations: ${registry.alterations.length}`)
|
|
19
|
+
console.log(` github stats: ${registry.githubStats.size}`)
|
|
12
20
|
|
|
13
21
|
// the generator aligns its own `// x N` comments and emits trailing blank
|
|
14
22
|
// lines; oxfmt disagrees on both, so WITHOUT this the ci gate goes red right
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type } from 'arktype'
|
|
2
|
+
|
|
3
|
+
/** ONE alter-list.json row (a1111 extension → comfy alternative); `tags` is a comma-separated STRING upstream */
|
|
4
|
+
export type ComfyManagerAlterInfo = typeof ComfyManagerAlterInfo_ark.infer
|
|
5
|
+
export const ComfyManagerAlterInfo_ark = type({
|
|
6
|
+
id: 'string', // "https://github.com/comfyanonymous/ComfyUI"
|
|
7
|
+
tags: 'string', // "SD1.x,SD2.x,SDXL"
|
|
8
|
+
description: 'string',
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
/** root shape only: rows are validated ONE BY ONE */
|
|
12
|
+
export type ComfyManagerFileAlterListRoot = typeof ComfyManagerFileAlterListRoot_ark.infer
|
|
13
|
+
export const ComfyManagerFileAlterListRoot_ark = type({ items: 'unknown[]' })
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type } from 'arktype'
|
|
2
|
-
import {
|
|
2
|
+
import type { ComfyManagerModelInfo } from 'src/manager/types/ComfyManagerModelInfo.ts'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
/** root shape only: rows are validated ONE BY ONE against ComfyManagerModelInfo_ark */
|
|
5
|
+
export type ComfyManagerFileModelInfoRoot = typeof ComfyManagerFileModelInfoRoot_ark.infer
|
|
6
|
+
export const ComfyManagerFileModelInfoRoot_ark = type({ models: 'unknown[]' })
|
|
7
|
+
|
|
8
|
+
/** hand-maintained extras (model-list.extra.ts) still declare the full canonical shape */
|
|
9
|
+
export type ComfyManagerFileModelInfo = { models: ComfyManagerModelInfo[] }
|
|
@@ -2,12 +2,9 @@ import { type } from 'arktype'
|
|
|
2
2
|
import { ComfyManagerPluginContentMetadata_ark } from 'src/manager/types/ComfyManagerPluginContentMetadata.ts'
|
|
3
3
|
import { ComfyManagerPluginContentNodeName_ark } from 'src/manager/types/ComfyManagerPluginEnums.ts'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ComfyManagerPluginContentMetadata_ark,
|
|
12
|
-
]),
|
|
13
|
-
)
|
|
5
|
+
/** ONE extension-node-map entry value: [nodeNames, meta]; the file root is a Record of these, validated row by row */
|
|
6
|
+
export type ComfyManagerExtensionNodeMapEntry = typeof ComfyManagerExtensionNodeMapEntry_ark.infer
|
|
7
|
+
export const ComfyManagerExtensionNodeMapEntry_ark = type([
|
|
8
|
+
ComfyManagerPluginContentNodeName_ark.array(),
|
|
9
|
+
ComfyManagerPluginContentMetadata_ark,
|
|
10
|
+
])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type } from 'arktype'
|
|
2
|
-
import { ComfyManagerPluginInfo_ark } from 'src/manager/types/ComfyManagerPluginInfo.ts'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
/** root shape only: rows are validated ONE BY ONE against ComfyManagerRawPluginInfo_ark */
|
|
4
|
+
export type ComfyManagerFilePluginListRoot = typeof ComfyManagerFilePluginListRoot_ark.infer
|
|
5
|
+
export const ComfyManagerFilePluginListRoot_ark = type({ custom_nodes: 'unknown[]' })
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type } from 'arktype'
|
|
2
|
+
|
|
3
|
+
/** ONE github-stats.json entry, keyed by repo url in the file root (a Record, validated row by row) */
|
|
4
|
+
export type ComfyManagerGithubStatEntry = typeof ComfyManagerGithubStatEntry_ark.infer
|
|
5
|
+
export const ComfyManagerGithubStatEntry_ark = type({
|
|
6
|
+
stars: 'number',
|
|
7
|
+
last_update: 'string', // "2026-07-28 03:14:59"
|
|
8
|
+
author_account_age_days: 'number',
|
|
9
|
+
})
|
|
@@ -2,9 +2,8 @@ import { type } from 'arktype'
|
|
|
2
2
|
|
|
3
3
|
export type ComfyManagerPluginContentMetadata = typeof ComfyManagerPluginContentMetadata_ark.infer
|
|
4
4
|
export const ComfyManagerPluginContentMetadata_ark = type({
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
title_aux: type.string.or(type.null), // "Jovimetrix Composition Nodes",
|
|
5
|
+
// absent on 10/5573 upstream rows (2026-07-30), null on others
|
|
6
|
+
'title_aux?': type.string.or(type.null), // "Jovimetrix Composition Nodes",
|
|
8
7
|
|
|
9
8
|
// optional
|
|
10
9
|
'author?': 'string', // "amorano",
|
|
@@ -3,48 +3,62 @@ import type { KnownComfyPluginTitle } from 'src/manager/generated/KnownComfyPlug
|
|
|
3
3
|
import type { KnownComfyPluginURL } from 'src/manager/generated/KnownComfyPluginURL.ts'
|
|
4
4
|
import type { ComfyManagerPluginID } from 'src/manager/types/ComfyManagerPluginEnums.ts'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
/**
|
|
7
|
+
* loose INPUT schema: what Comfy-Org/ComfyUI-Manager custom-node-list.json
|
|
8
|
+
* actually ships (surveyed 2026-07-30, 5882 rows)
|
|
9
|
+
*/
|
|
10
|
+
export type ComfyManagerRawPluginInfo = typeof ComfyManagerRawPluginInfo_ark.infer
|
|
11
|
+
export const ComfyManagerRawPluginInfo_ark = type({
|
|
12
|
+
// always present upstream
|
|
13
|
+
author: 'string',
|
|
14
|
+
title: type.string.as<KnownComfyPluginTitle>(),
|
|
15
|
+
reference: 'string',
|
|
16
|
+
files: type.string.as<KnownComfyPluginURL>().array(),
|
|
17
|
+
install_type: 'string', // 'git-clone' | 'copy' | 'unzip' | stray casings
|
|
18
|
+
description: 'string',
|
|
15
19
|
|
|
16
|
-
//
|
|
17
|
-
id: type.string.as<ComfyManagerPluginID>(),
|
|
20
|
+
// absent on 4471/5882 rows (2026-07-30): recovered at normalization
|
|
21
|
+
'id?': type.string.as<ComfyManagerPluginID>(),
|
|
18
22
|
|
|
19
|
-
// optional
|
|
23
|
+
// sparse optional tail
|
|
20
24
|
'preemptions?': 'string[]',
|
|
21
25
|
'pip?': 'string[]',
|
|
22
26
|
'nodename_pattern?': 'string',
|
|
23
27
|
'apt_dependency?': 'string[]',
|
|
24
28
|
'js_path?': 'string',
|
|
25
29
|
'version?': 'string',
|
|
30
|
+
'tags?': 'string[]',
|
|
26
31
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
'
|
|
32
|
+
// 2025/2026 additions, unconsumed but declared so drift stays visible
|
|
33
|
+
'reference2?': 'string',
|
|
34
|
+
'category?': 'string',
|
|
35
|
+
'name?': 'string',
|
|
36
|
+
'license?': 'string',
|
|
37
|
+
'nickname?': 'string',
|
|
38
|
+
'stars?': 'number',
|
|
39
|
+
'last_update?': 'string',
|
|
40
|
+
'badges?': 'string[]',
|
|
41
|
+
'dependencies?': 'string[]',
|
|
30
42
|
})
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
/**
|
|
45
|
+
* canonical plugin row: `id` ALWAYS present (normalization recovers it).
|
|
46
|
+
* The optional tail stays optional ON PURPOSE: this object is also the
|
|
47
|
+
* Manager v2 install POST body, where absent and null differ python-side.
|
|
48
|
+
*/
|
|
49
|
+
export type ComfyManagerPluginInfo = {
|
|
50
|
+
id: ComfyManagerPluginID
|
|
51
|
+
author: string
|
|
52
|
+
title: KnownComfyPluginTitle
|
|
53
|
+
reference: string
|
|
54
|
+
files: KnownComfyPluginURL[]
|
|
55
|
+
install_type: string
|
|
56
|
+
description: string
|
|
57
|
+
preemptions?: string[]
|
|
58
|
+
pip?: string[]
|
|
59
|
+
nodename_pattern?: string
|
|
60
|
+
apt_dependency?: string[]
|
|
61
|
+
js_path?: string
|
|
62
|
+
version?: string
|
|
63
|
+
tags?: string[]
|
|
64
|
+
}
|
|
@@ -201,9 +201,8 @@ export class ComfyExecution {
|
|
|
201
201
|
const promptMeta = this.workflow.data.metadata?.[promptNodeID]
|
|
202
202
|
if (promptNode == null) throw new Error(`❌ invariant violation: promptNode is null`)
|
|
203
203
|
|
|
204
|
-
//
|
|
205
|
-
const
|
|
206
|
-
const imgUrl = serverURL + '/view?' + new URLSearchParams(comfyImageInfo).toString()
|
|
204
|
+
// image route on the host (cloud answers a 302 signed url — fetchFile follows it unauthed)
|
|
205
|
+
const imgRoute = '/view?' + new URLSearchParams(comfyImageInfo).toString()
|
|
207
206
|
|
|
208
207
|
// target path on disk
|
|
209
208
|
const sf = this.saveFormat
|
|
@@ -222,7 +221,7 @@ export class ComfyExecution {
|
|
|
222
221
|
|
|
223
222
|
// RE-ENCODE (COMPRESSED)
|
|
224
223
|
if (sf && sf.format !== 'raw') {
|
|
225
|
-
const response = await
|
|
224
|
+
const response = await this.host.fetchFile(imgRoute)
|
|
226
225
|
const buff = await response.arrayBuffer()
|
|
227
226
|
let textChunk = {}
|
|
228
227
|
try {
|
|
@@ -257,7 +256,7 @@ export class ComfyExecution {
|
|
|
257
256
|
|
|
258
257
|
// SAVE RAW ------------------------------------------------------------------------------------------
|
|
259
258
|
else {
|
|
260
|
-
const response = await
|
|
259
|
+
const response = await this.host.fetchFile(imgRoute)
|
|
261
260
|
const buff = await response.arrayBuffer()
|
|
262
261
|
const uint8arr = new Uint8Array(buff)
|
|
263
262
|
writeFileSync(absPath, uint8arr)
|
|
@@ -363,9 +363,9 @@ export class ComfyWorkflow<ID extends string = string> {
|
|
|
363
363
|
},
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
const
|
|
367
|
-
const res = await fetch(promptEndpoint, {
|
|
366
|
+
const res = await this.host.fetch('/prompt', {
|
|
368
367
|
method: 'POST',
|
|
368
|
+
headers: { 'Content-Type': 'application/json' },
|
|
369
369
|
body: JSON.stringify(out),
|
|
370
370
|
})
|
|
371
371
|
const promptInfoJson = await res.json()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// pure parser for BINARY ws frames (formats per
|
|
2
|
+
// agent/external-docs/comfy-cloud/api-reference.md, all integers big-endian):
|
|
3
|
+
// 1 PREVIEW_IMAGE 4B type · 4B image_type (1 jpeg, 2 png) · image bytes
|
|
4
|
+
// 3 TEXT 4B type · 4B node_id_len · node_id · progress text
|
|
5
|
+
// 4 PREVIEW_IMAGE_WITH_METADATA 4B type · 4B metadata_len · metadata JSON · image bytes
|
|
6
|
+
// Unknown types come back as 'unknown' — the CALLER logs, never throws: the
|
|
7
|
+
// wire drifts faster than we do (type 4 appeared on the first live cloud run).
|
|
8
|
+
|
|
9
|
+
export type ParsedBinaryWsFrame =
|
|
10
|
+
| { kind: 'preview'; bytes: Uint8Array<ArrayBuffer>; mime: string; metadata: unknown }
|
|
11
|
+
| { kind: 'text'; nodeId: string; text: string }
|
|
12
|
+
| { kind: 'unknown'; eventType: number }
|
|
13
|
+
|
|
14
|
+
export function parseBinaryWsFrame(data: ArrayBuffer): ParsedBinaryWsFrame {
|
|
15
|
+
const view = new DataView(data)
|
|
16
|
+
const eventType = view.getUint32(0)
|
|
17
|
+
|
|
18
|
+
if (eventType === 1) {
|
|
19
|
+
const imageType = view.getUint32(4)
|
|
20
|
+
const bytes = new Uint8Array(data.slice(8))
|
|
21
|
+
const mime = imageType === 2 ? 'image/png' : 'image/jpeg'
|
|
22
|
+
return { kind: 'preview', bytes, mime, metadata: null }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (eventType === 3) {
|
|
26
|
+
const nodeIdLen = view.getUint32(4)
|
|
27
|
+
const decoder = new TextDecoder()
|
|
28
|
+
const nodeId = decoder.decode(data.slice(8, 8 + nodeIdLen))
|
|
29
|
+
const text = decoder.decode(data.slice(8 + nodeIdLen))
|
|
30
|
+
return { kind: 'text', nodeId, text }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (eventType === 4) {
|
|
34
|
+
const metadataLen = view.getUint32(4)
|
|
35
|
+
let metadata: unknown = null
|
|
36
|
+
try {
|
|
37
|
+
metadata = JSON.parse(new TextDecoder().decode(data.slice(8, 8 + metadataLen)))
|
|
38
|
+
} catch {
|
|
39
|
+
// tolerate broken metadata: the image bytes are the payload that matters
|
|
40
|
+
}
|
|
41
|
+
const bytes = new Uint8Array(data.slice(8 + metadataLen))
|
|
42
|
+
// the docs say "raw JPEG/PNG bytes" with no format field — sniff the magic
|
|
43
|
+
const mime = bytes[0] === 0x89 && bytes[1] === 0x50 ? 'image/png' : 'image/jpeg'
|
|
44
|
+
return { kind: 'preview', bytes, mime, metadata }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { kind: 'unknown', eventType }
|
|
48
|
+
}
|
|
@@ -4,6 +4,7 @@ import { toQualifiedNodeKey } from 'src/sdk-generator/_toQualifiedNodeKey.ts'
|
|
|
4
4
|
import { ComfyNodeSchema } from 'src/sdk-generator/ComfyNodeSchema.ts'
|
|
5
5
|
import type { ComfyEnumDef, ComfyNodeSchemaJSON, ComfySchemaJSON } from 'src/sdk-generator/ComfyUIObjectInfoTypes.ts'
|
|
6
6
|
import { codegenSDK } from 'src/sdk-generator/comfyui-sdk-codegen.ts'
|
|
7
|
+
import { classifyWidgetInput, containerInstanceSlotType } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
7
8
|
import {
|
|
8
9
|
asComfyNodeSlotName,
|
|
9
10
|
asComfyNodeSlotTypeName,
|
|
@@ -233,9 +234,21 @@ export class ComfySchema {
|
|
|
233
234
|
)
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
// autogrow container: the declaration is never a prompt input
|
|
238
|
+
// (instances are `<name>.<inst>` link slots) — never required, and
|
|
239
|
+
// its template sub-input slot type registers like any slot so
|
|
240
|
+
// codegen can type the dotted instance keys (agent/sdk-codegen.md)
|
|
241
|
+
const isAutogrowContainer =
|
|
242
|
+
typeof slotType === 'string' &&
|
|
243
|
+
classifyWidgetInput({ name: ipt.name, type: slotType, opts: slotOpts }).kind === 'dynamic-container'
|
|
244
|
+
if (isAutogrowContainer) {
|
|
245
|
+
const instType = containerInstanceSlotType(slotOpts)
|
|
246
|
+
if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType))
|
|
247
|
+
}
|
|
248
|
+
|
|
236
249
|
node.inputs.push({
|
|
237
250
|
slotName: inputSlotName,
|
|
238
|
-
required: ipt.required,
|
|
251
|
+
required: ipt.required && !isAutogrowContainer,
|
|
239
252
|
nameInComfy: inputNameInComfy,
|
|
240
253
|
nameInComfyEscaped: escapeJSKey(inputNameInComfy),
|
|
241
254
|
typeName: inputTypeName,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { LiteGraphNode } from 'src/litegraph/LiteGraphNode.ts'
|
|
2
1
|
import type { ComfyNodeSchemaJSON } from 'src/sdk-generator/ComfyUIObjectInfoTypes.ts'
|
|
3
|
-
import type { NodeInputExt } from 'src/sdk-generator/comfyui-types.ts'
|
|
4
2
|
|
|
5
3
|
export const ComfyPrimitiveMapping: { [key: string]: string } = {
|
|
6
4
|
// BACK
|
|
@@ -20,24 +18,14 @@ export const ComfyPrimitiveMapping: { [key: string]: string } = {
|
|
|
20
18
|
|
|
21
19
|
export const ComfyPrimitives: string[] = Object.keys(ComfyPrimitiveMapping)
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export const howManyWidgetValuesForThisSchemaType = (input: NodeInputExt): number => {
|
|
28
|
-
if (input.typeName === 'INT') {
|
|
29
|
-
if (input.nameInComfy === 'seed' || input.nameInComfy === 'noise_seed') return 2
|
|
30
|
-
}
|
|
31
|
-
if (input.isPrimitive) return 1
|
|
32
|
-
// 🔴
|
|
33
|
-
if (input.typeName.startsWith('E_')) return 1
|
|
34
|
-
// console.log(343, input)
|
|
35
|
-
return 0
|
|
36
|
-
}
|
|
21
|
+
// schema-driven widget counting moved to src/sdk-generator/inputWidgetKind.ts
|
|
22
|
+
// (config-driven classification); what stays below is the LEGACY serialized-
|
|
23
|
+
// type path, used only when an old file carries a widget-marked input whose
|
|
24
|
+
// schema now says slot.
|
|
37
25
|
|
|
38
26
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
27
|
+
* when a litegraph node has an input entry with a widget marker, the
|
|
28
|
+
* serialized TYPE string decides how many widgets_values it consumed in that era
|
|
41
29
|
*/
|
|
42
30
|
export const howManyWidgetValuesForThisInputType = (type: string, nameInComfy: string): number => {
|
|
43
31
|
if (type === 'INT') {
|
|
@@ -68,9 +56,3 @@ export const ComfyDefaultNodeWhenUnknown_Schema: ComfyNodeSchemaJSON = {
|
|
|
68
56
|
output_node: false,
|
|
69
57
|
python_module: 'nodes',
|
|
70
58
|
}
|
|
71
|
-
|
|
72
|
-
export class UnknownCustomNode extends Error {
|
|
73
|
-
constructor(public node: LiteGraphNode) {
|
|
74
|
-
super(`❌ node ${node.id}(${node.type}) has no known schema; you probably need to install some custom node`)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -9,8 +9,10 @@ export type ComfyApiJson = {
|
|
|
9
9
|
|
|
10
10
|
export type ComfyApiNodeJson = {
|
|
11
11
|
inputs: {
|
|
12
|
+
// object form: custom-widget values pass through verbatim, array widget
|
|
13
|
+
// values ride wrapped as { __value__: [...] } (a bare 2-list is a link)
|
|
12
14
|
// prettier-ignore
|
|
13
|
-
[key: string]: [string, number] | string | number | boolean | null
|
|
15
|
+
[key: string]: [string, number] | string | number | boolean | null | { [key: string]: unknown }
|
|
14
16
|
}
|
|
15
17
|
class_type: string
|
|
16
18
|
}
|
|
@@ -4,6 +4,7 @@ import { escapeJSKey } from 'src/utils/escapeJSKey.ts'
|
|
|
4
4
|
import type { ComfySchema } from 'src/sdk-generator/ComfySchema.ts'
|
|
5
5
|
|
|
6
6
|
import { type ComfyNodeSchema, wrapQuote } from 'src/sdk-generator/ComfyNodeSchema.ts'
|
|
7
|
+
import { classifySchemaInput, containerInstanceSlotType } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* convert a host id to the namespace name it gets inside the global `Comfy` namespace
|
|
@@ -76,6 +77,20 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
|
|
|
76
77
|
for (const n of nodes) {
|
|
77
78
|
p(`${escapeJSKey(n.nodeKey)}: {`)
|
|
78
79
|
for (const i of n.inputs) {
|
|
80
|
+
// autogrow container: emit dotted instance keys, never the container
|
|
81
|
+
// decl itself — the backend prompt input is `<name>.<inst>`, the
|
|
82
|
+
// first template.min instances required (agent/sdk-codegen.md)
|
|
83
|
+
const kind = classifySchemaInput(i)
|
|
84
|
+
if (kind.kind === 'dynamic-container') {
|
|
85
|
+
const instType = containerInstanceSlotType(i.opts)
|
|
86
|
+
if (instType != null) {
|
|
87
|
+
kind.instanceNames.forEach((instName, ix) => {
|
|
88
|
+
const opt = ix >= kind.requiredCount ? '?' : ''
|
|
89
|
+
p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`)
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
continue
|
|
93
|
+
}
|
|
79
94
|
const opts_ = typeof i.opts === 'string' ? null : i.opts
|
|
80
95
|
let type = `Accepts[${JSON.stringify(i.typeName)}]`
|
|
81
96
|
// COMBO inputs (ComfyUI ≥ 0.3.x) carry literal choices in opts.options
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { NodeInputExt } from 'src/sdk-generator/comfyui-types.ts'
|
|
2
|
+
import { ComfyPrimitiveMapping } from 'src/sdk-generator/Primitives.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Widget-ness of a schema input, decided from its CONFIG — never from a
|
|
6
|
+
* type-name whitelist (2026 object_info spells widget inputs as arbitrary
|
|
7
|
+
* strings backed by a frontend widget registry we cannot mirror; every
|
|
8
|
+
* registry spelling carries a config signal instead). Signal precedence and
|
|
9
|
+
* their upstream anchors: agent/architecture.md "Widget-ness is decided from
|
|
10
|
+
* the input CONFIG".
|
|
11
|
+
*/
|
|
12
|
+
export type InputWidgetKind =
|
|
13
|
+
| { kind: 'slot' }
|
|
14
|
+
| { kind: 'widget'; consumes: 1 | 2; strictValues: boolean }
|
|
15
|
+
| { kind: 'dynamic-combo'; options: DynamicComboOption[]; defaultKey: string }
|
|
16
|
+
| { kind: 'dynamic-container'; instanceNames: string[]; requiredCount: number }
|
|
17
|
+
|
|
18
|
+
/** one raw `[type, opts]` input entry as spelled in object_info (dynamic-combo branches arrive in this raw form) */
|
|
19
|
+
export type RawInputSpecEntry = {
|
|
20
|
+
name: string
|
|
21
|
+
type: string | readonly unknown[]
|
|
22
|
+
opts: unknown
|
|
23
|
+
required: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type DynamicComboOption = { key: string; inputs: RawInputSpecEntry[] }
|
|
27
|
+
|
|
28
|
+
export const isRecord = (x: unknown): x is Record<string, unknown> =>
|
|
29
|
+
typeof x === 'object' && x != null && !Array.isArray(x)
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* seed phantom: a TRUTHY `control_after_generate` adds one consumed value.
|
|
33
|
+
* The frontend creates the control widget on truthiness, and real 2026 hosts
|
|
34
|
+
* spell it as `true` OR as a string mode like `'fixed'` (PrimitiveInt.value,
|
|
35
|
+
* SeedNode.seed). When the KEY is absent (2024 era) the INT-named-seed
|
|
36
|
+
* heuristic applies.
|
|
37
|
+
*/
|
|
38
|
+
const controlConsumes = (o: Record<string, unknown> | null, typeName: string, name: string): 1 | 2 => {
|
|
39
|
+
if (o != null && 'control_after_generate' in o) return o['control_after_generate'] ? 2 : 1
|
|
40
|
+
if (typeName === 'INT' && (name === 'seed' || name === 'noise_seed')) return 2
|
|
41
|
+
return 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const flattenInputSections = (inputs: Record<string, unknown>): RawInputSpecEntry[] => {
|
|
45
|
+
const out: RawInputSpecEntry[] = []
|
|
46
|
+
for (const section of ['required', 'optional'] as const) {
|
|
47
|
+
const sec = inputs[section]
|
|
48
|
+
if (!isRecord(sec)) continue
|
|
49
|
+
for (const [name, spec] of Object.entries(sec)) {
|
|
50
|
+
if (!Array.isArray(spec) || spec.length === 0) continue
|
|
51
|
+
const t: unknown = spec[0]
|
|
52
|
+
if (typeof t !== 'string' && !Array.isArray(t)) continue
|
|
53
|
+
out.push({ name, type: t, opts: spec[1], required: section === 'required' })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return out
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** null when the options array is NOT the dynamic `{key, inputs}` family (then it is a plain combo) */
|
|
60
|
+
const parseDynamicOptions = (options: unknown[]): DynamicComboOption[] | null => {
|
|
61
|
+
if (options.length === 0) return null
|
|
62
|
+
const out: DynamicComboOption[] = []
|
|
63
|
+
for (const entry of options) {
|
|
64
|
+
if (!isRecord(entry)) return null
|
|
65
|
+
const key = entry['key']
|
|
66
|
+
const inputs = entry['inputs']
|
|
67
|
+
if (typeof key !== 'string' || !isRecord(inputs)) return null
|
|
68
|
+
out.push({ key, inputs: flattenInputSections(inputs) })
|
|
69
|
+
}
|
|
70
|
+
return out
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* autogrow (`template` WITH a nested `input` section): instances are always
|
|
75
|
+
* link slots named `decl.<name_i>` (the backend force-inputs widget
|
|
76
|
+
* templates), the first `min` of them required WHEN the template input
|
|
77
|
+
* section is `required` — mirrors `_io.py Autogrow._expand_schema_for_dynamic`.
|
|
78
|
+
*/
|
|
79
|
+
const parseContainer = (template: Record<string, unknown>): InputWidgetKind => {
|
|
80
|
+
const input = template['input']
|
|
81
|
+
const min = typeof template['min'] === 'number' ? template['min'] : 1
|
|
82
|
+
const prefix = typeof template['prefix'] === 'string' ? template['prefix'] : ''
|
|
83
|
+
const max = typeof template['max'] === 'number' ? template['max'] : 100
|
|
84
|
+
const rawNames = template['names']
|
|
85
|
+
const names = Array.isArray(rawNames)
|
|
86
|
+
? rawNames.filter((n): n is string => typeof n === 'string')
|
|
87
|
+
: Array.from({ length: max }, (_, i) => `${prefix}${i}`)
|
|
88
|
+
const templateRequired = isRecord(input) && isRecord(input['required']) && Object.keys(input['required']).length > 0
|
|
89
|
+
return {
|
|
90
|
+
kind: 'dynamic-container',
|
|
91
|
+
instanceNames: names,
|
|
92
|
+
requiredCount: templateRequired ? Math.min(min, names.length) : 0,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* the single template sub-input's slot type of an autogrow container
|
|
98
|
+
* (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
|
|
99
|
+
* autogrow template or the template has several sub-inputs (corpus-absent
|
|
100
|
+
* 2026-07-30, 27/27 single on the cloud catalog) — then codegen emits no
|
|
101
|
+
* typed instance keys and the container stays builderBase territory.
|
|
102
|
+
*/
|
|
103
|
+
export const containerInstanceSlotType = (opts: unknown): string | null => {
|
|
104
|
+
const o = isRecord(opts) ? opts : null
|
|
105
|
+
const template = o?.['template']
|
|
106
|
+
if (!isRecord(template) || !isRecord(template['input'])) return null
|
|
107
|
+
const subs = flattenInputSections(template['input'])
|
|
108
|
+
const first = subs[0]
|
|
109
|
+
if (subs.length !== 1 || first == null || typeof first.type !== 'string') return null
|
|
110
|
+
return first.type
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const classifyWidgetInput = (p: {
|
|
114
|
+
name: string
|
|
115
|
+
type: string | readonly unknown[]
|
|
116
|
+
opts: unknown
|
|
117
|
+
/** true when type is a generated `E_*` union name (parsed 2024-era enum) */
|
|
118
|
+
isEnumUnion?: boolean
|
|
119
|
+
}): InputWidgetKind => {
|
|
120
|
+
const o = isRecord(p.opts) ? p.opts : null
|
|
121
|
+
// 1. forceInput gates widget creation upstream, whatever the type says
|
|
122
|
+
if (o?.['forceInput'] === true) return { kind: 'slot' }
|
|
123
|
+
// 2. enum arrays / parsed E_ unions are combo widgets
|
|
124
|
+
if (Array.isArray(p.type) || p.isEnumUnion === true) {
|
|
125
|
+
const tn = typeof p.type === 'string' ? p.type : 'COMBO'
|
|
126
|
+
return { kind: 'widget', consumes: controlConsumes(o, tn, p.name), strictValues: true }
|
|
127
|
+
}
|
|
128
|
+
if (typeof p.type !== 'string') return { kind: 'slot' }
|
|
129
|
+
// 3. widgetType names the widget for multi-type unions (frontend: widgets.get(widgetType ?? type))
|
|
130
|
+
const widgetTypeName = typeof o?.['widgetType'] === 'string' ? o['widgetType'] : p.type
|
|
131
|
+
// 4. primitives
|
|
132
|
+
if (ComfyPrimitiveMapping[widgetTypeName] != null)
|
|
133
|
+
return { kind: 'widget', consumes: controlConsumes(o, widgetTypeName, p.name), strictValues: true }
|
|
134
|
+
// 5. options array: dynamic {key, inputs} family, else plain combo
|
|
135
|
+
const options = o?.['options']
|
|
136
|
+
if (Array.isArray(options)) {
|
|
137
|
+
const dynOptions = parseDynamicOptions(options)
|
|
138
|
+
if (dynOptions != null) {
|
|
139
|
+
const first = dynOptions[0]
|
|
140
|
+
if (first == null) return { kind: 'slot' } // unreachable: parseDynamicOptions rejects empty
|
|
141
|
+
const defaultKey = typeof o?.['default'] === 'string' ? o['default'] : first.key
|
|
142
|
+
return { kind: 'dynamic-combo', options: dynOptions, defaultKey }
|
|
143
|
+
}
|
|
144
|
+
return { kind: 'widget', consumes: controlConsumes(o, p.type, p.name), strictValues: true }
|
|
145
|
+
}
|
|
146
|
+
// 6. template WITH nested input = autogrow container; WITHOUT = matchtype slot typing
|
|
147
|
+
const template = o?.['template']
|
|
148
|
+
if (isRecord(template)) {
|
|
149
|
+
if (isRecord(template['input'])) return parseContainer(template)
|
|
150
|
+
return { kind: 'slot' }
|
|
151
|
+
}
|
|
152
|
+
// 7. socketless: a widget that never has a socket (IMAGECOMPARE, COLOR); value domain unknown
|
|
153
|
+
if (o?.['socketless'] === true) return { kind: 'widget', consumes: 1, strictValues: false }
|
|
154
|
+
return { kind: 'slot' }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const classifySchemaInput = (input: NodeInputExt): InputWidgetKind =>
|
|
158
|
+
classifyWidgetInput({
|
|
159
|
+
name: input.nameInComfy,
|
|
160
|
+
type: input.typeName,
|
|
161
|
+
opts: input.opts,
|
|
162
|
+
isEnumUnion: input.isEnum,
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
/** how many widgets_values entries this schema input consumes (export path + positional walks) */
|
|
166
|
+
export const howManyWidgetValuesForThisSchemaType = (input: NodeInputExt): number => {
|
|
167
|
+
const kind = classifySchemaInput(input)
|
|
168
|
+
return kind.kind === 'widget' ? kind.consumes : 0
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* what ComfyUI's frontend gives a widget created with no serialized value
|
|
173
|
+
* (`getWidgetDefaultValue` semantics), used when a positional array is
|
|
174
|
+
* shorter than the schema's widget list. `null` for custom widgets — the
|
|
175
|
+
* backend accepts an explicit null but errors on an ABSENT required key.
|
|
176
|
+
*/
|
|
177
|
+
export const defaultValueForWidget = (p: {
|
|
178
|
+
type: string
|
|
179
|
+
opts: unknown
|
|
180
|
+
/** resolved values when the type is a generated E_ union or an inline enum array */
|
|
181
|
+
enumValues?: readonly (string | boolean | number)[]
|
|
182
|
+
}): unknown => {
|
|
183
|
+
const o = isRecord(p.opts) ? p.opts : null
|
|
184
|
+
if (o != null && o['default'] !== undefined) return o['default']
|
|
185
|
+
const widgetTypeName = typeof o?.['widgetType'] === 'string' ? o['widgetType'] : p.type
|
|
186
|
+
if (widgetTypeName === 'INT' || widgetTypeName === 'FLOAT') return 0
|
|
187
|
+
if (widgetTypeName === 'BOOLEAN') return false
|
|
188
|
+
if (widgetTypeName === 'STRING') return ''
|
|
189
|
+
const options = o?.['options']
|
|
190
|
+
if (Array.isArray(options) && options.length > 0) {
|
|
191
|
+
const first: unknown = options[0]
|
|
192
|
+
if (typeof first === 'string' || typeof first === 'number' || typeof first === 'boolean') return first
|
|
193
|
+
}
|
|
194
|
+
if (p.enumValues != null && p.enumValues.length > 0) return p.enumValues[0]
|
|
195
|
+
return null
|
|
196
|
+
}
|