1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// =============================================================================
// bnto-core — The Foundation WASM Library
// =============================================================================
//
// Shared foundation for all Bnto WASM node crates: error types,
// the NodeProcessor trait, progress reporting, pipeline execution,
// and the node registry. This is an rlib -- it doesn't produce a
// .wasm file itself. That's the job of the bnto-wasm entry point.
// --- Public Modules ---
// These are the building blocks that node crates and the web app will use.
/// Centralized string case/formatting — lower, upper, title, slug, deslug, etc.
/// The Rust equivalent of JS's `change-case` library.
/// In-process PATH lookup mirroring `std::process::Command` spawn rules.
/// Backs `ProcessContext::find_binary` for native contexts.
/// Controlled system access for processors that need external tools.
/// Browser gets `NoopContext`, CLI gets `NativeContext`, desktop gets `SandboxedContext`.
/// Error types for the WASM engine.
/// Every error that can happen during node execution is defined here.
/// Structured pipeline events — rich progress reporting for multi-node execution.
/// Powers per-node status highlighting in the editor, progress bars, and error display.
/// Definition JSON Schema — validates `.bnto.json` files.
/// Generates a JSON Schema (Draft 2020-12) describing the Definition structure
/// so any consumer can validate recipe files without reimplementing TS types.
/// Document-shape types for `.bnto.json` files — the authoring view.
/// Mirrors the TypeScript `Definition` types and round-trips every real
/// recipe fixture. Distinct from `pipeline` (the execution-pruned view).
/// Node metadata types — self-describing processor definitions.
/// Each processor declares its name, category, parameters, accepted MIME types,
/// and whether it runs in the browser. Powers the `node_catalog()` WASM export.
/// The pipeline executor — walks nodes, iterates files, chains outputs.
/// This is the engine's brain. See `.claude/strategy/engine-execution.md`.
/// Recipe check — unknown node types, refused params and malformed
/// placeholders, found without running anything.
/// The operating systems a recipe runs on, worked out from its platform guards.
/// Control nodes (assert, report) that steer a run rather than transform files.
/// Data nodes (edit-fields) that change the fields items carry.
/// Pipeline definition types — what the engine receives to execute.
/// Mirrors the TypeScript `PipelineDefinition` / `PipelineNode` types.
/// `PipelineEdge` — a connection between two sibling pipeline nodes.
/// Level graph — validates one level's edges and orders its nodes.
/// `InputMode` and its wire-string form (the input node's `mode` param).
/// The NodeProcessor trait — the contract every node type must implement.
/// If you're building a new node (like image compression), you implement this.
/// Progress reporting — how nodes tell the UI "I'm 50% done".
/// Uses target-agnostic closures (no WASM dependency).
/// Node registry — maps node type keys (e.g., "image-compress") to processors.
/// Replaces the JS-side `wasmLoader.ts` registry.
/// Node-level field declarations — typed user-facing controls for nodes.
/// Field values are substituted into `{{fields.*}}` templates at execution time.
/// Editor state model — pure-data recipe editing state.
/// Shared by all editor surfaces (TUI List, Wizard, Code, Graph).
/// No TUI dependency. Sprint 15 extracts to standalone `bnto-editor` crate.
/// Engine-level logging — trait + types for structured diagnostics.
/// Browser gets `NoopLogger`, CLI gets `FileLogger`.
/// File content abstraction — in-memory bytes or on-disk path reference.
/// Large files (shell-run outputs) stay on disk as path references to
/// avoid reading multi-GB files into memory.
/// Simple dotenv parser — loads KEY=VALUE pairs from `.env` files.
/// No crate dependency, handles comments, quotes, and `export` prefix.
/// Secret declarations for recipes — pre-flight validation of required env vars.
/// Recipes declare what secrets they need; the engine validates before execution.
/// Caller-supplied `{{vars.KEY}}` values, resolved once before a run.
/// A run's outcome as one serializable summary, plus per-node counts
/// tallied from its pipeline events.
/// Node types and params a migration renamed, so errors can name the new
/// spelling and point at `bnto migrate`.
/// Relative paths as output-file names, `/`-separated on every OS.
/// Params a recipe gives a node that the node doesn't declare.
/// `{{fields.*}}` references no field value fills.
/// Civil (calendar) UTC time from epoch time, with no date crate.
/// `rfc3339_utc` is the one format for times nodes and templates report.
/// Version constraint checking for external dependencies.
/// Parses `--version` output, extracts version numbers, validates against
/// constraint strings like `">=6.0"`.
// --- Re-exports ---
// These `pub use` statements let users import directly from the crate root.
// Instead of writing `use bnto_core::errors::BntoError`, they can write
// `use bnto_core::BntoError`. Convenience!
pub use find_on_path;
pub use ;
pub use CommandOptions;
pub use ;
pub use ;
pub use definition_json_schema;
pub use ;
pub use BntoError;
pub use ;
pub use execute_pipeline;
pub use ;
pub use ;
pub use FileData;
pub use ;
pub use ;
pub use ;
pub use ;
pub use PipelineEdge;
pub use ;
pub use ;
pub use NodeRegistry;
pub use ;
pub use SecretDef;
pub use slash_path;
pub use ;
// =============================================================================
// Shared Constants
// =============================================================================
//
// Constants used by multiple node crates live here so there's a single source
// of truth. When compress, resize, and convert all need the same default JPEG
// quality, defining it once in bnto-core prevents the values from drifting
// apart over time.
/// The current `.bnto.json` format version.
///
/// This must stay in sync with `CURRENT_FORMAT_VERSION` in `@bnto/nodes`.
/// The WASM engine uses this to verify that a definition it receives is
/// compatible with the node processors it has compiled in.
///
/// Semver rules: definitions with the same major version are compatible.
/// A definition at "1.3.0" works fine on an engine that supports "1.0.0".
pub const FORMAT_VERSION: &str = "1.0.0";
/// Default quality when not specified by the user (1-100 scale).
/// 80 is the industry sweet spot: significant file size savings with barely
/// noticeable quality loss for most photos. Used by all image operations
/// (compress, resize, convert).
pub const DEFAULT_QUALITY: u8 = 80;
// =============================================================================
// Utility Functions (Pure Rust — no WASM boundary)
// =============================================================================
//
// NOTE: setup(), version(), and greet() used to live here with #[wasm_bindgen]
// attributes. They've moved to the bnto-wasm entry point crate which is the
// single cdylib that produces the .wasm file for the browser. This crate is
// now purely an rlib (Rust library) — no JS exports.
//
// These utility functions remain available as regular Rust functions for use
// by other crates in the workspace and for testing.
/// Returns the version of the bnto-core crate.
// =============================================================================
// Tests
// =============================================================================