---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/orchestration/functions/loadOnce.md
---

# Function: loadOnce()

```ts
function loadOnce(id: string, loader: () => Promise<void>): () => Promise<void>;
```

Defined in: [src/batteries/orchestration/predicates.ts:389](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/predicates.ts#L389)

Wraps a cell's `load()` so it is idempotent and converts a failed lazy `await import()` into
`E_ORCH_CELL_UNAVAILABLE`.

A cell's `load()` is expected to resolve an optional ESM peer through a lazy `await import()`.
That import can fail (the package is not installed), and the failure must surface as a named
`E_ORCH_CELL_UNAVAILABLE` whose message names the missing package and its install command —
not as a raw module-resolution error the author cannot act on. This helper also makes `load()`
idempotent: the wrapped loader runs at most once, and every subsequent call resolves with the
same outcome, so a cell can be loaded once and reused across many plans without re-importing.

The helper is deliberately minimal — it is a single idempotence + error-mapping wrapper, not a
plugin registry. A cell that needs to register itself with a consumer's registry does so in its
own `load()` body, before or after calling the wrapped loader.

## Parameters

| Parameter | Type                      | Description                                                      |
| --------- | ------------------------- | ---------------------------------------------------------------- |
| `id`      | `string`                  | The cell's id, used to name the missing package in the error.    |
| `loader`  | () => `Promise`<`void`> | The cell's actual load body (typically a lazy `await import()`). |

## Returns

A wrapped loader that is idempotent and maps import failure to
`E_ORCH_CELL_UNAVAILABLE`.

() => `Promise`<`void`>
