---
title: Standalone Inspector API
description: Generated public TypeScript reference for @relkit/inspector.
search:
  exclude: true
sidebar:
  icon: braces
---

{/* Generated by apps/docs/scripts/generate.ts. Do not edit. */}

For configuration and examples, read [inspector](/docs/modules/operations/inspector).

## Public imports

- `@relkit/inspector` — 13 exports

## All exported APIs

Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API's inline sample, a maintained repository usage, or the shared module walkthrough.

| API                                                                          | Kind  | Import from         | Example                                                                                                            |
| ---------------------------------------------------------------------------- | ----- | ------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [INSPECTOR_HELP](/docs/api/inspector#inspector_help-1)                       | Value | `@relkit/inspector` | [Module example](/docs/modules/operations/inspector)                                                               |
| [InspectorDiscovery](/docs/api/inspector#inspectordiscovery-class)           | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/discovery-bun.test.ts#L36)   |
| [InspectorDiscoveryLive](/docs/api/inspector#inspectordiscoverylive)         | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/discovery-bun.test.ts#L18)   |
| [InspectorHistory](/docs/api/inspector#inspectorhistory-class)               | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/history-bun.test.ts#L33)     |
| [inspectorHistoryLayer](/docs/api/inspector#inspectorhistorylayer)           | Value | `@relkit/inspector` | [Module example](/docs/modules/operations/inspector)                                                               |
| [InspectorHistoryNative](/docs/api/inspector#inspectorhistorynative-class)   | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/history-domain.test.ts#L16)  |
| [InspectorHistoryNativeLive](/docs/api/inspector#inspectorhistorynativelive) | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/history-bun.test.ts#L57)     |
| [InspectorOptions](/docs/api/inspector#inspectoroptions-interface)           | Type  | `@relkit/inspector` | [Module example](/docs/modules/operations/inspector)                                                               |
| [InspectorRemote](/docs/api/inspector#inspectorremote-class)                 | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/backend.test.ts#L187)        |
| [InspectorRemoteLive](/docs/api/inspector#inspectorremotelive-1)             | Value | `@relkit/inspector` | [Module example](/docs/modules/operations/inspector)                                                               |
| [InspectorTool](/docs/api/inspector#inspectortool-class)                     | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/tool-shutdown.test.ts#L19)   |
| [InspectorToolLive](/docs/api/inspector#inspectortoollive-1)                 | Value | `@relkit/inspector` | [Module example](/docs/modules/operations/inspector)                                                               |
| [parseInspectorOptions](/docs/api/inspector#parseinspectoroptions-1)         | Value | `@relkit/inspector` | [Source example](https://github.com/rel-kit/relkit/blob/main/packages/inspector/tests/container-policy.test.ts#L6) |

## `backend-forward.ts`

Live operations are forwarded once; bridge rejections retain their HTTP status in the UI protocol.

### forwardBackend

Preserves native cookies, authorization, operation IDs and streaming bodies.

**Signature**

```ts
declare const forwardBackend: (
  remote: InspectorRemoteOperations,
  connection: InspectionConnectionFile,
  request: Request,
  target?: string | undefined,
) => Effect.Effect<Response, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/backend-forward.ts#L9)

## `backend-history.ts`

History queries stay in the standalone writer; no application config is executed.

### backendError

Credential-free failures retain the UI's established error protocol.

**Signature**

```ts
declare const backendError: (error: string, status: number) => Response;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/backend-history.ts#L56)

### historyResponse

Decodes only supported query/detail paths and returns their existing public protocol.

**Signature**

```ts
declare const historyResponse: (
  current: InspectorToolState,
  request: Request,
  match: RegExpExecArray,
) => Effect.Effect<Response, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/backend-history.ts#L12)

## `bin.ts`

Native standalone entry; signals interrupt and join the tool's complete resource Scope.

## `collection.schemas.ts`

Validates network records again; in-process redaction brands are never trusted across JSON.

### InspectionCollectionBatch

A finite batch has monotonic session sequence identities and optional producer attribution.

**Signature**

```ts
declare const InspectionCollectionBatch: Schema.fromJsonString<
  Schema.Struct<{
    readonly records: Schema.$Array<
      Schema.Struct<{
        readonly sequence: Schema.Number;
        readonly record: Schema.declare<ObservabilityRecord, ObservabilityRecord>;
        readonly identity: Schema.optionalKey<
          Schema.Struct<{
            readonly key: Schema.String;
            readonly origin: Schema.Literals<readonly ["application", "relkit", "inspector"]>;
          }>
        >;
      }>
    >;
    readonly gap: Schema.Boolean;
    readonly droppedRecords: Schema.Number;
    readonly incomplete: Schema.Boolean;
    readonly droppedBytes: Schema.optionalKey<Schema.Number>;
    readonly producerFailed: Schema.optionalKey<Schema.Number>;
    readonly producerDropped: Schema.optionalKey<Schema.Number>;
  }>
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/collection.schemas.ts#L16)

## `collector-changes.ts`

Coalesces UI invalidations without retaining another copy of committed records.

### collectionChange

Uses existing event names so current graph/history/job views refresh after commits.

**Signature**

```ts
declare const collectionChange: (record: ObservabilityRecord) => ObservabilityStreamEventType;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/collector-changes.ts#L5)

## `collector-loss.ts`

Cumulative loss has an independent durable identity, outside the saturated application's buffer.

### persistCollectionLoss

One tiny transaction follows record persistence; a lost ACK reuses the same receipt key.

**Signature**

```ts
declare const persistCollectionLoss: (
  history: InspectorHistoryOperations,
  batch: {
    readonly records: ReadonlyArray<{
      readonly record: ObservabilityRecord;
      readonly sequence: number;
      readonly identity?: {
        readonly key: string;
        readonly origin: "application" | "relkit" | "inspector";
      };
    }>;
    readonly gap: boolean;
    readonly droppedRecords: number;
    readonly incomplete: boolean;
    readonly droppedBytes?: number;
    readonly producerFailed?: number;
    readonly producerDropped?: number;
  },
  sessionId: string,
  previous?: string | undefined,
) => Effect.Effect<string | undefined, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/collector-loss.ts#L8)

## `collector.ts`

Commits a finite replay batch before ACK; lost ACKs replay stable keys without duplicate writes.

### collectInspectionBatch

One bounded pull needs no independent pending queue or in-memory history copy.

**Signature**

```ts
declare const collectInspectionBatch: (
  remote: InspectorRemoteOperations,
  history: InspectorHistoryOperations,
  connection: InspectionConnectionFile,
  after: number,
  target?: string | undefined,
  previousLossKey?: string | undefined,
) => Effect.Effect<
  {
    through: number;
    gap: boolean;
    droppedRecords: number;
    incomplete: boolean;
    records: number;
    lossKey: string | undefined;
    producerFailed: number;
    producerDropped: number;
    changes: Array<
      | "request.started"
      | "request.completed"
      | "log.emitted"
      | "span.started"
      | "span.updated"
      | "span.completed"
      | "job.changed"
      | "event.published"
      | "event.delivery.changed"
      | "generation.changed"
      | "diagnostic.changed"
    >;
  },
  InspectionConnectionError,
  never
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/collector.ts#L17)

## `container-bin.ts`

Linux image entry requires explicit persistent mounts before acquiring the tool.

## `container-exit.ts`

A joined requested shutdown is healthy; mixed failures retain normal failure exit codes.

### inspectorContainerTeardown

**Signature**

```ts
declare const inspectorContainerTeardown: Runtime.Teardown;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/container-exit.ts#L4)

## `container-native.ts`

Reads Linux mount authority only at the image's explicit native entry.

### requireInspectorContainer

**Signature**

```ts
declare const requireInspectorContainer: (
  options: InspectorOptions,
) => Effect.Effect<undefined, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/container-native.ts#L9)

## `container-policy.ts`

Restricts image execution to a private directory mount and persistent history.

### validateInspectorContainer

**Signature**

```ts
declare const validateInspectorContainer: (
  options: InspectorOptions,
  uid: number,
  mountInfo: string,
) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/container-policy.ts#L5)

## `discovery.service.ts`

Authenticates session discovery without executing project code or deleting stale metadata.

### InspectorDiscovery (class)

Captures metadata and transport authority before creating any per-tool session state.

**Signature**

```ts
declare class InspectorDiscovery
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/discovery.service.ts#L19)

### InspectorDiscoveryLive

Native discovery performs no config import, writes, installation or PID liveness probes.

**Signature**

```ts
declare const InspectorDiscoveryLive: Layer.Layer<InspectorDiscovery, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/discovery.service.ts#L33)

## `discovery.types.ts`

Discovery results keep credentials private and never select by PID or file age.

### InspectorDiscoveryOperations (interface)

Read-only discovery leaves stale and foreign descriptors untouched.

**Signature**

```ts
export interface InspectorDiscoveryOperations {
  readonly select: (
    options: InspectorOptions,
  ) => Effect.Effect<InspectorSelection, InspectionConnectionError>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/discovery.types.ts#L22)

### InspectorSelection (type alias)

Only an authenticated matching handshake grants live forwarding authority.

**Signature**

```ts
type InspectorSelection =
  | { readonly state: "disconnected"; readonly rejected: number }
  | { readonly state: "ambiguous"; readonly sessions: readonly string[]; readonly rejected: number }
  | {
      readonly state: "connected";
      readonly connection: InspectionConnectionFile;
      readonly handshake: InspectionHandshake;
      readonly rejected: number;
    };
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/discovery.types.ts#L11)

## `history-binding.ts`

Binds a history directory to one project without replacing existing data or deleting locks.

### bindInspectorHistory

Publishes an immutable project marker atomically, retaining legacy history in place.

**Signature**

```ts
declare const bindInspectorHistory: (
  root: string,
  projectId: string,
) => Effect.Effect<undefined, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history-binding.ts#L16)

## `history-native.service.ts`

Acquires the optional isolated writer and validates its opening receipt before exposing it.

### InspectorHistoryNative (class)

Tests substitute the complete native boundary without inheriting live process authority.

**Signature**

```ts
declare class InspectorHistoryNative
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history-native.service.ts#L11)

### InspectorHistoryNativeLive

Native worker module is owned exclusively by the standalone tool.

**Signature**

```ts
declare const InspectorHistoryNativeLive: Layer.Layer<InspectorHistoryNative, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history-native.service.ts#L19)

### historyNativeFailure

Retains precise native failure evidence without exposing native payloads to browser responses.

**Signature**

```ts
declare const historyNativeFailure: <Cause extends Error>(
  cause: Cause,
) => InspectionConnectionError;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history-native.service.ts#L52)

## `history-native.types.ts`

Native history acquisition is replaceable and retains caller lifetime authority.

### InspectorHistoryNativeOperations (interface)

Owns project binding, worker open and joined physical shutdown as one acquisition.

**Signature**

```ts
export interface InspectorHistoryNativeOperations {
  readonly acquire: (
    root: string,
    projectId: string,
  ) => Effect.Effect<LocalWorkerEffects, InspectionConnectionError, Scope.Scope>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history-native.types.ts#L7)

## `history-reply.ts`

Validates native IPC payloads through the shared model/query owner before exposing browser data.

### validateHistoryReply

A transport-level JSON decode alone cannot certify a worker query response.

**Signature**

```ts
declare const validateHistoryReply: (
  command: LocalWorkerCommand,
  value: Schema.Json | undefined,
) => Effect.Effect<void, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history-reply.ts#L17)

## `history.service.ts`

Owns the existing isolated DuckDB worker and preserves its transactional receipt semantics.

### InspectorHistory (class)

Persistent history opens only inside the standalone tool's Scope.

**Signature**

```ts
declare class InspectorHistory
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history.service.ts#L10)

### inspectorHistoryLayer

Supplies exactly one native writer owner for the selected project.

**Signature**

```ts
declare const inspectorHistoryLayer: (
  root: string,
  projectId: string,
) => Layer.Layer<InspectorHistory, InspectionConnectionError, InspectorHistoryNative>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history.service.ts#L49)

## `history.types.ts`

Standalone history owns the native worker; the application receives only durable ACKs.

### InspectorHistoryOperations (interface)

Serialized operations use the existing project store/schema and stable receipt keys.

**Signature**

```ts
export interface InspectorHistoryOperations {
  readonly call: (
    command: LocalWorkerCommand,
  ) => Effect.Effect<Schema.Json | undefined, InspectionConnectionError>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/history.types.ts#L7)

## `index.ts`

Standalone tool entry; project inspection never evaluates application configuration.

### INSPECTOR_HELP

**Signature**

```ts
declare const INSPECTOR_HELP: "Usage: relkit-inspector [options]\n  --project-root <directory>     Discover running sessions without evaluating the project\n  --connection-file <file>       Explicitly select one private session descriptor\n  --credential-file <file>       Private descriptor supplying matching session credentials\n  --target <http-origin>         Override network routing while verifying original identity\n  --history-directory <path>     Persistent project-bound history (default .relkit/observability)\n  --hostname <host>              UI bind host (default 127.0.0.1)\n  --port <number>                UI port (default 3210)\n  --help                        Show this help\n";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L2)

### InspectorDiscovery

**Signature**

```ts
declare const InspectorDiscovery: typeof InspectorDiscovery;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L4)

### InspectorDiscoveryLive

**Signature**

```ts
declare const InspectorDiscoveryLive: Layer<InspectorDiscovery, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L4)

### InspectorHistory

**Signature**

```ts
declare const InspectorHistory: typeof InspectorHistory;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L7)

### InspectorHistoryNative

**Signature**

```ts
declare const InspectorHistoryNative: typeof InspectorHistoryNative;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L8)

### InspectorHistoryNativeLive

**Signature**

```ts
declare const InspectorHistoryNativeLive: Layer<InspectorHistoryNative, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L8)

### InspectorOptions

**Signature**

```ts
declare const InspectorOptions: InspectorOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L3)

### InspectorRemote

**Signature**

```ts
declare const InspectorRemote: typeof InspectorRemote;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L5)

### InspectorRemoteLive

**Signature**

```ts
declare const InspectorRemoteLive: Layer<InspectorRemote, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L5)

### InspectorTool

**Signature**

```ts
declare const InspectorTool: typeof InspectorTool;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L6)

### InspectorToolLive

**Signature**

```ts
declare const InspectorToolLive: Layer<InspectorTool, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L6)

### inspectorHistoryLayer

**Signature**

```ts
declare const inspectorHistoryLayer: (
  root: string,
  projectId: string,
) => Layer<InspectorHistory, InspectionConnectionError, InspectorHistoryNative>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L7)

### parseInspectorOptions

**Signature**

```ts
declare const parseInspectorOptions: (args: readonly string[]) => InspectorOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/index.ts#L2)

## `live-events.ts`

UI invalidations borrow the existing bounded stream, while full records stay in history.

### acquireLiveEvents

The tool Scope closes every subscriber before releasing its listener.

**Signature**

```ts
declare const acquireLiveEvents: Effect.Effect<ObservabilityStream, never, Scope>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/live-events.ts#L8)

### publishCollection

One small invalidation per signal follows the committed batch; no history copy is retained.

**Signature**

```ts
declare const publishCollection: (
  stream: ObservabilityStream,
  changes: readonly ObservabilityStreamEventType[],
) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/live-events.ts#L45)

### publishSelection

Session/generation changes invalidate metadata without exposing session credentials.

**Signature**

```ts
declare const publishSelection: (
  stream: ObservabilityStream,
  previous: InspectorSelection,
  next: InspectorSelection,
) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/live-events.ts#L21)

## `options.ts`

Parses trusted tool launch flags without importing an application's config or dependencies.

### INSPECTOR_HELP

Public standalone launch help; tokens are accepted only through private files.

**Signature**

```ts
declare const INSPECTOR_HELP: "Usage: relkit-inspector [options]\n  --project-root <directory>     Discover running sessions without evaluating the project\n  --connection-file <file>       Explicitly select one private session descriptor\n  --credential-file <file>       Private descriptor supplying matching session credentials\n  --target <http-origin>         Override network routing while verifying original identity\n  --history-directory <path>     Persistent project-bound history (default .relkit/observability)\n  --hostname <host>              UI bind host (default 127.0.0.1)\n  --port <number>                UI port (default 3210)\n  --help                        Show this help\n";
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/options.ts#L8)

### parseInspectorOptions

Validates all launch authority before opening a listener, history or a child.

**Signature**

```ts
declare const parseInspectorOptions: (args: readonly string[]) => InspectorOptions;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/options.ts#L20)

## `options.types.ts`

Trusted launch inputs; none are accepted from a browser request.

### InspectorOptions (interface)

Trusted launch inputs; none are accepted from a browser request.

**Signature**

```ts
export interface InspectorOptions {
  readonly projectRoot?: string;
  readonly connectionFile?: string;
  readonly credentialFile?: string;
  readonly target?: string;
  readonly historyDirectory?: string;
  readonly hostname: string;
  readonly port: number;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/options.types.ts#L2)

## `remote.service.ts`

Authenticates bounded server-to-server requests without exposing app credentials to UI.

### InspectorRemote (class)

Remote transport can be replaced by a deterministic Layer in collection tests.

**Signature**

```ts
declare class InspectorRemote
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/remote.service.ts#L8)

### InspectorRemoteLive

Live request capability; acquisition opens no network connections.

**Signature**

```ts
declare const InspectorRemoteLive: Layer.Layer<InspectorRemote, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/remote.service.ts#L18)

## `remote.types.ts`

Server-only remote authority with no application module evaluation.

### InspectorRemoteOperations (interface)

Single-shot requests preserve native operation IDs; callers never retry mutations.

**Signature**

```ts
export interface InspectorRemoteOperations {
  readonly request: (
    connection: InspectionConnectionFile,
    path: string,
    options?: RequestInit,
    target?: string,
  ) => Effect.Effect<Response, InspectionConnectionError>;
  readonly json: (response: Response) => Effect.Effect<string, InspectionConnectionError>;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/remote.types.ts#L9)

## `tool-backend.ts`

Protects UI server requests and serves history locally while forwarding live operations once.

### inspectorBackend

The packaged Next server alone receives credentials for this local hop.

**Signature**

```ts
declare const inspectorBackend: (
  state: InspectorToolStateRef,
  remote: InspectorRemoteOperations,
  token: string,
  options: InspectorOptions,
  stream: ObservabilityStream,
) => (request: Request) => Effect.Effect<Response, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-backend.ts#L17)

## `tool-history.ts`

Keeps history acquisition attached to the tool and hides retiring writers before native cleanup.

### acquireHistory

Opens legacy project history in a parent-owned child Scope and rejects cross-project reuse.

**Signature**

```ts
declare const acquireHistory: (
  state: InspectorToolStateRef,
  files: InspectionFilesOperations,
  options: InspectorOptions,
) => Effect.Effect<undefined, InspectionConnectionError, Scope.Scope | InspectorHistoryNative>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-history.ts#L11)

### recoverInspection

Recovery detaches unavailable history and its connection fence before awaiting a slow close.

**Signature**

```ts
declare const recoverInspection: (
  state: InspectorToolStateRef,
  error: InspectionConnectionError,
) => Effect.Effect<void, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-history.ts#L46)

## `tool-loop.ts`

Serializes bounded discovery, recovery and collection independently from application requests.

### inspectionLoop

Only one poll/batch can be pending; support failure uses a finite recovery interval.

**Signature**

```ts
declare const inspectionLoop: (
  state: InspectorToolStateRef,
  discovery: InspectorDiscoveryOperations,
  remote: InspectorRemoteOperations,
  files: InspectionFilesOperations,
  options: InspectorOptions,
  stream: ObservabilityStream,
) => Effect.Effect<never, InspectionConnectionError, Scope | InspectorHistoryNative>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-loop.ts#L15)

## `tool-main.ts`

Shares the native signal owner between package and restricted container entries.

### runInspectorMain

**Signature**

```ts
declare const runInspectorMain: (container: boolean) => void;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-main.ts#L10)

## `tool-state.types.ts`

Tool-owned projection; browser responses must select safe fields instead of serializing it.

### InspectorHistoryOwner (interface)

One native writer and its child Scope survive app generation/session changes.

**Signature**

```ts
export interface InspectorHistoryOwner {
  readonly projectId: string;
  readonly scope: Scope.Closeable;
  readonly operations: InspectorHistoryOperations;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-state.types.ts#L7)

### InspectorToolState (interface)

Collection state contains only one finite batch at a time; no pending write queue.

**Signature**

```ts
export interface InspectorToolState {
  readonly selection: InspectorSelection;
  readonly history: InspectorHistoryOwner | undefined;
  readonly sessionId: string | undefined;
  readonly through: number;
  readonly error: string | undefined;
  readonly incomplete: boolean;
  readonly droppedRecords: number;
  readonly lossKey?: string | undefined;
  readonly producerFailed?: number | undefined;
  readonly producerDropped?: number | undefined;
}
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-state.types.ts#L14)

### InspectorToolStateRef (type alias)

Shared projection is owned by the acquired tool, never module global.

**Signature**

```ts
type InspectorToolStateRef = Ref.Ref<InspectorToolState>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool-state.types.ts#L28)

## `tool.service.ts`

Composes standalone UI, collector, private discovery and a single project history writer.

### InspectorTool (class)

Native authority is captured once; every run owns an independent tool Scope.

**Signature**

```ts
declare class InspectorTool
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool.service.ts#L22)

### InspectorToolLive

Live command composition; no app compiler, evaluator or native feature SDK is included.

**Signature**

```ts
declare const InspectorToolLive: Layer.Layer<InspectorTool, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/tool.service.ts#L43)

## `ui-native.service.ts`

Owns the packaged Node UI child without inheriting application environment values.

### InspectorUiNative (class)

Native UI acquisition is separate from all application/session ownership.

**Signature**

```ts
declare class InspectorUiNative
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/ui-native.service.ts#L11)

### InspectorUiNativeLive

Live child adapter, acquired only by an explicit standalone launch.

**Signature**

```ts
declare const InspectorUiNativeLive: Layer.Layer<InspectorUiNative, never, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/ui-native.service.ts#L27)

### acquireInspectorUi

Runs the exact packaged UI and joins its process on tool exit.

**Signature**

```ts
declare const acquireInspectorUi: (
  entry: string,
  options: InspectorOptions,
  backend: string,
  token: string,
) => Effect.Effect<
  Effect.Effect<never, InspectionConnectionError, never>,
  InspectionConnectionError,
  Scope
>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/ui-native.service.ts#L30)

## `ui-readiness.ts`

Requires complete UI response bytes and joins cancellation before advertising listening.

### probeInspectorUi

Fetch cancellation reaches both headers and body; an oversized UI reply is never ready.

**Signature**

```ts
declare const probeInspectorUi: (
  fetcher: typeof fetch,
  endpoint: string,
) => Effect.Effect<boolean, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/ui-readiness.ts#L16)

### waitInspectorUiReady

The caller supplies native authority; expected connection failures retry within one minute.

**Signature**

```ts
declare const waitInspectorUiReady: (
  probe: Effect.Effect<boolean, InspectionConnectionError>,
) => Effect.Effect<boolean, InspectionConnectionError, never>;
```

[Source](https://github.com/rel-kit/relkit/blob/main/packages/inspector/src/ui-readiness.ts#L6)
