---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/orchestration/encoding/classes/NodeRef.md
description: 'A serializable reference to another node''s output — a CLASS, not a record.'
---

# Class: NodeRef

Defined in: [src/batteries/orchestration/encoding.ts:42](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L42)

A serializable reference to another node's output — a CLASS, not a record.

## Remarks

Why a class rather than a record with a marker field: a plain record can wear
`{kind: 'nodeRef', node, select, …}` — it is an ordinary encodable record — so a marker
property cannot separate a reference from a literal that happens to look like one, and a
resolver keying on it would silently rewrite the literal. `instanceof` is unforgeable: no
record can satisfy `NodeRef.isNodeRef`, and the encoder round-trips instances as
`custom:NodeRef` rather than as records. Same mechanism core uses for `Media`/`Tokenizable`.

`branchId` identifies WHICH EXECUTION of `node` to read — the same path identity `NodeOutput`
and `FrameRef` carry. Omitted means "do not filter".

## Constructors

### Constructor

```ts
new NodeRef(
   node: string,
   select:
  | "last"
  | "first"
  | "all"
  | {
  index: number;
},
   path?: string,
   branchId?: BranchId): NodeRef;
```

Defined in: [src/batteries/orchestration/encoding.ts:68](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L68)

Construct a `NodeRef`.

#### Parameters

| Parameter   | Type                                                            | Description                                                                               |
| ----------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `node`      | `string`                                                        | The id of the node whose output this reference reads.                                     |
| `select`    | | `"last"` | `"first"` | `"all"` | { `index`: `number`; } | Which item of that node's output to take: 'first', 'last', 'all', or an explicit {index}. |
| `path?`     | `string`                                                        | An optional dot-path into the selected item's value.                                      |
| `branchId?` | [`BranchId`](../../types/interfaces/BranchId.md)                | Which execution of the node to read, as a path identity; omitted means "do not filter".   |

#### Returns

`NodeRef`

## Properties

| Property                                   | Type                                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                        | Defined in                                                                                                                                    |
| ------------------------------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|  `branchId?` | [`BranchId`](../../types/interfaces/BranchId.md)                | WHICH EXECUTION of the node to read, as a path identity. **Remarks** This is NOT an outgoing branch of that node: a node fanning out to two successors still runs once and produces one output; what creates several outputs for one node is that node being REACHED by several paths. Omitted means "do not filter" — fine when exactly one path reaches the node, and refused at freeze when more than one does. | [src/batteries/orchestration/encoding.ts:58](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L58) |
|  `node`          | `string`                                                        | The id of the node whose output this reference reads.                                                                                                                                                                                                                                                                                                                                                              | [src/batteries/orchestration/encoding.ts:44](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L44) |
|  `path?`         | `string`                                                        | An optional dot-path into the selected item's value.                                                                                                                                                                                                                                                                                                                                                               | [src/batteries/orchestration/encoding.ts:48](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L48) |
|  `select`      | | `"last"` | `"first"` | `"all"` | { `index`: `number`; } | Which item of that node's output to take: 'first', 'last', 'all', or an explicit {index}.                                                                                                                                                                                                                                                                                                                          | [src/batteries/orchestration/encoding.ts:46](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L46) |

## Methods

### \[ENCODE\_METHOD]\()

```ts
ENCODE_METHOD: Record<string, unknown>;
```

Defined in: [src/batteries/orchestration/encoding.ts:86](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L86)

Emit a plain snapshot of the fields for the encoder.

#### Returns

[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`>

***

### \[DECODE\_METHOD]\()

```ts
static DECODE_METHOD: NodeRef;
```

Defined in: [src/batteries/orchestration/encoding.ts:91](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L91)

Rebuild an instance from a NodeRef.\[ENCODE\_METHOD] snapshot.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `data`    | `unknown` |

#### Returns

`NodeRef`

***

### isNodeRef()

```ts
static isNodeRef(v: unknown): v is NodeRef;
```

Defined in: [src/batteries/orchestration/encoding.ts:81](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/encoding.ts#L81)

`instanceof` guard — a look-alike record cannot pass.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `v`       | `unknown` |

#### Returns

`v is NodeRef`
