nanoodle 0.1.1 → 0.4.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
@@ -9,6 +9,19 @@ Zero runtime dependencies. Library + CLI in one install.
9
9
 
10
10
  Looking for Python? → **[nanoodle-py](https://github.com/nanoodlecom/nanoodle-py)**
11
11
 
12
+ ## Which repo do I want?
13
+
14
+ | I want to… | Go to |
15
+ |---|---|
16
+ | Design workflows in the browser | [nanoodle.com](https://nanoodle.com) |
17
+ | Run graphs from Node code or the CLI | **this package** |
18
+ | Run graphs from Python | [nanoodle-py](https://github.com/nanoodlecom/nanoodle-py) |
19
+ | Serve saved graphs as MCP tools | [nanoodle-mcp](https://github.com/nanoodlecom/nanoodle-mcp) |
20
+ | Run graphs in GitHub Actions CI | [run-noodle-action](https://github.com/nanoodlecom/run-noodle-action) |
21
+ | Teach an agent to *build* graphs | [nanoodle-skill](https://github.com/nanoodlecom/nanoodle-skill) |
22
+ | Prebuilt one-task agent skills | [noodle-skills](https://github.com/nanoodlecom/noodle-skills) |
23
+ | Browse ready-to-open graphs | [awesome-noodles](https://github.com/nanoodlecom/awesome-noodles) |
24
+
12
25
  ## At a glance
13
26
 
14
27
  ![Pipeline: nanoodle editor → noodle-graph.json → JS executor → NanoGPT API](docs/diagram-pipeline.jpg)
@@ -33,12 +46,18 @@ npm install nanoodle # library + CLI
33
46
  npx nanoodle --help # or run the CLI without installing
34
47
  ```
35
48
 
49
+ Latest on npm is **0.2.0**; accountless `--pay` (x402) and the local-media
50
+ nodes below need 0.4 — until it ships, install from this repo
51
+ (`npm install github:nanoodlecom/nanoodle-js`).
52
+
36
53
  ## Quickstart (library)
37
54
 
38
55
  ```js
39
56
  import { Workflow } from "nanoodle";
40
57
 
41
58
  const wf = await Workflow.load("noodle-graph.json"); // key from NANOGPT_API_KEY
59
+ // …or load any nanoodle share link — the URL is the package:
60
+ // const wf = await Workflow.load("https://nanoodle.com/#g=…");
42
61
  const result = await wf.run({ Text: "a cozy ramen shop on a rainy night" });
43
62
  await result.get("Image").save("ramen.png"); // media: MediaRef (url + bytes()/save())
44
63
  console.log(result.costUsd, result.remainingBalance);
@@ -48,24 +67,47 @@ With the app’s starter graph (text → LLM prompt-writer → image), that’s
48
67
 
49
68
  ## Quickstart (CLI)
50
69
 
51
- Inspect first — offline; shows inputs, outputs, and settings:
70
+ No graph yet? Scaffold the starter (text → LLM prompt-writer → image) and
71
+ inspect it — both offline, no key needed:
52
72
 
53
73
  ```bash
54
- npx nanoodle inspect graph.json
74
+ npx nanoodle init # writes ./noodle-graph.json
75
+ npx nanoodle inspect noodle-graph.json # shows inputs, outputs, settings
55
76
  ```
56
77
 
57
78
  Then run (calls NanoGPT and spends from your balance):
58
79
 
59
80
  ```bash
60
81
  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
82
+ npx nanoodle run noodle-graph.json --input Text="a cozy ramen shop on a rainy night"
83
+ npx nanoodle run graph.json --input n2.system=@style.txt --set n3.size=1k --out ./renders
63
84
  ```
64
85
 
65
- - `--env-file path` — load `NANOGPT_API_KEY` from a `.env`-style file (`--key` wins if both are set)
86
+ Media outputs are saved under `--out` (default `./noodle-out`, created only
87
+ when there is media to save); a JSON run summary always goes to stdout,
88
+ progress lines to stderr; exit code `0` on success, `1` on failure.
89
+
66
90
  - `--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
91
+ - `--set k=v` — override a setting (`n3.model=flux-pro`)
92
+ - `--out dir` — where media outputs land (default `./noodle-out`)
93
+ - `--timeout ms` — overall run timeout
94
+ - `--json` — quiet mode: skip the stderr progress lines (the JSON summary is printed either way)
95
+ - `--env-file path` — load `NANOGPT_API_KEY` from a `.env`-style file (`--key` wins if both are set)
96
+
97
+ ### The URL is the package
98
+
99
+ Every nanoodle share link is a runnable artifact — paste one straight from a
100
+ README, a chat, or a tweet, wherever a `graph.json` path is accepted:
101
+
102
+ ```bash
103
+ npx nanoodle inspect "https://nanoodle.com/#g=..." # what does it need? (offline)
104
+ npx nanoodle run "https://nanoodle.com/play.html#a=..." --input Text=hi # run it
105
+ ```
106
+
107
+ Workflow links (`#g=`/`#j=`) and app links (`#a=`, graph only — the app shell
108
+ stays in the browser) both work, as do da.gd/TinyURL short links (resolved by
109
+ reading redirect headers; no credentials are ever sent). Direct links decode
110
+ fully offline. Quote the URL — `#` starts a comment in most shells.
69
111
 
70
112
  ## Inputs, outputs, settings
71
113
 
@@ -111,23 +153,22 @@ const result = await wf.run(
111
153
  `run()` rejects with `RunError` when an output (sink) node fails —
112
154
  `err.result` still has partial results, per-node statuses, and cost so far.
113
155
  Failures in lanes no output depends on only appear in `result.errors`.
114
- Unknown/unsupported node types, missing required inputs, bad keys, and a
115
- missing API key all fail **before** anything is spent.
156
+ Unknown node types, missing required inputs, bad keys, and a missing API key
157
+ all fail **before** anything is spent.
116
158
 
117
159
  ## Supported nodes
118
160
 
119
161
  | runs | node types |
120
162
  |---|---|
121
163
  | local | text, upload (image/audio/video), choice, join, comment |
164
+ | local media† | resize, vframes, combine, soundtrack, trim, extractaudio |
122
165
  | NanoGPT | llm (incl. vision + audio input), image, draw, edit, inpaint*, vision, tvideo, ivideo, vedit, lipsync, music, remix, tts, transcribe |
123
- | **not supported** (browser-only media processing) | resize, vframes, combine, soundtrack, trim, extractaudio |
124
166
 
125
- Workflows with unsupported node types load with a warning and fail fast at
126
- `run()` with `UnsupportedNodeError` — before any network call.
167
+ † **local media** (0.4, unreleased — see [Install](#install)) prefers a pure-JS path that matches the browser (lossless mp4 remux, PCM-WAV trim, PNG resize). **ffmpeg** on `PATH` is the fallback for everything else (soft dependency — not an npm package); clear error if it’s required and missing.
127
168
 
128
- \* **inpaint:** the browser app composites the mask onto black at the source
129
- pixel size; this library passes your mask through verbatim. Supply a
130
- black/white mask matching the source dimensions.
169
+ \* **inpaint:** the mask is composited onto black at the source image’s pixel
170
+ size before send (same as the browser app) — white = repaint, black = keep.
171
+ Brush-style white-on-transparent masks and plain B/W masks both work.
131
172
 
132
173
  ## Use it as an agent skill
133
174
 
@@ -135,7 +176,8 @@ A saved workflow plus a short `SKILL.md` playbook is a skill any coding agent
135
176
  can run — Claude Code, Cursor, Grok, or anything that reads markdown and runs
136
177
  shell. Recipe and template: [docs/agent-skills.md](docs/agent-skills.md).
137
178
 
138
- **Example skill** (idea → LLM prompt → poster image):
179
+ **Example skill** (idea → LLM prompt → poster image), installed with the
180
+ [`skills` CLI](https://www.npmjs.com/package/skills):
139
181
 
140
182
  ```bash
141
183
  npx skills add nanoodlecom/nanoodle-js@poster-generator -g -y
@@ -160,6 +202,51 @@ A price of `0` means known-included (subscription), not unknown. `inspect`
160
202
  and loading/validating workflows never call the API. No telemetry, no
161
203
  analytics; the API key is never logged.
162
204
 
205
+ ## No account at all: pay per run in Nano (x402) — 0.4, unreleased
206
+
207
+ NanoGPT supports [x402](https://nano-gpt.com) accountless payments: call the
208
+ API with no key, get an HTTP 402 invoice, settle it in Nano (XNO — instant,
209
+ feeless), and the call completes. nanoodle wires that up end to end:
210
+
211
+ ```bash
212
+ # each paid call prints a scannable QR + nano: URI on stderr and waits for the deposit
213
+ nanoodle run "https://nanoodle.com/#g=..." --input Text="hello" --pay
214
+ ```
215
+
216
+ ```js
217
+ const wf = await Workflow.load(url, {
218
+ payment: async (invoice) => {
219
+ // invoice: { payTo, amountRaw, amount, amountUsd, uri, expiresAt, explorerUrl, ... }
220
+ await myWallet.send(invoice.payTo, invoice.amountRaw); // YOUR signer does the send
221
+ },
222
+ });
223
+ ```
224
+
225
+ The library **never touches funds or keys**: `payment` must be a callback —
226
+ passing a seed or private key throws. Do the send inside the callback with
227
+ your own wallet/signer (e.g. a self-custody wallet, or print `invoice.uri`
228
+ for a human to scan — `qrTerminal(invoice.uri)` is exported). Each API call
229
+ pays at most once; graphs with several paid nodes produce one small invoice
230
+ per node. Chat and image nodes are live-verified; async video/audio job
231
+ polling under accountless mode is untested upstream.
232
+
233
+ Copy-paste scripts (CLI, QR callback, wallet stub, bare chat):
234
+ [examples/x402/](examples/x402/).
235
+
236
+ ### Accountless image, start to finish
237
+
238
+ The starter graph (text → LLM prompt-writer → image), run with **no NanoGPT
239
+ account and no API key** — scan the Nano invoice, and the image node settles
240
+ for a few cents of XNO:
241
+
242
+ ```bash
243
+ nanoodle run noodle-graph.json --input Text="a cozy ramen shop on a rainy night" --pay --out ./noodle-out
244
+ # → LLM node runs, image node prints a nano: QR, waits for the deposit,
245
+ # then writes noodle-out/Image.jpg
246
+ ```
247
+
248
+ ![Accountless x402 run of the starter graph — a bowl of ramen generated with no account and no API key](noodle-out/Image.jpg)
249
+
163
250
  ## Specs and testing
164
251
 
165
252
  Format and execution semantics live in [docs/](docs/):
package/bin/nanoodle.mjs CHANGED
@@ -1,34 +1,77 @@
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
- import { MediaRef, extForMime } from "../src/media.mjs";
21
+ import { MediaRef, extForMime, sniffMime } 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
+ --pay accountless run — no API key or account: each paid call prints a Nano (XNO)
46
+ invoice as a scannable QR + nano: URI on stderr and waits for the deposit
47
+ (x402; ignores any configured key; self-custody wallet does the send)
48
+ --timeout ms overall run timeout
49
+
50
+ examples:
51
+ # scaffold the starter graph and see its inputs/outputs — no API key needed
52
+ nanoodle init && nanoodle inspect noodle-graph.json
53
+
54
+ # run it: media lands in ./noodle-out, JSON summary on stdout
55
+ export NANOGPT_API_KEY=... # key from nano-gpt.com
56
+ nanoodle run noodle-graph.json --input Text="a cozy ramen shop on a rainy night"
57
+
58
+ # feed a file into a wired field, override a setting, pick the output dir
59
+ nanoodle run graph.json --input n2.system=@style.txt --set n3.size=1k --out ./renders
60
+
61
+ # any nanoodle share link is runnable — paste it straight from a README or chat
62
+ nanoodle inspect "https://nanoodle.com/#g=..."
63
+ nanoodle run "https://nanoodle.com/play.html#a=..." --input Text="hello"
64
+
65
+ # no account at all: pay per run in Nano — scan the QR that appears in the terminal
66
+ nanoodle run "https://nanoodle.com/#g=..." --input Text="hello" --pay
67
+
68
+ Graphs are the noodle-graph.json files saved from the https://nanoodle.com editor (💾),
69
+ or any share link (#g=/#j=/#a= URLs, including da.gd/TinyURL short links) — quote it;
70
+ # starts a comment in most shells. Direct links decode offline; only short links fetch.
71
+ Exit codes: 0 success, 1 failure. The API key is never logged.`;
72
+
73
+ function usage(code = 1) {
74
+ (code === 0 ? console.log : console.error)(HELP);
32
75
  process.exit(code);
33
76
  }
34
77
 
@@ -56,9 +99,28 @@ async function main() {
56
99
  process.exit(0);
57
100
  }
58
101
  if (!cmd || cmd === "--help" || cmd === "-h") usage(cmd ? 0 : 1);
102
+
103
+ if (cmd === "init") {
104
+ const dest = argv[0] ?? "noodle-graph.json";
105
+ if (argv.length > 1 || dest.startsWith("-")) usage();
106
+ // the template is the same starter graph the tests exercise (tests/fixtures/starter-graph.json)
107
+ const tpl = await readFile(new URL("../templates/starter-graph.json", import.meta.url), "utf8");
108
+ try {
109
+ await writeFile(dest, tpl, { flag: "wx" }); // never overwrite
110
+ } catch (e) {
111
+ if (e.code === "EEXIST") { console.error(`init: ${dest} already exists — not overwriting`); process.exit(1); }
112
+ throw e;
113
+ }
114
+ console.log(dest);
115
+ console.error(`wrote ${dest} — starter graph (text → LLM prompt-writer → image)
116
+ next: nanoodle inspect ${dest}
117
+ then: NANOGPT_API_KEY=... nanoodle run ${dest} --input Text="your idea"`);
118
+ return;
119
+ }
120
+
59
121
  if (cmd !== "run" && cmd !== "inspect") usage();
60
122
 
61
- let graphPath = null, outDir = null, asJson = false, keyFlag = null, envFile = null, timeoutMs;
123
+ let graphPath = null, outDir = null, quiet = false, keyFlag = null, envFile = null, timeoutMs, pay = false;
62
124
  const inputArgs = [], setArgs = [];
63
125
  let i = 0;
64
126
  const val = (flag) => { // a value-taking flag at end of argv is a usage error, not a TypeError
@@ -71,9 +133,10 @@ async function main() {
71
133
  if (a === "--input") inputArgs.push(val("--input"));
72
134
  else if (a === "--set") setArgs.push(val("--set"));
73
135
  else if (a === "--out") outDir = val("--out");
74
- else if (a === "--json") asJson = true;
136
+ else if (a === "--json") quiet = true;
75
137
  else if (a === "--key") keyFlag = val("--key");
76
138
  else if (a === "--env-file") envFile = val("--env-file");
139
+ else if (a === "--pay") pay = true;
77
140
  else if (a === "--timeout") timeoutMs = +val("--timeout");
78
141
  else if (a.startsWith("-")) { console.error("unknown flag: " + a); usage(); }
79
142
  else if (!graphPath) graphPath = a;
@@ -92,7 +155,26 @@ async function main() {
92
155
  apiKey = m[1].trim();
93
156
  }
94
157
 
95
- const wf = await Workflow.load(graphPath, { apiKey, baseUrl: process.env.NANOGPT_BASE_URL || undefined });
158
+ // --pay = accountless x402: the key (flag or env) is deliberately ignored, each paid call
159
+ // prints a Nano invoice on stderr and the run resumes once the deposit is seen on-chain.
160
+ // The send happens in the user's own wallet — the CLI never asks for a seed or key.
161
+ let payment;
162
+ if (pay) {
163
+ apiKey = null; // null, not undefined — undefined would let Workflow's NANOGPT_API_KEY env fallback re-inject a key
164
+ const { qrTerminal } = await import("../src/qr.mjs");
165
+ payment = async (inv) => {
166
+ const mins = inv.expiresAt ? Math.max(1, Math.round((inv.expiresAt - Date.now()) / 60000)) : null;
167
+ console.error(`\n⚡ payment required: ${inv.amount || inv.amountRaw + " raw"}${inv.amountUsd != null ? ` (~$${inv.amountUsd})` : ""}`);
168
+ console.error(qrTerminal(inv.uri));
169
+ console.error("scan with your Nano wallet (dark terminals scan best), or send to:");
170
+ console.error(" " + inv.payTo);
171
+ console.error(" " + inv.uri);
172
+ if (inv.explorerUrl) console.error(" explorer: " + inv.explorerUrl);
173
+ console.error(`waiting for the deposit…${mins ? ` (invoice expires in ~${mins} min,` : " ("}Ctrl-C aborts)\n`);
174
+ };
175
+ }
176
+
177
+ const wf = await Workflow.load(graphPath, { apiKey, payment, baseUrl: process.env.NANOGPT_BASE_URL || undefined });
96
178
 
97
179
  if (cmd === "inspect") {
98
180
  const pad = (s, n) => String(s).padEnd(n);
@@ -139,7 +221,7 @@ async function main() {
139
221
  try {
140
222
  result = await wf.run(inputs, {
141
223
  settings, timeoutMs,
142
- onProgress: asJson ? undefined : (e) => {
224
+ onProgress: quiet ? undefined : (e) => {
143
225
  if (e.type === "node-start") console.error(`▶ ${e.name} (${e.nodeId})`);
144
226
  if (e.type === "node-done") console.error(`✔ ${e.name} (${e.nodeId}) ${e.ms}ms${e.costUsd != null ? ` $${e.costUsd}` : ""}`);
145
227
  if (e.type === "node-error") console.error(`✖ ${e.name} (${e.nodeId}): ${e.error}`);
@@ -156,37 +238,38 @@ async function main() {
156
238
  }
157
239
  }
158
240
 
159
- if (outDir) await mkdir(outDir, { recursive: true });
241
+ // media outputs land under --out (default ./noodle-out; created only if there is media to save)
242
+ const dir = outDir ?? "noodle-out";
243
+ let dirMade = false;
160
244
  const printable = {};
161
245
  for (const o of wf.outputs) {
162
246
  const value = result.outputs[o.key];
163
247
  if (value === undefined) { printable[o.key] = null; continue; }
164
248
  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
- }
249
+ if (!dirMade) { await mkdir(dir, { recursive: true }); dirMade = true; }
250
+ const safe = o.key.replace(/[^\w.-]+/g, "_");
251
+ // fetch before naming: hosted media only reveals its mime via the response Content-Type
252
+ const data = await value.bytes();
253
+ const path = join(dir, safe + "." + extForMime(value.mime || sniffMime(data)));
254
+ await writeFile(path, data);
255
+ printable[o.key] = path;
256
+ if (!quiet) console.error(`${o.key}: saved ${path}`);
175
257
  } else {
176
258
  printable[o.key] = value;
177
- if (!asJson) console.log(`${o.key}: ${value}`);
259
+ if (!quiet) console.error(`${o.key}: ${value}`);
178
260
  }
179
261
  }
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 {
262
+
263
+ // the run summary is ALWAYS the JSON on stdout (contract shared with nanoodle-py and the docs)
264
+ console.log(JSON.stringify({
265
+ outputs: printable,
266
+ costUsd: result.costUsd,
267
+ costExact: result.costExact,
268
+ remainingBalance: result.remainingBalance,
269
+ errors: result.errors,
270
+ nodes: Object.fromEntries(Object.entries(result.nodes).map(([id, r]) => [id, { status: r.status, ms: r.ms, costUsd: r.costUsd, error: r.error }])),
271
+ }, null, 2));
272
+ if (!quiet) {
190
273
  const approx = result.costExact ? "" : "≥ ";
191
274
  console.error(`cost: ${approx}$${result.costUsd}${result.remainingBalance != null ? ` · balance: $${result.remainingBalance}` : ""}`);
192
275
  }
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "nanoodle",
3
- "version": "0.1.1",
3
+ "version": "0.4.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",
7
7
  "exports": {
8
8
  ".": "./src/index.mjs",
9
+ "./browser": "./src/browser.mjs",
9
10
  "./package.json": "./package.json"
10
11
  },
12
+ "browser": {
13
+ "./src/index.mjs": "./src/browser.mjs"
14
+ },
11
15
  "sideEffects": false,
12
16
  "bin": {
13
17
  "nanoodle": "./bin/nanoodle.mjs"
@@ -21,6 +25,7 @@
21
25
  "files": [
22
26
  "src",
23
27
  "bin",
28
+ "templates",
24
29
  "README.md",
25
30
  "LICENSE"
26
31
  ],
@@ -28,6 +33,11 @@
28
33
  "nanoodle",
29
34
  "workflow",
30
35
  "ai",
36
+ "ai-workflow",
37
+ "node-graph",
38
+ "dag",
39
+ "pipeline",
40
+ "cli",
31
41
  "nanogpt",
32
42
  "image-generation",
33
43
  "video-generation",
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Browser-oriented package entry (`import … from "nanoodle/browser"`).
3
+ *
4
+ * Goal: one engine for play/export/CLI. No module on this surface top-level
5
+ * imports Node builtins (Phase D): the pure local-media paths (MP4CAT remux,
6
+ * PCM-WAV trim, PNG resize/mask composite) and share-link decoding run in a
7
+ * browser as-is — zlib work goes through Compression/DecompressionStream
8
+ * there. Only the ffmpeg fallback and file-path helpers dynamically import
9
+ * Node builtins when those code paths actually run.
10
+ * See docs/DESIGN.md § "Replacing the browser executor".
11
+ *
12
+ * Prefer `Workflow.fromJSON(obj, { apiKey, fetch, payment })` in the browser;
13
+ * `Workflow.load(path)` and `mediaFromFile` remain Node-only (dynamic `node:fs`).
14
+ */
15
+ export { Workflow, RunResult } from "./workflow.mjs";
16
+ export { NanoodleError, UnsupportedNodeError, RunError } from "./errors.mjs";
17
+ export {
18
+ MediaRef,
19
+ MEDIA_INLINE_MAX,
20
+ coerceMediaInput,
21
+ assertInlineMediaSize,
22
+ bytesToDataUrl,
23
+ dataUrlBytes,
24
+ bytesToBase64,
25
+ base64ToBytes,
26
+ sniffMime,
27
+ b64ImageMime,
28
+ extForMime,
29
+ } from "./media.mjs";
30
+ export { NanoClient, httpError, costFromJson, costFromHeaders, costWithHeaders, sleep } from "./client.mjs";
31
+ export { NODE_TYPES, displayName, materialize, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
32
+ export { RUNNERS } from "./nodes.mjs"; // per-node executors — the play delegation shim drives these directly
33
+ export { catItem, chatModelCan } from "./catalog.mjs";
34
+ export { deriveInputs, deriveOutputs, deriveSettings, INPUT_SPECS, SETTING_SPECS } from "./io.mjs";
35
+ export { decodeShareUrl, decodeShareFragment, isShareRef } from "./share.mjs";
36
+ export { resizePlan, maskToSource, resizeCropImage, encodeWavMono } from "./local-media.mjs";
37
+ export { parseNanoInvoice } from "./x402.mjs";
38
+ export { qrTerminal, qrModules } from "./qr.mjs";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Opt-in model catalog (replace-prep: catalog gates behave like play RUNTIME_JS).
3
+ *
4
+ * Data-only: pass `{ catalog: { chat, image, video, audio } }` to Workflow with
5
+ * the raw arrays the NanoGPT public catalog endpoints return (/api/v1/models,
6
+ * /api/v1/image-models, …) — the library never fetches them itself. Every gate
7
+ * is permissive: no catalog, or a model absent from it, changes nothing, so
8
+ * authored graphs keep their behavior offline. Only a KNOWN-incapable model has
9
+ * the gated part/knob stripped (mirrors play's chatModelCan / rawCatItem).
10
+ */
11
+
12
+ export function catItem(catalog, kind, id) {
13
+ if (!catalog || !id) return null;
14
+ const raw = catalog[kind];
15
+ return (Array.isArray(raw) && raw.find((m) => m && m.id === id)) || null;
16
+ }
17
+
18
+ /** Permissive capability probe: true unless the model is in the catalog AND lacks the flag. */
19
+ export function chatModelCan(catalog, model, flag) {
20
+ const m = catItem(catalog, "chat", model);
21
+ return !m || !!((m.capabilities || {})[flag]);
22
+ }