nanoodle 0.5.0 → 0.6.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 +6 -0
- package/package.json +1 -1
- package/src/graph.mjs +11 -0
- package/src/io.mjs +8 -4
- package/src/nodes.mjs +23 -4
- package/src/workflow.mjs +7 -1
package/README.md
CHANGED
|
@@ -119,6 +119,12 @@ keys are the sink node’s custom name (or its type name). A workflow with
|
|
|
119
119
|
exactly one required input also accepts a bare value: `wf.run("hello")`.
|
|
120
120
|
Settings use `nodeId.field` keys (`"n3.model"`).
|
|
121
121
|
|
|
122
|
+
An input is `optional` when its node-type spec says so (LLM system prompts),
|
|
123
|
+
or when the author checked **optional** on the node in the editor (saved as
|
|
124
|
+
`fields.optional`). Optional inputs can be omitted: the run proceeds and the
|
|
125
|
+
node yields an empty value (an omitted optional image/audio/video input is
|
|
126
|
+
simply dropped by downstream reference-style consumers).
|
|
127
|
+
|
|
122
128
|
### Media inputs
|
|
123
129
|
|
|
124
130
|
```js
|
package/package.json
CHANGED
package/src/graph.mjs
CHANGED
|
@@ -73,6 +73,17 @@ export function displayName(node) {
|
|
|
73
73
|
return (t && t.title) || node.type || "?";
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Author-marked optional node: fields.optional (the editor's "optional" checkbox on
|
|
78
|
+
* input nodes) makes every input this node surfaces skippable — the run proceeds and
|
|
79
|
+
* the node yields an empty value instead of failing. Serialized inside fields so it
|
|
80
|
+
* survives save/share/materialize with zero format changes.
|
|
81
|
+
*/
|
|
82
|
+
export function optionalNode(node) {
|
|
83
|
+
const v = node && node.fields && node.fields.optional;
|
|
84
|
+
return v === true || v === "true";
|
|
85
|
+
}
|
|
86
|
+
|
|
76
87
|
/** Is a wire landing on `port` of `node` a data input (vs a field override)? */
|
|
77
88
|
export function isInputPort(node, port) {
|
|
78
89
|
const t = NODE_TYPES[node.type];
|
package/src/io.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NanoodleError } from "./errors.mjs";
|
|
2
|
-
import { NODE_TYPES, displayName, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
|
|
2
|
+
import { NODE_TYPES, displayName, optionalNode, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
|
|
3
3
|
|
|
4
4
|
/* ============================== INPUTS ============================== */
|
|
5
5
|
|
|
@@ -31,7 +31,7 @@ export function deriveInputs(graph) {
|
|
|
31
31
|
const mk = (n, field, label, kind, optional, specDef) => {
|
|
32
32
|
const cur = n.fields[field];
|
|
33
33
|
return {
|
|
34
|
-
nodeId: n.id, field, label, kind, optional: !!optional,
|
|
34
|
+
nodeId: n.id, field, label, kind, optional: !!optional || optionalNode(n),
|
|
35
35
|
def: cur != null && String(cur) !== "" ? cur : specDef,
|
|
36
36
|
title: displayName(n), _node: n,
|
|
37
37
|
};
|
|
@@ -67,13 +67,17 @@ export function deriveInputs(graph) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
// Friendly keys: a node's custom name labels its input when it contributes exactly one
|
|
70
|
-
// REQUIRED input (app PR #138)
|
|
70
|
+
// REQUIRED input (app PR #138) — or exactly one input at all, so an author-optional
|
|
71
|
+
// renamed node (e.g. an optional "Style reference" upload) keeps its name as the key.
|
|
72
|
+
// Otherwise the generic spec label. Dedupe with " 2", " 3".
|
|
71
73
|
const used = new Map();
|
|
72
74
|
for (const e of entries) {
|
|
73
75
|
const nodeEntries = entries.filter((x) => x.nodeId === e.nodeId);
|
|
74
76
|
const required = nodeEntries.filter((x) => !x.optional);
|
|
75
77
|
const custom = (e._node.name || "").trim();
|
|
76
|
-
|
|
78
|
+
const names = (required.length === 1 && required[0] === e) ||
|
|
79
|
+
(required.length === 0 && nodeEntries.length === 1);
|
|
80
|
+
let key = custom && names ? custom : e.label;
|
|
77
81
|
const lower = key.toLowerCase();
|
|
78
82
|
const count = (used.get(lower) || 0) + 1;
|
|
79
83
|
used.set(lower, count);
|
package/src/nodes.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NanoodleError } from "./errors.mjs";
|
|
2
2
|
import { catItem, chatModelCan } from "./catalog.mjs";
|
|
3
|
-
import { IMG_PORT_RE, EDIT_IMG_RE, REF_PORT_RE, CLIP_PORT_RE, VID_PORT_RE } from "./graph.mjs";
|
|
3
|
+
import { IMG_PORT_RE, EDIT_IMG_RE, REF_PORT_RE, CLIP_PORT_RE, VID_PORT_RE, optionalNode } from "./graph.mjs";
|
|
4
4
|
import { MEDIA_INLINE_MAX } from "./media.mjs";
|
|
5
5
|
import {
|
|
6
6
|
resizeCropImage, trimAudioToWav, extractAudioToWav,
|
|
@@ -193,6 +193,13 @@ function isValidCustomAir(air) {
|
|
|
193
193
|
// 400 FLUX.2/klein. Mirrors the app.
|
|
194
194
|
function airTakesNegative(air) { return !/^runware:(100|101|103|104|106|107|111|160|400)@/i.test(String(air || "")); }
|
|
195
195
|
|
|
196
|
+
// The NanoGPT catalog also lists AIR-style ids as DIRECT models (e.g. persona:376130@2456367) —
|
|
197
|
+
// same Runware path, same negative_prompt support, same FLUX gate.
|
|
198
|
+
function airModelTakesNegative(model) {
|
|
199
|
+
const m = String(model || "");
|
|
200
|
+
return /^(persona:|civitai:|runware:)/i.test(m) && airTakesNegative(m);
|
|
201
|
+
}
|
|
202
|
+
|
|
196
203
|
/** Per-call image extras: LoRA params + fixed seed (when numeric) + custom-civitai AIR. */
|
|
197
204
|
function imgExtra(n) {
|
|
198
205
|
const e = loraParams(n);
|
|
@@ -209,6 +216,9 @@ function imgExtra(n) {
|
|
|
209
216
|
// probe on persona:376130@2456367 confirmed negative_prompt reaches the sampler (2026-07-18)
|
|
210
217
|
const np = String(n.fields.negativePrompt || "").trim();
|
|
211
218
|
if (np && airTakesNegative(air)) e.negative_prompt = np;
|
|
219
|
+
} else if (airModelTakesNegative(n.fields.model)) {
|
|
220
|
+
const np = String(n.fields.negativePrompt || "").trim();
|
|
221
|
+
if (np) e.negative_prompt = np;
|
|
212
222
|
}
|
|
213
223
|
return e;
|
|
214
224
|
}
|
|
@@ -375,15 +385,24 @@ export const RUNNERS = {
|
|
|
375
385
|
async text(n) { return { text: n.fields.text || "" }; },
|
|
376
386
|
|
|
377
387
|
async upload(n) {
|
|
378
|
-
if (!n.fields.image)
|
|
388
|
+
if (!n.fields.image) {
|
|
389
|
+
if (optionalNode(n)) return { image: "" }; // skipped optional input — consumers drop empty media (collectPorts)
|
|
390
|
+
throw new NanoodleError("no image — this Image input has no image");
|
|
391
|
+
}
|
|
379
392
|
return { image: n.fields.image };
|
|
380
393
|
},
|
|
381
394
|
async aupload(n) {
|
|
382
|
-
if (!n.fields.audio)
|
|
395
|
+
if (!n.fields.audio) {
|
|
396
|
+
if (optionalNode(n)) return { audio: "" };
|
|
397
|
+
throw new NanoodleError("no audio — this Audio input has no clip");
|
|
398
|
+
}
|
|
383
399
|
return { audio: n.fields.audio };
|
|
384
400
|
},
|
|
385
401
|
async vupload(n) {
|
|
386
|
-
if (!n.fields.video)
|
|
402
|
+
if (!n.fields.video) {
|
|
403
|
+
if (optionalNode(n)) return { video: "" };
|
|
404
|
+
throw new NanoodleError("no video — this Video input has no clip");
|
|
405
|
+
}
|
|
387
406
|
return { video: n.fields.video };
|
|
388
407
|
},
|
|
389
408
|
|
package/src/workflow.mjs
CHANGED
|
@@ -360,7 +360,13 @@ export class Workflow {
|
|
|
360
360
|
|
|
361
361
|
const failedSinks = this.outputs.filter((o) => nodesRec[o.nodeId] && nodesRec[o.nodeId].status === "error");
|
|
362
362
|
if (failedSinks.length) {
|
|
363
|
-
|
|
363
|
+
let detail = failedSinks.map((o) => `"${o.key}": ${nodesRec[o.nodeId].error}`).join("; ");
|
|
364
|
+
// "upstream failed: X" only names the sink's neighbor — name the node(s) that actually broke
|
|
365
|
+
const sinkIds = new Set(failedSinks.map((o) => o.nodeId));
|
|
366
|
+
const roots = errors.filter((e) => !sinkIds.has(e.nodeId) && !/^upstream failed: /.test(e.message));
|
|
367
|
+
if (roots.length) {
|
|
368
|
+
detail += ` (root cause — ${roots.map((e) => `"${e.name}": ${e.message}`).join("; ")})`;
|
|
369
|
+
}
|
|
364
370
|
throw new RunError("run failed — " + detail, result);
|
|
365
371
|
}
|
|
366
372
|
return result;
|