The
transform operation is edge-compatible - no eval or Function constructors. All expressions (${...}) are resolved by the runtime before the agent executes.Quick Start
Return literal values:Configuration
Modes
Value Mode
Return a literal value. Expression interpolation (${...}) is resolved before the agent runs.
Input Mode
Pass through data with optional modifiers applied.Pick - Include Only Specified Fields
{ id: 1, name: "Alice", email: "alice@example.com", password: "secret", adminNotes: "..." }
Output: { id: 1, name: "Alice", email: "alice@example.com" }
Omit - Exclude Specified Fields
{ id: 1, name: "Alice", password: "secret", ssn: "123-45-6789" }
Output: { id: 1, name: "Alice" }
Rename - Rename Fields
{ user_id: 1, display_name: "Alice", created_at: "2024-01-15" }
Output: { id: 1, name: "Alice", createdAt: "2024-01-15" }
Defaults - Add Missing Fields
{ id: 1, name: "Alice" }
Output: { id: 1, name: "Alice", status: "pending", role: "user", verified: false }
Existing values are not overwritten:
Input: { id: 1, name: "Alice", status: "active" }
Output: { id: 1, name: "Alice", status: "active", role: "user", verified: false }
Combining Modifiers
Modifiers are applied in order: defaults → rename → pick → omitArray Input
Modifiers apply to each item in arrays:[{ id: 1, name: "Alice", password: "x" }, { id: 2, name: "Bob", password: "y" }]
Output: [{ id: 1, name: "Alice", status: "pending" }, { id: 2, name: "Bob", status: "pending" }]
Merge Mode
Combine multiple items into one.Object Merge
Later objects override earlier ones (shallow merge):{ id: 1, name: "Alice", theme: "dark", updatedAt: "2025-01-15T..." }
Array Concatenation
Arrays are flattened:[1, 2, 3, 4, 5, 6]
Parse & Format
Transform can parse and format data between different formats without custom code.CSV Parsing
Parse CSV strings to arrays of objects:CSV parsing uses papaparse with
dynamicTyping: true, so numbers are automatically converted to numeric types.CSV Formatting
Format arrays of objects to CSV strings:columns: [id, name, email]):
TSV (Tab-Separated Values)
Same as CSV but with tab delimiters:JSONL (Newline-Delimited JSON)
Parse/format newline-delimited JSON:XLSX (Excel)
Parse Excel files:Array Operations
Transform provides declarative array operations without writing loops.Filter
Keep only items where a field is truthy:Sort
Sort by a field:Pagination
Uselimit and offset for pagination:
Data Cleaning
Transform provides utilities for cleaning messy data.Trim
Trim whitespace from all string fields:{ name: " Alice ", email: " alice@example.com " }
Output: { name: "Alice", email: "alice@example.com" }
Compact
Remove null and undefined values:{ id: 1, name: "Alice", email: null, phone: undefined }
Output: { id: 1, name: "Alice" }
Dedupe
Remove duplicates:Coerce
Convert field types:string- Convert to stringnumber- Parse as number (returns 0 for invalid)boolean- Parse as boolean (“true”, “1”, “yes” → true)date- Parse as Date object (returns null for invalid)
Complete ETL Example
Here’s a complete example showing parse → transform → format:Mode Priority
When multiple modes are specified, they’re evaluated in this order:- value - If defined (including
null), use value mode - merge - If defined, use merge mode
- input - If defined, use input mode
Why Transform vs Code?
Use transform when you need:- Return static/mock data
- Parse/format CSV, TSV, XLSX, JSONL
- Pick/omit/rename fields from objects
- Merge multiple data sources
- Filter/sort/paginate arrays
- Clean data (trim, compact, dedupe)
- Type coercion
- Complex conditional logic
- Custom calculations
- Multiple dependent transformations
- External library calls
- Faster - No JavaScript parsing
- Safer - No arbitrary code execution
- Clearer - Declarative intent
- Cacheable - Deterministic outputs
Error Handling
Missing Mode
If no mode is specified, an error is thrown:transform operation requires one of: config.value, config.input, or config.merge
Empty Merge Array
transform merge mode requires a non-empty array
Invalid Parse Format
transform: unsupported parse format 'pdf'
JSONL Parse Error
transform: JSONL parse error at line 2: Invalid JSON
Performance
Transform is one of the fastest operations:XLSX operations are slower due to the library size. For high-performance use cases, prefer CSV.

