---
url: 'https://adk.nht.io/api/@nhtio/adk/batteries/functions/defineIsolatedService.md'
---

# Function: defineIsolatedService()

```ts
function defineIsolatedService<M, S, E>(
  input: IsolatedServiceSpecInput<M, S, E>,
): IsolatedServiceSpec<M, S, E>;
```

Defined in: [src/batteries/isolation/validation.ts:94](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/validation.ts#L94)

Define an isolated service's spec — validates `input` eagerly (see
validateIsolatedServiceSpecInput) then resolves it via
@nhtio/adk/batteries/isolation!resolveIsolatedServiceSpec. This is the public entry point
re-exported as `defineIsolatedService` from this battery's `index.ts` barrel.

## Type Parameters

| Type Parameter                                            | Default type                                                                                                    |
| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `M` *extends* [`MethodMap`](../type-aliases/MethodMap.md) | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`never`, `never`> |
| `S` *extends* [`StreamMap`](../type-aliases/StreamMap.md) | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`never`, `never`> |
| `E` *extends* [`EventMap`](../type-aliases/EventMap.md)   | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`never`, `never`> |

## Parameters

| Parameter | Type                                                                                     |
| --------- | ---------------------------------------------------------------------------------------- |
| `input`   | [`IsolatedServiceSpecInput`](../interfaces/IsolatedServiceSpecInput.md)<`M`, `S`, `E`> |

## Returns

[`IsolatedServiceSpec`](../interfaces/IsolatedServiceSpec.md)<`M`, `S`, `E`>

## Throws

@nhtio/adk/batteries/isolation!E\_INVALID\_ISOLATION\_OPTIONS when the spec fails
validation (missing/empty `name`, unknown top-level key, or a name collision across
`methods`/`streams`/`events`).
