Combines multiple required inputs into one output when the combined value is itself meaningful data. Supports collecting into arrays, merging objects, wrapping each input under a keyed object, or selecting a single input by index.

NOTE: Merge waits on all required sockets. Use it for required parallel inputs. If you are recombining mutually exclusive alternate branches, skip Merge and wire each branch to the same downstream socket. Otherwise the other sockets will wait indefinitely for branches that never arrive.

Merge is not a control-flow node and not a generic pipe adapter. Use `switch`, `if`, or `selector` for visible routing. If the next node is JS and needs several values, prefer named `input_names` on that JS node and wire inputs directly. Use Merge only when the next node truly needs a merged/selected/collected value.

**Prefer named sockets over adapter Merge:**

```text
FetchUser.output  -> BuildContext.user
FetchPrefs.output -> BuildContext.prefs
```

with JS config:

```json
{ "input_names": ["user", "prefs"] }
```

Avoid:

```text
FetchUser.output  -> Merge.input_1
FetchPrefs.output -> Merge.input_2
Merge.output      -> BuildContext.input
```

unless `BuildContext` actually needs the Merge node's merged object/array semantics.

**Config:**
- `mode` - `list` (collect into array), `merge` (deep merge objects), `object` (wrap each input under a key), or `select` (output only one branch by index)
- `input_count` - number of input sockets (default: 2)
- `output_keys` - array of keys for object mode (one per input, required when mode is `object`)
- `select_index` - 0-based index of which input to select (0 to N-1, required when mode is `select`, default: 0)

**Modes:**
- **list:** `{a:1}` + `{b:2}` → `[{a:1}, {b:2}]`
- **merge:** `{a:1}` + `{b:2}` → `{a:1, b:2}` (later values win)
- **object:** `{a:1}` + `{b:2}` with keys `["first", "second"]` → `{first: {a:1}, second: {b:2}}`
- **select:** `{a:1}` + `{b:2}` + `{c:3}` with index `1` → `{b:2}`

**Object Mode Example:**

Configuration:
- mode: `object`
- input_count: 3
- output_keys: `["user", "settings", "metadata"]`

Inputs:
- input_1: `{ "id": 123 }`
- input_2: `{ "theme": "dark" }`
- input_3: `{ "version": "1.0" }`

Output:
```json
{
  "user": { "id": 123 },
  "settings": { "theme": "dark" },
  "metadata": { "version": "1.0" }
}
```

**Select Mode Example:**

Configuration:
- mode: `select`
- input_count: 3
- select_index: 1

Inputs:
- input_1: `{ "source": "api" }`
- input_2: `{ "source": "cache" }`
- input_3: `{ "source": "fallback" }`

Output:
```json
{ "source": "cache" }
```

**Validation:**
- `output_keys` must have exactly `input_count` entries (for object mode)
- Keys cannot be empty strings
- Keys must be unique (no duplicates)
- `select_index` must be >= 0 (for select mode)
- `select_index` must be < `input_count` (for select mode)

**Inputs:** `input_1`, `input_2`, etc.
**Output:** Combined result (or selected input value in select mode)

## Data Piping Invariant

A downstream node only sees what is explicitly wired into it. Effectful nodes do not carry upstream row data through their output. If you need to upsert a row after a side-effect (Discord Send, HTTP POST, etc.), you must still pipe the original data to the write node. Do not place write/upsert nodes in thin air expecting data to appear from an unrelated upstream branch.

**Use `select` mode to pick the original payload:**
```
[Prepare Row Data]
    ↓
[Discord Send] ────┐
    ↓              │
[Merge: select 0] ←┘
    ↓
[Upsert Row] ← receives original row data, not Discord response
```

Wire the original data source into the first input of the Merge node, and the effectful node's output into the second input. Set `mode: select` with `select_index: 0` so the Merge passes through the original payload to the write node.
