nanoodle 0.1.1 → 0.2.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 CHANGED
@@ -39,6 +39,8 @@ npx nanoodle --help # or run the CLI without installing
39
39
  import { Workflow } from "nanoodle";
40
40
 
41
41
  const wf = await Workflow.load("noodle-graph.json"); // key from NANOGPT_API_KEY
42
+ // …or load any nanoodle share link — the URL is the package:
43
+ // const wf = await Workflow.load("https://nanoodle.com/#g=…");
42
44
  const result = await wf.run({ Text: "a cozy ramen shop on a rainy night" });
43
45
  await result.get("Image").save("ramen.png"); // media: MediaRef (url + bytes()/save())
44
46
  console.log(result.costUsd, result.remainingBalance);
@@ -48,24 +50,46 @@ With the app’s starter graph (text → LLM prompt-writer → image), that’s
48
50
 
49
51
  ## Quickstart (CLI)
50
52
 
51
- Inspect first — offline; shows inputs, outputs, and settings:
53
+ No graph yet? Scaffold the starter (text → LLM prompt-writer → image) and
54
+ inspect it — both offline, no key needed:
52
55
 
53
56
  ```bash
54
- npx nanoodle inspect graph.json
57
+ npx nanoodle init # writes ./noodle-graph.json
58
+ npx nanoodle inspect noodle-graph.json # shows inputs, outputs, settings
55
59
  ```
56
60
 
57
61
  Then run (calls NanoGPT and spends from your balance):
58
62
 
59
63
  ```bash
60
64
  export NANOGPT_API_KEY=... # or --key K, or --env-file .env
61
- npx nanoodle run graph.json --input Text="a cozy ramen shop" --out ./out
62
- npx nanoodle run graph.json --input n2.system=@style.txt --set n3.size=1k --json
65
+ npx nanoodle run noodle-graph.json --input Text="a cozy ramen shop on a rainy night"
66
+ npx nanoodle run graph.json --input n2.system=@style.txt --set n3.size=1k --out ./renders
63
67
  ```
64
68
 
65
- - `--env-file path` — load `NANOGPT_API_KEY` from a `.env`-style file (`--key` wins if both are set)
69
+ Media outputs are saved under `--out` (default `./noodle-out`, created only
70
+ when there is media to save); a JSON run summary always goes to stdout,
71
+ progress lines to stderr; exit code `0` on success, `1` on failure.
72
+
66
73
  - `--input k=@path` — read a file (media as media; `.txt` / `.md` / `.json` as text)
67
- - `--out dir` — save media outputs to disk
68
- - `--json` — machine-readable result
74
+ - `--set k=v` — override a setting (`n3.model=flux-pro`)
75
+ - `--out dir` — where media outputs land (default `./noodle-out`)
76
+ - `--json` — quiet mode: skip the stderr progress lines (the JSON summary is printed either way)
77
+ - `--env-file path` — load `NANOGPT_API_KEY` from a `.env`-style file (`--key` wins if both are set)
78
+
79
+ ### The URL is the package
80
+
81
+ Every nanoodle share link is a runnable artifact — paste one straight from a
82
+ README, a chat, or a tweet, wherever a `graph.json` path is accepted:
83
+
84
+ ```bash
85
+ npx nanoodle inspect "https://nanoodle.com/#g=..." # what does it need? (offline)
86
+ npx nanoodle run "https://nanoodle.com/play.html#a=..." --input Text=hi # run it
87
+ ```
88
+
89
+ Workflow links (`#g=`/`#j=`) and app links (`#a=`, graph only — the app shell
90
+ stays in the browser) both work, as do da.gd/TinyURL short links (resolved by
91
+ reading redirect headers; no credentials are ever sent). Direct links decode
92
+ fully offline. Quote the URL — `#` starts a comment in most shells.
69
93
 
70
94
  ## Inputs, outputs, settings
71
95
 
package/bin/nanoodle.mjs CHANGED
@@ -1,34 +1,71 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * nanoodle CLI — run and inspect noodle-graph.json workflows.
3
+ * nanoodle CLI — run and inspect noodle-graph.json workflows and share links.
4
4
  *
5
- * nanoodle run graph.json --input Text="a cozy ramen shop" --input n2.system=@file.txt \
6
- * --set n3.size=1k --out ./out [--json]
5
+ * nanoodle run graph.json --input Text="a cozy ramen shop" --out ./noodle-out
6
+ * nanoodle run "https://nanoodle.com/#g=..."
7
7
  * nanoodle inspect graph.json
8
+ * nanoodle init [path]
9
+ *
10
+ * Contract: media outputs are written under --out (default ./noodle-out); a JSON
11
+ * run summary always goes to stdout; progress/log lines go to stderr; exit 0 on
12
+ * success, 1 on failure.
8
13
  *
9
14
  * API key: NANOGPT_API_KEY env var, --key <key>, or --env-file <path> (.env-style file).
10
15
  * Precedence: --key > --env-file > NANOGPT_API_KEY. NANOGPT_BASE_URL overrides the API host.
11
16
  */
12
- import { mkdir, readFile } from "node:fs/promises";
17
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
13
18
  import { join, extname } from "node:path";
14
19
  import process from "node:process";
15
20
  import { Workflow, RunError, mediaFromFile } from "../src/index.mjs";
16
21
  import { MediaRef, extForMime } from "../src/media.mjs";
17
22
 
18
- function usage(code = 1) {
19
- console.error(`usage:
20
- nanoodle run <graph.json> [--input k=v]... [--set k=v]... [--out dir] [--json] [--key K] [--env-file path] [--timeout ms]
21
- nanoodle inspect <graph.json> [--key K] [--env-file path]
22
- nanoodle --version
23
+ const HELP = `nanoodle — run nanoodle.com visual AI workflows from the terminal
24
+
25
+ usage:
26
+ nanoodle run <graph.json|share-url> [--input k=v]... [--set k=v]... [--out dir] [--json] [--key K] [--env-file path] [--timeout ms]
27
+ nanoodle inspect <graph.json|share-url>
28
+ nanoodle init [path]
29
+ nanoodle --help | --version
23
30
 
31
+ commands:
32
+ run execute a workflow (needs an API key; spends from your NanoGPT balance)
33
+ inspect show a workflow's inputs, outputs, and settings — fully offline, no key needed
34
+ init write the starter graph (text → LLM prompt-writer → image) to path (default ./noodle-graph.json)
35
+
36
+ flags:
24
37
  --input k=v set a workflow input ("Text=hello", "n2.system=@notes.txt"; @path reads a file —
25
38
  media files ride as media, .txt/.md/.json as text)
26
39
  --set k=v override a setting ("n3.model=flux-pro", "n3.size=1k")
27
- --out dir save media outputs into dir (text outputs are printed)
28
- --json print a machine-readable result
40
+ --out dir directory for media outputs (default ./noodle-out, created only when needed)
41
+ --json quiet mode: skip progress/log lines on stderr
42
+ (the JSON run summary is always printed to stdout either way)
29
43
  --key K NanoGPT API key (defaults to NANOGPT_API_KEY)
30
44
  --env-file p read NANOGPT_API_KEY from a .env-style file (--key wins if both given)
31
- --timeout ms overall run timeout`);
45
+ --timeout ms overall run timeout
46
+
47
+ examples:
48
+ # scaffold the starter graph and see its inputs/outputs — no API key needed
49
+ nanoodle init && nanoodle inspect noodle-graph.json
50
+
51
+ # run it: media lands in ./noodle-out, JSON summary on stdout
52
+ export NANOGPT_API_KEY=... # key from nano-gpt.com
53
+ nanoodle run noodle-graph.json --input Text="a cozy ramen shop on a rainy night"
54
+
55
+ # feed a file into a wired field, override a setting, pick the output dir
56
+ nanoodle run graph.json --input n2.system=@style.txt --set n3.size=1k --out ./renders
57
+
58
+ # any nanoodle share link is runnable — paste it straight from a README or chat
59
+ nanoodle inspect "https://nanoodle.com/#g=..."
60
+ nanoodle run "https://nanoodle.com/play.html#a=..." --input Text="hello"
61
+
62
+ Graphs are the noodle-graph.json files saved from the https://nanoodle.com editor (💾),
63
+ or any share link (#g=/#j=/#a= URLs, including da.gd/TinyURL short links) — quote it;
64
+ # starts a comment in most shells. Direct links decode offline; only short links fetch.
65
+ Exit codes: 0 success, 1 failure. The API key is never logged.`;
66
+
67
+ function usage(code = 1) {
68
+ (code === 0 ? console.log : console.error)(HELP);
32
69
  process.exit(code);
33
70
  }
34
71
 
@@ -56,9 +93,28 @@ async function main() {
56
93
  process.exit(0);
57
94
  }
58
95
  if (!cmd || cmd === "--help" || cmd === "-h") usage(cmd ? 0 : 1);
96
+
97
+ if (cmd === "init") {
98
+ const dest = argv[0] ?? "noodle-graph.json";
99
+ if (argv.length > 1 || dest.startsWith("-")) usage();
100
+ // the template is the same starter graph the tests exercise (tests/fixtures/starter-graph.json)
101
+ const tpl = await readFile(new URL("../templates/starter-graph.json", import.meta.url), "utf8");
102
+ try {
103
+ await writeFile(dest, tpl, { flag: "wx" }); // never overwrite
104
+ } catch (e) {
105
+ if (e.code === "EEXIST") { console.error(`init: ${dest} already exists — not overwriting`); process.exit(1); }
106
+ throw e;
107
+ }
108
+ console.log(dest);
109
+ console.error(`wrote ${dest} — starter graph (text → LLM prompt-writer → image)
110
+ next: nanoodle inspect ${dest}
111
+ then: NANOGPT_API_KEY=... nanoodle run ${dest} --input Text="your idea"`);
112
+ return;
113
+ }
114
+
59
115
  if (cmd !== "run" && cmd !== "inspect") usage();
60
116
 
61
- let graphPath = null, outDir = null, asJson = false, keyFlag = null, envFile = null, timeoutMs;
117
+ let graphPath = null, outDir = null, quiet = false, keyFlag = null, envFile = null, timeoutMs;
62
118
  const inputArgs = [], setArgs = [];
63
119
  let i = 0;
64
120
  const val = (flag) => { // a value-taking flag at end of argv is a usage error, not a TypeError
@@ -71,7 +127,7 @@ async function main() {
71
127
  if (a === "--input") inputArgs.push(val("--input"));
72
128
  else if (a === "--set") setArgs.push(val("--set"));
73
129
  else if (a === "--out") outDir = val("--out");
74
- else if (a === "--json") asJson = true;
130
+ else if (a === "--json") quiet = true;
75
131
  else if (a === "--key") keyFlag = val("--key");
76
132
  else if (a === "--env-file") envFile = val("--env-file");
77
133
  else if (a === "--timeout") timeoutMs = +val("--timeout");
@@ -139,7 +195,7 @@ async function main() {
139
195
  try {
140
196
  result = await wf.run(inputs, {
141
197
  settings, timeoutMs,
142
- onProgress: asJson ? undefined : (e) => {
198
+ onProgress: quiet ? undefined : (e) => {
143
199
  if (e.type === "node-start") console.error(`▶ ${e.name} (${e.nodeId})`);
144
200
  if (e.type === "node-done") console.error(`✔ ${e.name} (${e.nodeId}) ${e.ms}ms${e.costUsd != null ? ` $${e.costUsd}` : ""}`);
145
201
  if (e.type === "node-error") console.error(`✖ ${e.name} (${e.nodeId}): ${e.error}`);
@@ -156,37 +212,36 @@ async function main() {
156
212
  }
157
213
  }
158
214
 
159
- if (outDir) await mkdir(outDir, { recursive: true });
215
+ // media outputs land under --out (default ./noodle-out; created only if there is media to save)
216
+ const dir = outDir ?? "noodle-out";
217
+ let dirMade = false;
160
218
  const printable = {};
161
219
  for (const o of wf.outputs) {
162
220
  const value = result.outputs[o.key];
163
221
  if (value === undefined) { printable[o.key] = null; continue; }
164
222
  if (value instanceof MediaRef) {
165
- if (outDir) {
166
- const safe = o.key.replace(/[^\w.-]+/g, "_");
167
- const path = join(outDir, safe + "." + extForMime(value.mime || ""));
168
- await value.save(path);
169
- printable[o.key] = path;
170
- if (!asJson) console.log(`${o.key}: saved ${path}`);
171
- } else {
172
- printable[o.key] = value.url.length > 200 ? value.url.slice(0, 80) + `… (${value.url.length} chars — use --out to save)` : value.url;
173
- if (!asJson) console.log(`${o.key}: ${printable[o.key]}`);
174
- }
223
+ if (!dirMade) { await mkdir(dir, { recursive: true }); dirMade = true; }
224
+ const safe = o.key.replace(/[^\w.-]+/g, "_");
225
+ const path = join(dir, safe + "." + extForMime(value.mime || ""));
226
+ await value.save(path);
227
+ printable[o.key] = path;
228
+ if (!quiet) console.error(`${o.key}: saved ${path}`);
175
229
  } else {
176
230
  printable[o.key] = value;
177
- if (!asJson) console.log(`${o.key}: ${value}`);
231
+ if (!quiet) console.error(`${o.key}: ${value}`);
178
232
  }
179
233
  }
180
- if (asJson) {
181
- console.log(JSON.stringify({
182
- outputs: printable,
183
- costUsd: result.costUsd,
184
- costExact: result.costExact,
185
- remainingBalance: result.remainingBalance,
186
- errors: result.errors,
187
- nodes: Object.fromEntries(Object.entries(result.nodes).map(([id, r]) => [id, { status: r.status, ms: r.ms, costUsd: r.costUsd, error: r.error }])),
188
- }, null, 2));
189
- } else {
234
+
235
+ // the run summary is ALWAYS the JSON on stdout (contract shared with nanoodle-py and the docs)
236
+ console.log(JSON.stringify({
237
+ outputs: printable,
238
+ costUsd: result.costUsd,
239
+ costExact: result.costExact,
240
+ remainingBalance: result.remainingBalance,
241
+ errors: result.errors,
242
+ nodes: Object.fromEntries(Object.entries(result.nodes).map(([id, r]) => [id, { status: r.status, ms: r.ms, costUsd: r.costUsd, error: r.error }])),
243
+ }, null, 2));
244
+ if (!quiet) {
190
245
  const approx = result.costExact ? "" : "≥ ";
191
246
  console.error(`cost: ${approx}$${result.costUsd}${result.remainingBalance != null ? ` · balance: $${result.remainingBalance}` : ""}`);
192
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanoodle",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Run nanoodle visual AI workflows from JavaScript — zero-dependency executor for saved noodle-graph.json files",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -21,6 +21,7 @@
21
21
  "files": [
22
22
  "src",
23
23
  "bin",
24
+ "templates",
24
25
  "README.md",
25
26
  "LICENSE"
26
27
  ],
@@ -28,6 +29,11 @@
28
29
  "nanoodle",
29
30
  "workflow",
30
31
  "ai",
32
+ "ai-workflow",
33
+ "node-graph",
34
+ "dag",
35
+ "pipeline",
36
+ "cli",
31
37
  "nanogpt",
32
38
  "image-generation",
33
39
  "video-generation",
package/src/index.mjs CHANGED
@@ -4,3 +4,4 @@ export { MediaRef, mediaFromFile, MEDIA_INLINE_MAX } from "./media.mjs";
4
4
  export { NanoClient } from "./client.mjs";
5
5
  export { NODE_TYPES, displayName, materialize, topoSort } from "./graph.mjs";
6
6
  export { deriveInputs, deriveOutputs, deriveSettings, INPUT_SPECS, SETTING_SPECS } from "./io.mjs";
7
+ export { decodeShareUrl, decodeShareFragment, isShareRef } from "./share.mjs";
package/src/share.mjs ADDED
@@ -0,0 +1,129 @@
1
+ import { gunzipSync } from "node:zlib";
2
+ import { NanoodleError } from "./errors.mjs";
3
+
4
+ /**
5
+ * Decode-only codec for nanoodle share links — the editor stays the single
6
+ * encoder of record; these functions only ever read.
7
+ *
8
+ * Wire formats (mirrors index.html's loadFromHash / buildShareUrl, locked by
9
+ * the golden fixtures in tests/fixtures/share/ — regenerate them from a real
10
+ * editor with tests/harness/gen-share-fixtures.mjs when the encoder changes):
11
+ * #g=<b64url(gzip(graph JSON))> workflow link (editor 🔗 Share)
12
+ * #j=<b64url(graph JSON)> uncompressed fallback (no CompressionStream)
13
+ * #a=<b64url(gzip(app payload))> app link (play.html); payload = { v, graph, files?, name?, lang?, ... }
14
+ * #a=u<b64url(app payload)> uncompressed app fallback ('u' tag inside the value)
15
+ * #ga=… editor↔play handoff — internal transport, deliberately NOT supported
16
+ */
17
+
18
+ const URL_RE = /^https?:\/\//i;
19
+ const FRAG_RE = /^#?(ga|[gja])=/;
20
+
21
+ /** True when a string is addressable as a share link: an http(s) URL, or a bare #g=/#j=/#a= fragment. */
22
+ export function isShareRef(s) {
23
+ return typeof s === "string" && (URL_RE.test(s) || FRAG_RE.test(s));
24
+ }
25
+
26
+ function b64urlToBuf(s, what) {
27
+ if (!/^[A-Za-z0-9_-]+$/.test(s)) {
28
+ throw new NanoodleError(`share link: ${what} payload is not base64url data — is the URL complete?`);
29
+ }
30
+ return Buffer.from(s.replace(/-/g, "+").replace(/_/g, "/"), "base64");
31
+ }
32
+
33
+ function parseJson(text, what) {
34
+ try { return JSON.parse(text); }
35
+ catch { throw new NanoodleError(`share link: ${what} payload decoded but is not valid JSON — the link may be truncated`); }
36
+ }
37
+
38
+ function gunzipText(buf, what) {
39
+ try { return gunzipSync(buf).toString("utf8"); }
40
+ catch { throw new NanoodleError(`share link: ${what} payload is not valid gzip data — the link may be truncated`); }
41
+ }
42
+
43
+ /**
44
+ * Decode a share fragment ("#g=…", "g=…", "#a=…", …) to its graph.
45
+ * @returns {{ graph: object, kind: "g"|"j"|"a", app: { name?, lang?, hasFiles: boolean }|null }}
46
+ */
47
+ export function decodeShareFragment(fragment) {
48
+ let f = String(fragment);
49
+ if (f.startsWith("#")) f = f.slice(1);
50
+ if (f.startsWith("ga=")) {
51
+ throw new NanoodleError(
52
+ "share link: #ga= is the editor↔app-builder handoff — an internal, unstable format. " +
53
+ "Open the link in a browser and use 🔗 Share to mint a #g= workflow link instead.");
54
+ }
55
+ if (f.startsWith("g=")) {
56
+ return { graph: parseJson(gunzipText(b64urlToBuf(f.slice(2), "#g="), "#g="), "#g="), kind: "g", app: null };
57
+ }
58
+ if (f.startsWith("j=")) {
59
+ return { graph: parseJson(b64urlToBuf(f.slice(2), "#j=").toString("utf8"), "#j="), kind: "j", app: null };
60
+ }
61
+ if (f.startsWith("a=")) {
62
+ const tag = f.slice(2);
63
+ const json = tag[0] === "u"
64
+ ? b64urlToBuf(tag.slice(1), "#a=u").toString("utf8")
65
+ : gunzipText(b64urlToBuf(tag, "#a="), "#a=");
66
+ const payload = parseJson(json, "#a=");
67
+ if (!payload || typeof payload !== "object" || !payload.graph) {
68
+ throw new NanoodleError("share link: #a= app payload has no graph in it");
69
+ }
70
+ // files/samples/lang are play.html presentation — executors run graphs, not apps.
71
+ return {
72
+ graph: payload.graph,
73
+ kind: "a",
74
+ app: {
75
+ ...(typeof payload.name === "string" && payload.name ? { name: payload.name } : {}),
76
+ ...(typeof payload.lang === "string" && payload.lang ? { lang: payload.lang } : {}),
77
+ hasFiles: !!payload.files,
78
+ },
79
+ };
80
+ }
81
+ throw new NanoodleError(`share link: no #g=/#j=/#a= fragment found in "${fragment}"`);
82
+ }
83
+
84
+ function fragmentOf(url) {
85
+ const i = url.indexOf("#");
86
+ return i === -1 ? null : url.slice(i);
87
+ }
88
+
89
+ /**
90
+ * Decode any nanoodle share reference — a full URL, a bare fragment, or a
91
+ * shortener link (da.gd/TinyURL/…) whose redirect target carries the fragment.
92
+ *
93
+ * Direct fragment links decode with ZERO network calls. Only fragment-less
94
+ * http(s) URLs trigger fetches, and those are redirect-header reads with no
95
+ * credentials attached (the codec never sees an API key by construction).
96
+ *
97
+ * @param {string} input
98
+ * @param {{ fetch?: typeof fetch, maxHops?: number }} [opts]
99
+ * @returns {Promise<{ graph: object, kind: "g"|"j"|"a", app: object|null, url: string }>}
100
+ */
101
+ export async function decodeShareUrl(input, opts = {}) {
102
+ const s = String(input).trim();
103
+ if (!URL_RE.test(s)) return { ...decodeShareFragment(s), url: s };
104
+
105
+ let url = s;
106
+ const frag = fragmentOf(url);
107
+ if (frag && FRAG_RE.test(frag)) return { ...decodeShareFragment(frag), url };
108
+
109
+ // No fragment on the URL itself → treat it as a short link and follow
110
+ // redirects by hand: fragments ride in the Location header, which automatic
111
+ // redirect handling would consume before we could read it.
112
+ const f = opts.fetch ?? globalThis.fetch;
113
+ const maxHops = opts.maxHops ?? 5;
114
+ for (let hop = 0; hop < maxHops; hop++) {
115
+ let res;
116
+ try { res = await f(url, { method: "GET", redirect: "manual" }); }
117
+ catch (e) { throw new NanoodleError(`share link: could not resolve ${url}: ${e.message}`); }
118
+ const loc = res.status >= 300 && res.status < 400 ? res.headers.get("location") : null;
119
+ if (!loc) {
120
+ throw new NanoodleError(
121
+ `share link: ${url} answered ${res.status} with no #g=/#j=/#a= fragment and no redirect — ` +
122
+ "open it in a browser and share the long nanoodle.com URL instead");
123
+ }
124
+ url = new URL(loc, url).href;
125
+ const hopFrag = fragmentOf(url);
126
+ if (hopFrag && FRAG_RE.test(hopFrag)) return { ...decodeShareFragment(hopFrag), url };
127
+ }
128
+ throw new NanoodleError(`share link: gave up after ${maxHops} redirects without finding a share fragment`);
129
+ }
package/src/workflow.mjs CHANGED
@@ -5,6 +5,7 @@ import { deriveInputs, deriveOutputs, deriveSettings, resolveInputKey, resolveSe
5
5
  import { NanoClient } from "./client.mjs";
6
6
  import { MediaRef, coerceMediaInput } from "./media.mjs";
7
7
  import { RUNNERS, unsupportedNodeError } from "./nodes.mjs";
8
+ import { decodeShareUrl, isShareRef } from "./share.mjs";
8
9
 
9
10
  const MEDIA_KINDS = new Set(["image", "audio", "video", "inpaint"]);
10
11
 
@@ -71,9 +72,19 @@ export class Workflow {
71
72
  }
72
73
  }
73
74
 
74
- /** Load a downloaded noodle-graph.json save from disk. */
75
- static async load(path, opts = {}) {
76
- return Workflow.fromJSON(await readFile(path, "utf8"), opts);
75
+ /**
76
+ * Load a workflow from a noodle-graph.json file on disk, or from any nanoodle
77
+ * share link — a full URL (nanoodle.com/#g=…, /play.html#a=…, a da.gd/TinyURL
78
+ * short link) or a bare #g=/#j=/#a= fragment. Direct fragment links decode
79
+ * offline; only fragment-less short links touch the network (redirect-header
80
+ * reads, no credentials attached).
81
+ */
82
+ static async load(src, opts = {}) {
83
+ if (isShareRef(src)) {
84
+ const { graph } = await decodeShareUrl(src, { fetch: opts.fetch });
85
+ return new Workflow(graph, opts);
86
+ }
87
+ return Workflow.fromJSON(await readFile(src, "utf8"), opts);
77
88
  }
78
89
 
79
90
  /** Build from a parsed object or a JSON string. */
@@ -0,0 +1,48 @@
1
+ {
2
+ "v": 1,
3
+ "nodes": [
4
+ {
5
+ "id": "n1",
6
+ "type": "text",
7
+ "x": 60,
8
+ "y": 130,
9
+ "fields": {
10
+ "text": "a cozy ramen shop on a rainy night"
11
+ },
12
+ "w": 220
13
+ },
14
+ {
15
+ "id": "n2",
16
+ "type": "llm",
17
+ "x": 340,
18
+ "y": 70,
19
+ "fields": {
20
+ "model": "zai-org/glm-5.2",
21
+ "system": "You write image prompts. Turn the idea into one vivid, detailed image prompt — scene, lighting, mood, style. Reply with the prompt only."
22
+ },
23
+ "w": 250,
24
+ "sizes": {
25
+ "system": 120
26
+ }
27
+ },
28
+ {
29
+ "id": "n3",
30
+ "type": "image",
31
+ "x": 650,
32
+ "y": 100,
33
+ "fields": {
34
+ "model": "nano-banana-2-lite",
35
+ "size": "1k",
36
+ "variations": "1"
37
+ },
38
+ "w": 250
39
+ }
40
+ ],
41
+ "links": [
42
+ { "id": "l1", "from": { "node": "n1", "port": "text" }, "to": { "node": "n2", "port": "prompt" } },
43
+ { "id": "l2", "from": { "node": "n2", "port": "text" }, "to": { "node": "n3", "port": "prompt" } }
44
+ ],
45
+ "nid": 4,
46
+ "lid": 3,
47
+ "view": { "panX": 40, "panY": 60, "scale": 1 }
48
+ }