---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/type-aliases/IsolatedImplementation.md
description: >-
  The guest-side implementation object a caller of `serveIsolated` must provide
  — one function per declared method/stream. Method implementations may return
  their result synchronously or as a `Promise`. Every method implementation
  accepts an optional trailing [`IsolationCallContext`](https://adk.nht.io/api/@nhtio/adk/batteries/interfaces/IsolationCallContext) uniformly (a
  deliberate typing simplification — see remarks below); at RUNTIME a context is
  only ever constructed and passed when the method descriptor declared `{
  signal: true }`, so an implementation that ignores the parameter for a
  non-`signal` method simply never receives one. Stream implementations may
  return a `ReadableStream<D>` or any `AsyncIterable<D>` (e.g. an async
  generator), and always receive a trailing [`StreamHandle`](https://adk.nht.io/api/@nhtio/adk/batteries/interfaces/StreamHandle). Declared
  `events` are NOT part of this object — see `serveIsolated`'s factory `emit`
  parameter.
---

# Type Alias: IsolatedImplementation\<S>

```ts
type IsolatedImplementation<S> = {
  [K in keyof S["methods"]]: (
    args: [...MethodArgs<S["methods"][K]>, ctx?: IsolationCallContext],
  ) => MethodResult<S["methods"][K]> | Promise<MethodResult<S["methods"][K]>>;
} & {
  [K in keyof S["streams"]]: (
    args: [...StreamArgs<S["streams"][K]>, handle: StreamHandle],
  ) =>
    | ReadableStream<StreamDelta<S["streams"][K]>>
    | AsyncIterable<StreamDelta<S["streams"][K]>>;
};
```

Defined in: [src/batteries/isolation/types.ts:284](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L284)

The guest-side implementation object a caller of `serveIsolated` must provide — one function per
declared method/stream. Method implementations may return their result synchronously or as a
`Promise`. Every method implementation accepts an optional trailing [IsolationCallContext](../interfaces/IsolationCallContext.md)
uniformly (a deliberate typing simplification — see remarks below); at RUNTIME a context is only ever
constructed and passed when the method descriptor declared `{ signal: true }`, so an implementation
that ignores the parameter for a non-`signal` method simply never receives one. Stream implementations
may return a `ReadableStream<D>` or any `AsyncIterable<D>` (e.g. an async generator), and always
receive a trailing [StreamHandle](../interfaces/StreamHandle.md). Declared `events` are NOT part of this object — see
`serveIsolated`'s factory `emit` parameter.

## Type Parameters

| Type Parameter                                                              |
| --------------------------------------------------------------------------- |
| `S` *extends* [`IsolatedServiceSpec`](../interfaces/IsolatedServiceSpec.md) |

## Remarks

Conditioning the trailing parameter's presence on `S['methods'][K] extends { signal: true }` at the
type level runs into a genuine TypeScript inference gap: the `method<A, R>({ signal: true })` factory
can't carry `signal`'s literal-`true` value through to the mapped type without the descriptor's
optional `signal?: boolean` property widening back to `boolean` (or `true | undefined`) well before the
conditional type gets to test it, making the `extends { signal: true }` branch either never trigger or
trigger unconditionally. Rather than reach for `const`-generic phantom-typing surgery to fight that,
this mapped type intentionally accepts the simpler, slightly-less-precise contract: the trailing
context is always optionally typed, regardless of the descriptor's declared `signal` option.
