comfy-ts 2.16.0 → 2.17.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 +23 -0
- package/dist/{run-serve-C78hD7t9.js → ServeApp-BSA5yzxZ.js} +17 -444
- package/dist/ServeApp-BSA5yzxZ.js.map +1 -0
- package/dist/cli.js +18 -5
- package/dist/cli.js.map +1 -1
- package/dist/exampleAssets-BfWzygoM.js +38 -0
- package/dist/exampleAssets-BfWzygoM.js.map +1 -0
- package/dist/{LogsSt-Ct7Le0S_.js → findDefinedWorkflow-0lG-VTEd.js} +201 -201
- package/dist/findDefinedWorkflow-0lG-VTEd.js.map +1 -0
- package/dist/index.cjs +146 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -8
- package/dist/index.d.ts +61 -8
- package/dist/index.js +146 -59
- package/dist/index.js.map +1 -1
- package/dist/run-run-DnaMLCFn.js +450 -0
- package/dist/run-run-DnaMLCFn.js.map +1 -0
- package/dist/run-serve-CbKxIu6i.js +418 -0
- package/dist/run-serve-CbKxIu6i.js.map +1 -0
- package/dist/{run-tui-nPETFRmk.js → run-tui-B0AQWbad.js} +6 -37
- package/dist/run-tui-B0AQWbad.js.map +1 -0
- package/dist/{schemaDrift-wb5XkrHV.js → schemaDrift-CbsABBuk.js} +3 -2
- package/dist/{schemaDrift-wb5XkrHV.js.map → schemaDrift-CbsABBuk.js.map} +1 -1
- package/dist/serve-web.js +37 -37
- package/dist/{state-BMW57_M0.js → state-C2oDiQ26.js} +146 -60
- package/dist/state-C2oDiQ26.js.map +1 -0
- package/dist/web.d.ts +61 -8
- package/dist/web.js +146 -59
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/rvion/15-tts-voice-clone.cflow.ts +8 -8
- package/examples/rvion/16-tts-voice-design.cflow.ts +71 -0
- package/guide-for-agents.md +3 -0
- package/package.json +1 -1
- package/src/cli/comfy-ts-cli.ts +14 -1
- package/src/cli/run/findModules.ts +36 -0
- package/src/cli/run/flagValue.ts +61 -0
- package/src/cli/run/outputPaths.ts +41 -0
- package/src/cli/run/pickModule.ts +41 -0
- package/src/cli/run/run-run.ts +250 -0
- package/src/cli/run/runArgs.ts +61 -0
- package/src/cli/run/sidecar.ts +27 -0
- package/src/cli/serve/ServeApp.ts +13 -39
- package/src/cli/serve/web/components/DraftTabs.tsx +8 -2
- package/src/cli/serve/web/state/draftTabs.ts +12 -0
- package/src/cli/serve/web/state/shortcutCatalog.ts +1 -0
- package/src/coreExports.ts +2 -0
- package/src/host/ComfyHost.ts +73 -40
- package/src/host/previewMethod.ts +29 -0
- package/src/runner/ComfyExecution.ts +45 -1
- package/src/runner/ComfyWorkflow.ts +6 -1
- package/src/runner/ComfyWsApi.ts +1 -1
- package/src/runner/wsBinaryFrame.ts +48 -25
- package/src/vars/ComfyVars.ts +3 -0
- package/src/vars/DefinedWorkflow.ts +1 -0
- package/dist/LogsSt-Ct7Le0S_.js.map +0 -1
- package/dist/run-serve-C78hD7t9.js.map +0 -1
- package/dist/run-tui-nPETFRmk.js.map +0 -1
- package/dist/state-BMW57_M0.js.map +0 -1
package/examples/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Every `*.cflow.ts` file here is a runnable workflow module: run it directly with
|
|
|
9
9
|
- `rvion/06-qwen-image-edit.cflow.ts` — image editing (qwen image edit 2511) against the same local host.
|
|
10
10
|
- `rvion/07-local-llm-text-gen.cflow.ts` — a local LLM, no image: core's `TextGenerate` runs a chat model loaded through `CLIPLoader`, and the text comes back in `execution.text`. `--sweep` reports which text encoders on your host actually generate.
|
|
11
11
|
- `rvion/08-qwen-image-21-t2i.cflow.ts` / `rvion/09-qwen-image-21-edit.cflow.ts` — Qwen Image 2.1 (ComfyUI ≥ 0.37) against the same local host: text to image, and instruction editing of one reference image (its `remove background` preset is the official background-removal template).
|
|
12
|
+
- `rvion/16-tts-voice-design.cflow.ts`: a new voice from a written description (needs TTS-Audio-Suite, Qwen3-TTS VoiceDesign): it speaks one sample line in that voice, and the clip plus that line are what `15-tts-voice-clone` takes as `voice` and `transcript`. From the command line the flow is two runs: `comfy-ts run tts-voice-design --description "…" --line "…" --out voices/sailor.flac` writes the clip and `voices/sailor.txt`, then `comfy-ts run tts-voice-clone --voice voices/sailor.flac --prompt "…" --out lines/001.flac` speaks any line in it.
|
|
12
13
|
- `rvion/15-tts-voice-clone.cflow.ts` — text to speech in a cloned voice (needs the [TTS-Audio-Suite](https://github.com/diodiogod/TTS-Audio-Suite) custom node pack on the host): pick an engine (Chatterbox Multilingual v3 by default, Qwen3-TTS, Fish Audio S2 Pro, CosyVoice3, OmniVoice) and a language, drop a voice clip and write its transcript, and the text comes back as audio in `execution.audios`.
|
|
13
14
|
- `comfy-cloud/<family>-<mode>.cflow.ts` — the model zoo: one clean example per model family × mode (`t2i`, `i2i`, `t2v`, `i2v`, `t2a`), each mirroring an official ComfyUI template (flux, qwen-image, z-image, wan, hidream, ace-step, …). All share `comfy-cloud/cloudHost.ts`.
|
|
14
15
|
|
|
@@ -27,8 +27,13 @@ const LANGUAGES = [
|
|
|
27
27
|
'Chinese',
|
|
28
28
|
] as const
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const transcript = v.text(
|
|
31
|
+
'This is a short sample of my voice. Clone it, and I can read any text you give me, in many languages.',
|
|
32
|
+
{ label: 'transcript of the voice clip' },
|
|
33
|
+
)
|
|
34
|
+
// bundled default (examples/media/, ships in the tarball). A clip's `<clip>.txt` is its
|
|
35
|
+
// transcript when `comfy-ts run` sets the clip and leaves the transcript alone
|
|
36
|
+
const voice = v.audio(exampleMediaPath('voice_en_6s.flac'), { sidecarText: transcript })
|
|
32
37
|
|
|
33
38
|
export const ttsVoiceClone = host.defineWorkflow({
|
|
34
39
|
id: 'tts-voice-clone',
|
|
@@ -41,12 +46,7 @@ export const ttsVoiceClone = host.defineWorkflow({
|
|
|
41
46
|
engine: v.choice(ENGINES, 'chatterbox', 'engine'),
|
|
42
47
|
language: v.choice(LANGUAGES, 'English', 'language'),
|
|
43
48
|
voice,
|
|
44
|
-
transcript
|
|
45
|
-
'This is a short sample of my voice. Clone it, and I can read any text you give me, in many languages.',
|
|
46
|
-
{
|
|
47
|
-
label: 'transcript of the voice clip',
|
|
48
|
-
},
|
|
49
|
-
),
|
|
49
|
+
transcript,
|
|
50
50
|
},
|
|
51
51
|
// async build: the voice clip is uploaded (hash-named, deduped) per run
|
|
52
52
|
build: async (b, vars, wf) => {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// a new voice from a written description, on windows-1: Qwen3-TTS VoiceDesign speaks one sample
|
|
2
|
+
// line in the voice you describe. The clip and that line are the pair 15-tts-voice-clone takes
|
|
3
|
+
// as `voice` and `transcript`, so every later line keeps the same voice. The line comes back
|
|
4
|
+
// as a text output too: `comfy-ts run` writes it beside the clip as its transcript
|
|
5
|
+
// box inventory: custom node pack TTS-Audio-Suite (github.com/diodiogod/TTS-Audio-Suite); the
|
|
6
|
+
// VoiceDesign checkpoint downloads on first use, which takes minutes
|
|
7
|
+
// run directly: bun examples/rvion/16-tts-voice-design.cflow.ts ["description"] ["line"]
|
|
8
|
+
import { ComfyTS, v } from 'comfy-ts'
|
|
9
|
+
|
|
10
|
+
const comfy = ComfyTS.create()
|
|
11
|
+
const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
|
|
12
|
+
await host.loadSchemaFromCache() // offline import; run() connects lazily
|
|
13
|
+
|
|
14
|
+
const LANGUAGES = [
|
|
15
|
+
'English',
|
|
16
|
+
'French',
|
|
17
|
+
'German',
|
|
18
|
+
'Spanish',
|
|
19
|
+
'Italian',
|
|
20
|
+
'Portuguese',
|
|
21
|
+
'Russian',
|
|
22
|
+
'Japanese',
|
|
23
|
+
'Korean',
|
|
24
|
+
'Chinese',
|
|
25
|
+
] as const
|
|
26
|
+
|
|
27
|
+
export const ttsVoiceDesign = host.defineWorkflow({
|
|
28
|
+
id: 'tts-voice-design',
|
|
29
|
+
tags: ['tts', 'voice'],
|
|
30
|
+
vars: {
|
|
31
|
+
description: v.text('An old sailor, gravelly and warm, slow pace, a smile in the voice.', {
|
|
32
|
+
label: 'the voice: age, gender, pitch, texture, accent, pace, mood',
|
|
33
|
+
}),
|
|
34
|
+
line: v.text('Ahoy, and welcome aboard. The sea is calm tonight, so sit down and listen to my story.', {
|
|
35
|
+
label: 'what the sample says (8 to 12 s of speech clones best)',
|
|
36
|
+
}),
|
|
37
|
+
language: v.choice(LANGUAGES, 'English', 'language'),
|
|
38
|
+
seed: v.seed(7),
|
|
39
|
+
},
|
|
40
|
+
build: (b, vars) => {
|
|
41
|
+
const S = 'TTS-Audio-Suite'
|
|
42
|
+
const engine = b[`${S}.Qwen3TTSEngineNode`]({
|
|
43
|
+
model_variant: 'Voice Design - 1.7B VoiceDesign',
|
|
44
|
+
device: 'auto',
|
|
45
|
+
voice_preset: 'None (Zero-shot / Custom)',
|
|
46
|
+
language: vars.language,
|
|
47
|
+
instruct: '',
|
|
48
|
+
})
|
|
49
|
+
const designed = b[`${S}.UnifiedVoiceDesignerNode`]({
|
|
50
|
+
TTS_engine: engine.outputs.TTS_engine,
|
|
51
|
+
reference_text: vars.line,
|
|
52
|
+
voice_instruction: vars.description,
|
|
53
|
+
seed: vars.seed,
|
|
54
|
+
})
|
|
55
|
+
b.PreviewAudio({ audio: designed.outputs.preview_audio })
|
|
56
|
+
// the transcript of the clip: the line itself, as a text output
|
|
57
|
+
b.PreviewAny({ source: vars.line })
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export default ttsVoiceDesign
|
|
62
|
+
|
|
63
|
+
// standalone run (skipped when another driver, like the TUI, imports this module)
|
|
64
|
+
if (import.meta.main) {
|
|
65
|
+
if (process.argv[2]) ttsVoiceDesign.vars.description.set(process.argv[2])
|
|
66
|
+
if (process.argv[3]) ttsVoiceDesign.vars.line.set(process.argv[3])
|
|
67
|
+
|
|
68
|
+
const execution = await ttsVoiceDesign.run({ log: true, save: { prefix: 'comfy-ts-example/tts-voice-design' } })
|
|
69
|
+
for (const clip of execution.audios) console.log(`🟢 ${clip.absPath}`)
|
|
70
|
+
host.disconnect()
|
|
71
|
+
}
|
package/guide-for-agents.md
CHANGED
|
@@ -96,8 +96,11 @@ bunx comfy-ts gen --id <host-id> [--host http://127.0.0.1:8188] # codegen
|
|
|
96
96
|
bunx comfy-ts outline [file] [--section Name] [--lines N] # inspect a sdk.d.ts
|
|
97
97
|
bunx comfy-ts loras [--id <host-id>] [--host http://…] # mirror lora metadata (optional ComfyUI-Lora-Manager extension)
|
|
98
98
|
bunx comfy-ts tui [dir | module.cflow.ts] # interactive tweak & re-run
|
|
99
|
+
bunx comfy-ts run <name | module.cflow.ts> [--draft <name>] [--<var> <value>…] [--out <path>] [--json] # one generation, headless
|
|
99
100
|
```
|
|
100
101
|
|
|
102
|
+
`comfy-ts run` is how an agent generates: the module is found in the cwd, then in the bundled examples, by key or a unique part of it (`folder/name` narrows, like `rvion/anima`). Every var is a flag (`--prompt "…" --seed 7 --image in.png`, `--<var>-file` reads a text var from a file), `--out` says where the output goes, and `--json` prints one line with every output path. `comfy-ts run <name> --help` lists the vars. Every flag is a var name the module declares. A media var declared with `sidecarText: someTextVar` fills that text var from `<file>.txt` beside the file it is given (a voice clip's transcript, example 15).
|
|
103
|
+
|
|
101
104
|
`comfy-ts loras` writes `.comfy-ts/hosts/<id>/loras.json`: per lora, the model's real name, its civitai trigger words, tags, base model and preview url, stored raw. It is what makes `v.prompt(text, { loraKeywordsFrom: lorasVar })` inject a lora's trigger words with nothing typed by hand, and what lets the TUI find a lora by its human name. Read it yourself (`getLoraInfo`, `getLoraTriggerWords`, `getLoraDisplayName`) when a user asks which lora to pick. Absent extension or no sync yet: every getter answers empty, nothing breaks.
|
|
102
105
|
|
|
103
106
|
The TUI scans `**/*.cflow.ts` (no arg: cwd PLUS the examples bundled with the package, grouped apart in the tree; an explicit dir or file limits to that scope), shows vars as editable knobs, runs with live progress and previews, and saves named drafts under `.comfy-ts/drafts/`. It re-execs through bun when launched under node (workflow modules are TypeScript, and node cannot import .ts from node_modules). Point users at it; as an agent you run modules with `bun path/to/module.cflow.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comfyui",
|
package/src/cli/comfy-ts-cli.ts
CHANGED
|
@@ -39,6 +39,15 @@ Usage:
|
|
|
39
39
|
panel. No bundled examples, no auth, and any origin may call it: use
|
|
40
40
|
--host beyond localhost only on a network you trust.
|
|
41
41
|
|
|
42
|
+
comfy-ts run <name | module.cflow.ts> [--draft <name>] [--<var> <value>…] [--out <path>] [--json]
|
|
43
|
+
ONE generation, headless, with live progress: the module is found in cwd,
|
|
44
|
+
then in the examples bundled with comfy-ts, by its key (10-anima-t2i), its
|
|
45
|
+
key without the number (anima-t2i) or a unique part (anima). Each var is a
|
|
46
|
+
flag (--prompt "…" --seed 7 --image in.png), --<var>-file reads a text var
|
|
47
|
+
from a file, --out writes the output there (several: a-1.png, a-2.png; a
|
|
48
|
+
dir keeps the server's names). \`comfy-ts run <name> --help\` lists the vars,
|
|
49
|
+
\`comfy-ts run\` lists the modules. --json prints one line with the paths
|
|
50
|
+
|
|
42
51
|
comfy-ts help
|
|
43
52
|
`
|
|
44
53
|
|
|
@@ -47,7 +56,7 @@ async function main(): Promise<number> {
|
|
|
47
56
|
if (cmd === 'gen') return runGen(rest)
|
|
48
57
|
if (cmd === 'outline') return runOutline(rest)
|
|
49
58
|
if (cmd === 'loras') return runLoras(rest)
|
|
50
|
-
if (cmd === 'tui' || cmd === 'serve') {
|
|
59
|
+
if (cmd === 'tui' || cmd === 'serve' || cmd === 'run') {
|
|
51
60
|
// .cflow.ts workflow modules need bun: node refuses to strip types under
|
|
52
61
|
// node_modules, exactly where the packaged examples live — and the bin's
|
|
53
62
|
// node shebang means `bunx comfy-ts tui|serve` lands here under NODE. Hop
|
|
@@ -60,6 +69,10 @@ async function main(): Promise<number> {
|
|
|
60
69
|
`[comfy-ts ${cmd}] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`,
|
|
61
70
|
)
|
|
62
71
|
}
|
|
72
|
+
if (cmd === 'run') {
|
|
73
|
+
const { runRun } = await import('src/cli/run/run-run.ts')
|
|
74
|
+
return runRun(rest)
|
|
75
|
+
}
|
|
63
76
|
if (cmd === 'serve') {
|
|
64
77
|
const { runServe } = await import('src/cli/serve/run-serve.ts')
|
|
65
78
|
return runServe(rest)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// the `*.cflow.ts` modules under the cwd for `comfy-ts run`, walked with bounds: node_modules
|
|
2
|
+
// and dot dirs are never entered (a recursive readdir reads all of them before any filter,
|
|
3
|
+
// which stalls a run started in a big repo or a temp dir), and the walk stops MAX_DEPTH deep
|
|
4
|
+
import { existsSync, readdirSync } from 'node:fs'
|
|
5
|
+
import { dirname, join } from 'pathe'
|
|
6
|
+
|
|
7
|
+
export const MAX_DEPTH = 5
|
|
8
|
+
|
|
9
|
+
export function findModules(dir: string, depth = 0): string[] {
|
|
10
|
+
let entries: import('node:fs').Dirent[]
|
|
11
|
+
try {
|
|
12
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
13
|
+
} catch {
|
|
14
|
+
return []
|
|
15
|
+
}
|
|
16
|
+
const out: string[] = []
|
|
17
|
+
for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
18
|
+
if (e.isFile() && /\.cflow\.tsx?$/.test(e.name)) out.push(join(dir, e.name))
|
|
19
|
+
else if (e.isDirectory() && depth < MAX_DEPTH && e.name !== 'node_modules' && !e.name.startsWith('.'))
|
|
20
|
+
out.push(...findModules(join(dir, e.name), depth + 1))
|
|
21
|
+
}
|
|
22
|
+
return out
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** the workspace a module belongs to: the nearest folder above it holding `.comfy-ts/` (its
|
|
26
|
+
* schema cache and its tuned drafts), or null. A run roots comfy-ts there, so it never writes a
|
|
27
|
+
* `.comfy-ts/` into whatever folder it was started from */
|
|
28
|
+
export function workspaceOf(file: string): string | null {
|
|
29
|
+
let dir = dirname(file)
|
|
30
|
+
while (true) {
|
|
31
|
+
if (existsSync(join(dir, '.comfy-ts'))) return dir
|
|
32
|
+
const up = dirname(dir)
|
|
33
|
+
if (up === dir) return null
|
|
34
|
+
dir = up
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// one `--<var> <value>` flag, a string on the command line, as the value serve's payload takes
|
|
2
|
+
// for that var kind (applyVarPayload validates it after, so this only shapes, never judges)
|
|
3
|
+
import { isAbsolute, resolve } from 'pathe'
|
|
4
|
+
import type { ChoiceSelect, VarKind } from 'src/vars/ComfyVars.ts'
|
|
5
|
+
|
|
6
|
+
export type FlagSpec = { kind: VarKind; select?: ChoiceSelect }
|
|
7
|
+
|
|
8
|
+
const TRUE = new Set(['true', 'yes', '1', 'on'])
|
|
9
|
+
const FALSE = new Set(['false', 'no', '0', 'off'])
|
|
10
|
+
|
|
11
|
+
/** `raw` is `true` for a bare flag (`--upscale`) */
|
|
12
|
+
export function flagValue(p: {
|
|
13
|
+
name: string
|
|
14
|
+
spec: FlagSpec
|
|
15
|
+
raw: string | true
|
|
16
|
+
cwd: string
|
|
17
|
+
}): { value: unknown } | { error: string } {
|
|
18
|
+
const raw = p.raw
|
|
19
|
+
if (p.spec.kind === 'toggle') {
|
|
20
|
+
if (raw === true) return { value: true }
|
|
21
|
+
const v = raw.toLowerCase()
|
|
22
|
+
if (TRUE.has(v)) return { value: true }
|
|
23
|
+
if (FALSE.has(v)) return { value: false }
|
|
24
|
+
return { error: `--${p.name} is a toggle: true or false` }
|
|
25
|
+
}
|
|
26
|
+
if (raw === true) return { error: `--${p.name} needs a value` }
|
|
27
|
+
switch (p.spec.kind) {
|
|
28
|
+
case 'int':
|
|
29
|
+
case 'float':
|
|
30
|
+
return { value: raw }
|
|
31
|
+
case 'seed': {
|
|
32
|
+
// a random seed as a number: serve rerolls a '?' mode only when the payload leaves the seed out
|
|
33
|
+
if (raw === '?') return { value: Math.floor(Math.random() * 2 ** 32) }
|
|
34
|
+
const n = Number(raw)
|
|
35
|
+
return Number.isFinite(n) ? { value: n } : { error: `--${p.name} is a seed: a number, or ? for a random one` }
|
|
36
|
+
}
|
|
37
|
+
case 'choice':
|
|
38
|
+
if (p.spec.select === 'many')
|
|
39
|
+
return {
|
|
40
|
+
value: raw
|
|
41
|
+
.split(',')
|
|
42
|
+
.map((x) => x.trim())
|
|
43
|
+
.filter((x) => x !== ''),
|
|
44
|
+
}
|
|
45
|
+
if (p.spec.select === 'zero-or-one' && raw === 'none') return { value: null }
|
|
46
|
+
return { value: raw }
|
|
47
|
+
case 'loras':
|
|
48
|
+
try {
|
|
49
|
+
return { value: JSON.parse(raw) }
|
|
50
|
+
} catch {
|
|
51
|
+
return { error: `--${p.name} takes the loras as json, like '{"name.safetensors": 0.8}'` }
|
|
52
|
+
}
|
|
53
|
+
case 'image':
|
|
54
|
+
case 'audio':
|
|
55
|
+
case 'video':
|
|
56
|
+
// a url goes through as is: serve downloads it
|
|
57
|
+
return { value: /^https?:\/\//.test(raw) || isAbsolute(raw) ? raw : resolve(p.cwd, raw) }
|
|
58
|
+
default:
|
|
59
|
+
return { value: raw }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// where `comfy-ts run` writes each output. `--out a.png` and one output: exactly there, its
|
|
2
|
+
// extension swapped for the output's own when they differ (said on the line); several outputs
|
|
3
|
+
// are numbered (`a-1.png`); a dir keeps the server's filenames; no --out names them after the
|
|
4
|
+
// module and the prompt in the cwd. Pure: the caller says whether --out is a dir
|
|
5
|
+
import { basename, extname, join, resolve } from 'pathe'
|
|
6
|
+
|
|
7
|
+
export type Produced = { filename: string }
|
|
8
|
+
export type Destination = { path: string; note: string | null }
|
|
9
|
+
|
|
10
|
+
export function outputPaths(p: {
|
|
11
|
+
out: string | null
|
|
12
|
+
outIsDir: boolean
|
|
13
|
+
module: string
|
|
14
|
+
promptId: string
|
|
15
|
+
items: readonly Produced[]
|
|
16
|
+
cwd: string
|
|
17
|
+
}): Destination[] {
|
|
18
|
+
const n = p.items.length
|
|
19
|
+
if (p.out != null && p.outIsDir) {
|
|
20
|
+
const dir = resolve(p.cwd, p.out)
|
|
21
|
+
return p.items.map((it) => ({ path: join(dir, basename(it.filename)), note: null }))
|
|
22
|
+
}
|
|
23
|
+
const base = p.out == null ? join(p.cwd, `${p.module}-${p.promptId.slice(0, 8)}`) : resolve(p.cwd, p.out)
|
|
24
|
+
const asked = p.out == null ? '' : extname(base)
|
|
25
|
+
const stem = asked === '' ? base : base.slice(0, -asked.length)
|
|
26
|
+
return p.items.map((it, ix) => {
|
|
27
|
+
const own = extname(it.filename)
|
|
28
|
+
const path = `${stem}${n > 1 ? `-${ix + 1}` : ''}${own}`
|
|
29
|
+
const note =
|
|
30
|
+
asked !== '' && own !== '' && asked.toLowerCase() !== own.toLowerCase()
|
|
31
|
+
? `the output is ${own}, not ${asked}`
|
|
32
|
+
: null
|
|
33
|
+
return { path, note }
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** the transcript or text beside the first media output: same stem, `.txt` */
|
|
38
|
+
export function sidecarPath(mediaPath: string): string {
|
|
39
|
+
const ext = extname(mediaPath)
|
|
40
|
+
return `${ext === '' ? mediaPath : mediaPath.slice(0, -ext.length)}.txt`
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// `comfy-ts run <name>`: which module a name means, over the discovered files in their order
|
|
2
|
+
// (cwd first, then the bundled examples). A name may carry its folder (`rvion/anima`,
|
|
3
|
+
// `comfy-cloud/anima`), which narrows to modules in a folder of that name. Tiers, first hit
|
|
4
|
+
// wins: the exact module key, the key without its number (`anima-t2i` → `10-anima-t2i`), a
|
|
5
|
+
// prefix of that, a substring. Two modules on the first tier that hits is ambiguous, and the
|
|
6
|
+
// error names them with their folder
|
|
7
|
+
import { basename, dirname } from 'pathe'
|
|
8
|
+
import { moduleName } from 'src/cli/tui/treeRows.ts'
|
|
9
|
+
|
|
10
|
+
export type Picked = { file: string; key: string } | { error: string }
|
|
11
|
+
|
|
12
|
+
const bare = (key: string): string => key.replace(/^\d+-/, '')
|
|
13
|
+
const qualified = (file: string): string => `${basename(dirname(file))}/${moduleName(file)}`
|
|
14
|
+
|
|
15
|
+
export function pickModule(files: readonly string[], name: string): Picked {
|
|
16
|
+
const cut = name.lastIndexOf('/')
|
|
17
|
+
const folder = cut < 0 ? null : name.slice(0, cut).toLowerCase()
|
|
18
|
+
const n = name.slice(cut + 1).toLowerCase()
|
|
19
|
+
// one file per qualified name, the first one found: a cwd module shadows a bundled one
|
|
20
|
+
const byName = new Map<string, string>()
|
|
21
|
+
for (const f of files) {
|
|
22
|
+
if (folder != null && !qualified(f).toLowerCase().startsWith(`${folder}/`)) continue
|
|
23
|
+
if (!byName.has(qualified(f))) byName.set(qualified(f), f)
|
|
24
|
+
}
|
|
25
|
+
const all = [...byName.values()]
|
|
26
|
+
const tiers: ((k: string) => boolean)[] = [
|
|
27
|
+
(k) => k === n,
|
|
28
|
+
(k) => bare(k) === n,
|
|
29
|
+
(k) => bare(k).startsWith(n),
|
|
30
|
+
(k) => k.includes(n),
|
|
31
|
+
]
|
|
32
|
+
for (const hit of tiers) {
|
|
33
|
+
const found = all.filter((f) => hit(moduleName(f).toLowerCase()))
|
|
34
|
+
if (found.length === 1) return { file: found[0]!, key: moduleName(found[0]!) }
|
|
35
|
+
if (found.length > 1)
|
|
36
|
+
return {
|
|
37
|
+
error: `'${name}' matches ${found.length} modules: ${found.map(qualified).join(', ')}. Name one, folder included`,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { error: `no module matches '${name}'. Modules: ${all.map(qualified).join(', ')}` }
|
|
41
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// `comfy-ts run`: one generation from the command line, headless (architecture.md item 15).
|
|
2
|
+
// It is serve's generate path in process: a ServeApp over the one module, handle(POST
|
|
3
|
+
// /generate/…), so drafts, payload checks, the media gate and seeds are serve's own code. Only
|
|
4
|
+
// the starter differs (live progress, nothing saved by the runner) and the outputs land where
|
|
5
|
+
// --out says
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
|
|
7
|
+
import { pathToFileURL } from 'node:url'
|
|
8
|
+
import { basename, dirname, resolve } from 'pathe'
|
|
9
|
+
import type { DefinedWorkflow } from 'src/vars/DefinedWorkflow.ts'
|
|
10
|
+
import { flagValue, type FlagSpec } from 'src/cli/run/flagValue.ts'
|
|
11
|
+
import { outputPaths, sidecarPath } from 'src/cli/run/outputPaths.ts'
|
|
12
|
+
import { pickModule } from 'src/cli/run/pickModule.ts'
|
|
13
|
+
import { sidecarFills } from 'src/cli/run/sidecar.ts'
|
|
14
|
+
import { parseRunArgs } from 'src/cli/run/runArgs.ts'
|
|
15
|
+
import { describeVar, renderDescriptorLine } from 'src/cli/serve/describeVar.ts'
|
|
16
|
+
import { ServeApp, type ServeExecution, type ServeStarter } from 'src/cli/serve/ServeApp.ts'
|
|
17
|
+
import { findModules, workspaceOf } from 'src/cli/run/findModules.ts'
|
|
18
|
+
import { mergeWorkflowSources, scanCflowFiles } from 'src/cli/tui/discoverWorkflows.ts'
|
|
19
|
+
import { findDefinedWorkflow } from 'src/cli/tui/findDefinedWorkflow.ts'
|
|
20
|
+
import { moduleName } from 'src/cli/tui/treeRows.ts'
|
|
21
|
+
import { bundledExamplesDir } from 'src/exampleAssets.ts'
|
|
22
|
+
import { ComfyTS } from 'src/state.ts'
|
|
23
|
+
import { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'
|
|
24
|
+
|
|
25
|
+
const USAGE = `comfy-ts run <name | module.cflow.ts> [--draft <name>] [--<var> <value>…] [--out <path>] [--json]
|
|
26
|
+
one generation, headless, with live progress. <name> is a module key (10-anima-t2i), the key
|
|
27
|
+
without its number (anima-t2i), or a unique part of it (anima). \`comfy-ts run <name> --help\`
|
|
28
|
+
lists the module's vars. --<var>-file <path> reads a text var from a file. --out a.png writes
|
|
29
|
+
there (several outputs: a-1.png, a-2.png), --out dir/ keeps the server's names, no --out
|
|
30
|
+
writes <module>-<id>.<ext> here. Text outputs go beside the first media output as <stem>.txt.
|
|
31
|
+
--json prints one line with every output path, --verbose shows the library log on stderr`
|
|
32
|
+
|
|
33
|
+
type Out = { path: string; note: string | null; bytes: Uint8Array | null; from: string | null }
|
|
34
|
+
|
|
35
|
+
function discover(cwd: string): string[] {
|
|
36
|
+
const bundledDir = bundledExamplesDir()
|
|
37
|
+
return mergeWorkflowSources({
|
|
38
|
+
explicitTarget: false,
|
|
39
|
+
scanned: findModules(cwd),
|
|
40
|
+
bundledFiles: bundledDir == null ? [] : scanCflowFiles(bundledDir),
|
|
41
|
+
}).files
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const log = (line: string): void => void process.stderr.write(`${line}\n`)
|
|
45
|
+
|
|
46
|
+
export async function runRun(argv: string[]): Promise<number> {
|
|
47
|
+
const args = parseRunArgs(argv)
|
|
48
|
+
if ('error' in args) {
|
|
49
|
+
log(`[comfy-ts run] ${args.error}`)
|
|
50
|
+
return 1
|
|
51
|
+
}
|
|
52
|
+
// stdout carries the result lines only (one json line under --json): the library's info
|
|
53
|
+
// chatter is silenced, and a stray console.log reaches stderr under --verbose, else nowhere
|
|
54
|
+
const say = console.log.bind(console)
|
|
55
|
+
if (!args.verbose) process.env.COMFY_TS_QUIET = '1'
|
|
56
|
+
console.log = (...a: unknown[]): void => {
|
|
57
|
+
if (args.verbose) console.error(...a)
|
|
58
|
+
}
|
|
59
|
+
const cwd = process.cwd()
|
|
60
|
+
const explicit = args.name != null && /\.cflow\.tsx?$/.test(args.name) ? resolve(cwd, args.name) : null
|
|
61
|
+
const files = explicit != null ? [explicit] : discover(cwd)
|
|
62
|
+
if (args.name == null) {
|
|
63
|
+
say(USAGE)
|
|
64
|
+
const names = [...new Set(files.map((f) => `${basename(dirname(f))}/${moduleName(f)}`))]
|
|
65
|
+
say(`\nmodules:\n${names.map((k) => ` ${k}`).join('\n')}`)
|
|
66
|
+
return 0
|
|
67
|
+
}
|
|
68
|
+
if (explicit != null && !existsSync(explicit)) {
|
|
69
|
+
log(`[comfy-ts run] no such file: ${explicit}`)
|
|
70
|
+
return 1
|
|
71
|
+
}
|
|
72
|
+
const picked = explicit != null ? { file: explicit, key: moduleName(explicit) } : pickModule(files, args.name)
|
|
73
|
+
if ('error' in picked) {
|
|
74
|
+
log(`[comfy-ts run] ${picked.error}`)
|
|
75
|
+
return 1
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// rooted at the module's workspace before its import registers one at the cwd: its schema
|
|
79
|
+
// cache and drafts are there, and --out and media paths still resolve against the cwd
|
|
80
|
+
ComfyTS.create({ rootPath: workspaceOf(picked.file) ?? cwd })
|
|
81
|
+
let dw: DefinedWorkflow
|
|
82
|
+
try {
|
|
83
|
+
const found = findDefinedWorkflow((await import(pathToFileURL(picked.file).href)) as Record<string, unknown>)
|
|
84
|
+
if (found == null) throw new Error('it exports no DefinedWorkflow')
|
|
85
|
+
dw = found
|
|
86
|
+
} catch (e) {
|
|
87
|
+
log(`[comfy-ts run] ${picked.file}: ${extractErrorMessage(e)}`)
|
|
88
|
+
return 1
|
|
89
|
+
}
|
|
90
|
+
const vars = new Map(dw.entries())
|
|
91
|
+
|
|
92
|
+
if (args.help) {
|
|
93
|
+
say(`comfy-ts run ${picked.key} (${picked.file})\n\nvars, each one a --<name> <value> flag:`)
|
|
94
|
+
const width = Math.max(0, ...[...vars.keys()].map((k) => k.length))
|
|
95
|
+
for (const [k, v] of vars) {
|
|
96
|
+
const d = describeVar(v)
|
|
97
|
+
// the cli's own forms where they differ from serve's json payload
|
|
98
|
+
const payload =
|
|
99
|
+
v.kind === 'seed'
|
|
100
|
+
? 'a number, or ? for a random one'
|
|
101
|
+
: v.kind === 'toggle'
|
|
102
|
+
? 'true | false, or the bare flag'
|
|
103
|
+
: v.kind === 'text' || v.kind === 'prompt'
|
|
104
|
+
? `${d.payload}, or --${k}-file <path>`
|
|
105
|
+
: d.payload
|
|
106
|
+
say(renderDescriptorLine(k, { ...d, payload }, width))
|
|
107
|
+
}
|
|
108
|
+
return 0
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// the flags, shaped by each var's own kind
|
|
112
|
+
const payload: Record<string, unknown> = {}
|
|
113
|
+
for (const [name, raw] of args.vars) {
|
|
114
|
+
const fileOf = name.endsWith('-file') ? name.slice(0, -'-file'.length) : null
|
|
115
|
+
const target = fileOf != null && vars.has(fileOf) ? fileOf : name
|
|
116
|
+
const v = vars.get(target)
|
|
117
|
+
if (v == null) {
|
|
118
|
+
log(`[comfy-ts run] ${picked.key} has no var '${name}'. Vars: ${[...vars.keys()].join(', ')}`)
|
|
119
|
+
return 1
|
|
120
|
+
}
|
|
121
|
+
if (target !== name) {
|
|
122
|
+
if (raw === true) {
|
|
123
|
+
log(`[comfy-ts run] --${name} needs a path`)
|
|
124
|
+
return 1
|
|
125
|
+
}
|
|
126
|
+
const path = resolve(cwd, raw)
|
|
127
|
+
if (!existsSync(path)) {
|
|
128
|
+
log(`[comfy-ts run] --${name}: no such file ${path}`)
|
|
129
|
+
return 1
|
|
130
|
+
}
|
|
131
|
+
payload[target] = readFileSync(path, 'utf8').trim()
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
// kind, never instanceof (agent/coding.md cast whitelist 6)
|
|
135
|
+
const spec: FlagSpec = { kind: v.kind, select: v.kind === 'choice' ? describeVar(v).select : undefined }
|
|
136
|
+
const shaped = flagValue({ name, spec, raw, cwd })
|
|
137
|
+
if ('error' in shaped) {
|
|
138
|
+
log(`[comfy-ts run] ${shaped.error}`)
|
|
139
|
+
return 1
|
|
140
|
+
}
|
|
141
|
+
payload[name] = shaped.value
|
|
142
|
+
}
|
|
143
|
+
// a media file's <file>.txt fills the text var its declaration links (a clip's transcript)
|
|
144
|
+
for (const fill of sidecarFills([...vars], payload, existsSync)) {
|
|
145
|
+
payload[fill.name] = readFileSync(fill.from, 'utf8').trim()
|
|
146
|
+
if (!args.json) log(` ${fill.name} from ${fill.from}`)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let execution: ServeExecution | null = null
|
|
150
|
+
const starter: ServeStarter = async (mod, opts) => {
|
|
151
|
+
const host = opts.host ?? mod.dw.host
|
|
152
|
+
await host.connect()
|
|
153
|
+
const wf = await mod.dw.build({ advance: true, host })
|
|
154
|
+
const ex = await wf.start({ save: false, log: !args.json })
|
|
155
|
+
execution = ex
|
|
156
|
+
return ex
|
|
157
|
+
}
|
|
158
|
+
const app = new ServeApp([{ key: picked.key, file: picked.file, dw }], { starter })
|
|
159
|
+
if (!args.json) log(`▶ ${dw.host.data.id} · ${picked.key}/${args.draft}`)
|
|
160
|
+
const t0 = Date.now()
|
|
161
|
+
let code = 0
|
|
162
|
+
try {
|
|
163
|
+
const reply = await app.handle({
|
|
164
|
+
method: 'POST',
|
|
165
|
+
url: `/generate/${encodeURIComponent(picked.key)}/${encodeURIComponent(args.draft)}`,
|
|
166
|
+
body: JSON.stringify(payload),
|
|
167
|
+
})
|
|
168
|
+
const body = JSON.parse(typeof reply.body === 'string' ? reply.body : new TextDecoder().decode(reply.body)) as {
|
|
169
|
+
ok?: boolean
|
|
170
|
+
error?: string
|
|
171
|
+
seeds?: Record<string, number>
|
|
172
|
+
promptId?: string
|
|
173
|
+
durationMs?: number
|
|
174
|
+
}
|
|
175
|
+
const ex = execution as ServeExecution | null
|
|
176
|
+
if (reply.status !== 200 || body.ok !== true || ex == null) {
|
|
177
|
+
const error = body.error ?? `serve answered ${reply.status}`
|
|
178
|
+
if (args.json) say(JSON.stringify({ ok: false, module: picked.key, draft: args.draft, error }))
|
|
179
|
+
else log(`\n✗ ${picked.key}/${args.draft}: ${error}`)
|
|
180
|
+
return 1
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const media: { filename: string; bytes: Uint8Array | null; from: string | null }[] = [
|
|
184
|
+
...ex.images.map((i) => ({ filename: i.filename, bytes: i.buffer ?? null, from: i.absPath })),
|
|
185
|
+
...(ex.audios ?? []).map((a) => ({ filename: a.filename, bytes: a.bytes, from: a.absPath })),
|
|
186
|
+
...(ex.videos ?? []).map((a) => ({ filename: a.filename, bytes: a.bytes, from: a.absPath })),
|
|
187
|
+
]
|
|
188
|
+
const outIsDir =
|
|
189
|
+
args.out != null &&
|
|
190
|
+
(/[/\\]$/.test(args.out) ||
|
|
191
|
+
(existsSync(resolve(cwd, args.out)) && statSync(resolve(cwd, args.out)).isDirectory()))
|
|
192
|
+
const dests = outputPaths({
|
|
193
|
+
out: args.out,
|
|
194
|
+
outIsDir,
|
|
195
|
+
module: picked.key,
|
|
196
|
+
promptId: body.promptId ?? ex.data.id,
|
|
197
|
+
items: media,
|
|
198
|
+
cwd,
|
|
199
|
+
})
|
|
200
|
+
const outs: Out[] = media.map((m, i) => ({ ...dests[i]!, bytes: m.bytes, from: m.from }))
|
|
201
|
+
for (const o of outs) {
|
|
202
|
+
const bytes = o.bytes ?? (o.from != null ? new Uint8Array(readFileSync(o.from)) : null)
|
|
203
|
+
if (bytes == null) throw new Error(`an output of ${picked.key} came back with no bytes`)
|
|
204
|
+
mkdirSync(dirname(o.path), { recursive: true })
|
|
205
|
+
writeFileSync(o.path, bytes)
|
|
206
|
+
}
|
|
207
|
+
const texts = (ex.texts ?? []).map((t) => t.text)
|
|
208
|
+
const written = outs.map((o) => o.path)
|
|
209
|
+
if (texts.length > 0) {
|
|
210
|
+
const first = outs[0]
|
|
211
|
+
if (first != null) {
|
|
212
|
+
writeFileSync(sidecarPath(first.path), `${texts.join('\n')}\n`)
|
|
213
|
+
written.push(sidecarPath(first.path))
|
|
214
|
+
} else if (args.out != null && !outIsDir) {
|
|
215
|
+
const path = resolve(cwd, args.out)
|
|
216
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
217
|
+
writeFileSync(path, `${texts.join('\n')}\n`)
|
|
218
|
+
written.push(path)
|
|
219
|
+
} else if (!args.json) for (const t of texts) say(t)
|
|
220
|
+
}
|
|
221
|
+
const durationMs = body.durationMs ?? Date.now() - t0
|
|
222
|
+
if (args.json)
|
|
223
|
+
say(
|
|
224
|
+
JSON.stringify({
|
|
225
|
+
ok: true,
|
|
226
|
+
module: picked.key,
|
|
227
|
+
draft: args.draft,
|
|
228
|
+
seeds: body.seeds ?? {},
|
|
229
|
+
durationMs,
|
|
230
|
+
outputs: written,
|
|
231
|
+
texts,
|
|
232
|
+
}),
|
|
233
|
+
)
|
|
234
|
+
else {
|
|
235
|
+
const seeds = Object.entries(body.seeds ?? {})
|
|
236
|
+
.map(([k, v]) => `${k} ${v}`)
|
|
237
|
+
.join(', ')
|
|
238
|
+
for (const o of outs) log(`✓ ${o.path}${o.note == null ? '' : ` (${o.note})`}`)
|
|
239
|
+
for (const w of written.slice(outs.length)) log(`✓ ${w}`)
|
|
240
|
+
log(` ${(durationMs / 1000).toFixed(1)}s${seeds === '' ? '' : ` · ${seeds}`}`)
|
|
241
|
+
if (written.length === 0) log(' the run produced no output')
|
|
242
|
+
}
|
|
243
|
+
} catch (e) {
|
|
244
|
+
log(`[comfy-ts run] 🔴 ${extractErrorMessage(e)}`)
|
|
245
|
+
code = 1
|
|
246
|
+
} finally {
|
|
247
|
+
for (const [, h] of comfyts.hosts) h.disconnect()
|
|
248
|
+
}
|
|
249
|
+
return code
|
|
250
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// `comfy-ts run [name] [--draft d] [--out p] [--json] [--verbose] [--help] [--<var> value | --<var>=value | --<toggle>]`
|
|
2
|
+
// Pure: the vars stay strings here, the module's own var kinds shape them later (flagValue)
|
|
3
|
+
|
|
4
|
+
export type RunArgs = {
|
|
5
|
+
name: string | null
|
|
6
|
+
draft: string
|
|
7
|
+
out: string | null
|
|
8
|
+
json: boolean
|
|
9
|
+
/** the library's own log lines, on stderr */
|
|
10
|
+
verbose: boolean
|
|
11
|
+
help: boolean
|
|
12
|
+
/** in command line order; `true` = a bare flag */
|
|
13
|
+
vars: [string, string | true][]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const OWN = new Set(['draft', 'out'])
|
|
17
|
+
|
|
18
|
+
export function parseRunArgs(argv: readonly string[]): RunArgs | { error: string } {
|
|
19
|
+
const r: RunArgs = { name: null, draft: 'default', out: null, json: false, verbose: false, help: false, vars: [] }
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
const a = argv[i]!
|
|
22
|
+
if (a === '-h' || a === '--help') {
|
|
23
|
+
r.help = true
|
|
24
|
+
continue
|
|
25
|
+
}
|
|
26
|
+
if (a === '--json') {
|
|
27
|
+
r.json = true
|
|
28
|
+
continue
|
|
29
|
+
}
|
|
30
|
+
if (a === '--verbose') {
|
|
31
|
+
r.verbose = true
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
if (!a.startsWith('--')) {
|
|
35
|
+
if (r.name != null) return { error: `one module per run: got '${r.name}' and '${a}'` }
|
|
36
|
+
r.name = a
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
const eq = a.indexOf('=')
|
|
40
|
+
const key = eq < 0 ? a.slice(2) : a.slice(2, eq)
|
|
41
|
+
if (key === '') return { error: `'${a}' names no var` }
|
|
42
|
+
let value: string | true
|
|
43
|
+
if (eq >= 0) value = a.slice(eq + 1)
|
|
44
|
+
else {
|
|
45
|
+
const next = argv[i + 1]
|
|
46
|
+
if (next == null || next.startsWith('--')) value = true
|
|
47
|
+
else {
|
|
48
|
+
value = next
|
|
49
|
+
i++
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (OWN.has(key)) {
|
|
53
|
+
if (value === true) return { error: `--${key} needs a value` }
|
|
54
|
+
if (key === 'draft') r.draft = value
|
|
55
|
+
else r.out = value
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
58
|
+
r.vars.push([key, value])
|
|
59
|
+
}
|
|
60
|
+
return r
|
|
61
|
+
}
|