Documentation
    Preparing search index...

    Interface MockServiceDefinition<TState>

    Declarative description consumed by defineMockService.

    const service = defineMockService<{ count: number }>({
    domain: 'ping',
    version: '1.0.0',
    kind: 'extension',
    initialState: () => ({ count: 0 }),
    routes: {
    'ping.send': ({ state, reply }) => { state.count += 1; reply({ count: state.count }); },
    },
    });
    interface MockServiceDefinition<TState> {
        capabilities?: Readonly<
            Record<
                string,
                | "relay:read"
                | "relay:write"
                | "cache:read"
                | "cache:write"
                | "hotkey:forward"
                | "state:read"
                | "state:write"
                | "identity:read"
                | "keys:bind"
                | "keys:forward"
                | "media:control"
                | "notify:send"
                | "notify:channel"
                | "theme:read"
                | "config:read"
                | "resource:fetch"
                | "cvm:call"
                | "outbox:read"
                | "outbox:write"
                | "upload:write"
                | "intent:read"
                | "intent:write"
                | "dm:read"
                | "dm:write"
                | "fs:read"
                | "fs:write"
                | "llm:generate"
                | null,
            >,
        >;
        description?: string;
        domain: string;
        initialState: (rng: SeededRng, options: MockServiceOptions) => TState;
        kind: "service" | "extension";
        onCapabilityRevoked?: (
            windowId: string,
            capability: string | null,
            state: TState,
        ) => void;
        onRegistered?: (runtime: ServiceRuntimeContext, state: TState) => void;
        onUnregistered?: (state: TState) => void;
        onWindowDestroyed?: (windowId: string, state: TState) => void;
        pushes?: Readonly<
            Record<
                string,
                | "relay:read"
                | "relay:write"
                | "cache:read"
                | "cache:write"
                | "hotkey:forward"
                | "state:read"
                | "state:write"
                | "identity:read"
                | "keys:bind"
                | "keys:forward"
                | "media:control"
                | "notify:send"
                | "notify:channel"
                | "theme:read"
                | "config:read"
                | "resource:fetch"
                | "cvm:call"
                | "outbox:read"
                | "outbox:write"
                | "upload:write"
                | "intent:read"
                | "intent:write"
                | "dm:read"
                | "dm:write"
                | "fs:read"
                | "fs:write"
                | "llm:generate"
                | null,
            >,
        >;
        routes: Readonly<Record<string, MockRoute<TState>>>;
        version: string;
    }

    Type Parameters

    • TState
    Index

    Properties

    capabilities?: Readonly<
        Record<
            string,
            | "relay:read"
            | "relay:write"
            | "cache:read"
            | "cache:write"
            | "hotkey:forward"
            | "state:read"
            | "state:write"
            | "identity:read"
            | "keys:bind"
            | "keys:forward"
            | "media:control"
            | "notify:send"
            | "notify:channel"
            | "theme:read"
            | "config:read"
            | "resource:fetch"
            | "cvm:call"
            | "outbox:read"
            | "outbox:write"
            | "upload:write"
            | "intent:read"
            | "intent:write"
            | "dm:read"
            | "dm:write"
            | "fs:read"
            | "fs:write"
            | "llm:generate"
            | null,
        >,
    >

    Explicit capability requirements per message type.

    description?: string

    Descriptor description.

    domain: string

    Wire domain and descriptor name.

    initialState: (rng: SeededRng, options: MockServiceOptions) => TState

    Build the initial state (called on construction and on reset).

    kind: "service" | "extension"

    service for built-in runtime domains (no messageCapabilities emitted unless capabilities is given); extension for domains outside the built-in dispatcher (every route is published with null unless overridden by capabilities).

    onCapabilityRevoked?: (
        windowId: string,
        capability: string | null,
        state: TState,
    ) => void

    Hook run when a capability is revoked for a window.

    onRegistered?: (runtime: ServiceRuntimeContext, state: TState) => void

    Hook run once the runtime attaches the handler.

    onUnregistered?: (state: TState) => void

    Hook run when the runtime detaches the handler.

    onWindowDestroyed?: (windowId: string, state: TState) => void

    Extra per-window cleanup (state cleanup for the destroyed window).

    pushes?: Readonly<
        Record<
            string,
            | "relay:read"
            | "relay:write"
            | "cache:read"
            | "cache:write"
            | "hotkey:forward"
            | "state:read"
            | "state:write"
            | "identity:read"
            | "keys:bind"
            | "keys:forward"
            | "media:control"
            | "notify:send"
            | "notify:channel"
            | "theme:read"
            | "config:read"
            | "resource:fetch"
            | "cvm:call"
            | "outbox:read"
            | "outbox:write"
            | "upload:write"
            | "intent:read"
            | "intent:write"
            | "dm:read"
            | "dm:write"
            | "fs:read"
            | "fs:write"
            | "llm:generate"
            | null,
        >,
    >

    Shell -> napplet push types this mock emits outside a request, each mapped to the recipient capability or explicit null. Published as the handler's pushCapabilities, which is how ServiceRuntimeContext.sendToEligibleNapplet authorizes a push into a domain outside the built-in dispatcher. Built-in domains keep the runtime's own recipient mapping.

    routes: Readonly<Record<string, MockRoute<TState>>>

    Exact message type → handler.

    version: string

    Descriptor version.