> ## Documentation Index
> Fetch the complete documentation index at: https://iii.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Browser SDK

> API reference for the iii SDK for Browser / TypeScript.

{/* AI: any skill-check (vale/AI) text fixes belong in the source doc-comments under sdk/packages/node/iii-browser/src (prose) or docs/next/scripts/ (structure/formatting), then regenerate. Never edit this file directly. */}

## Installation

```bash theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
npm install iii-browser-sdk
```

## Initialization

### registerWorker

Register the worker with a iii instance, returns a connected worker client.
The WebSocket connection is established automatically.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
registerWorker(address: string, options?: InitOptions) => ISdk
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="address" type="string" required>
      WebSocket URL of the III engine (e.g. `ws://localhost:49135`).
    </ParamField>

    <ParamField body="options" type="InitOptions">
      Optional InitOptions for worker name, timeouts, and reconnection.

      <Expandable title="`InitOptions` fields">
        <ParamField body="headers" type="Record<string, string>">
          Browser WebSocket connections authenticate via query parameters or cookies; the `headers` option is ignored.
        </ParamField>

        <ParamField body="invocationTimeoutMs" type="number">
          Default timeout for `worker.trigger()` invocations in milliseconds. Defaults to `30000`.
        </ParamField>

        <ParamField body="reconnectionConfig" type="Partial<IIIReconnectionConfig>">
          WebSocket reconnection behavior.
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    import { registerWorker } from 'iii-browser-sdk'

    const worker = registerWorker('ws://localhost:49135')
    ```
  </Tab>
</Tabs>

## Methods

### registerTrigger

Registers a new trigger. A trigger is a way to invoke a function when a certain event occurs.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
registerTrigger(trigger: RegisterTriggerInput) => Trigger
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="trigger" type="RegisterTriggerInput" required>
      The trigger to register

      <Expandable title="`RegisterTriggerInput` fields" defaultOpen>
        <ParamField body="config" type="unknown" required>
          Trigger-type-specific configuration, matching the shape the trigger type expects.
        </ParamField>

        <ParamField body="function_id" type="string" required>
          ID of the function this trigger invokes when it fires.
        </ParamField>

        <ParamField body="type" type="string" required>
          Identifier of the registered trigger type this trigger uses (e.g. `storage::object-created`, `http`).
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    const trigger = worker.registerTrigger({
      type: 'cron',
      function_id: 'my-service::process-batch',
      config: { expression: '0 */5 * * * * *' },
    })

    // Later, remove the trigger
    trigger.unregister()
    ```
  </Tab>
</Tabs>

***

### registerFunction

Registers a new function with a local async handler that runs in the
browser session. HTTP invocation configs are a Node.js SDK feature.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
registerFunction(functionId: string, handler: RemoteFunctionHandler, options?: RegisterFunctionOptions) => FunctionRef
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="functionId" type="string" required>
      Unique function identifier
    </ParamField>

    <ParamField body="handler" type="RemoteFunctionHandler" required>
      Async handler executed when the function is invoked
    </ParamField>

    <ParamField body="options" type="RegisterFunctionOptions">
      Optional function registration options (description, request/response formats, metadata)

      <Expandable title="`RegisterFunctionOptions` fields">
        <ParamField body="description" type="string">
          The description of the function
        </ParamField>

        <ParamField body="metadata" type="Record<string, unknown>" />

        <ParamField body="request_format" type="RegisterFunctionFormat">
          The request format of the function
        </ParamField>

        <ParamField body="response_format" type="RegisterFunctionFormat">
          The response format of the function
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    // Local handler
    const ref = worker.registerFunction(
      'greet',
      async (data: { name: string }) => ({ message: `Hello, ${data.name}!` }),
      { description: 'Returns a greeting' },
    )

    // Later, remove the function
    ref.unregister()
    ```
  </Tab>
</Tabs>

***

### trigger

Invokes a function using a request object.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
trigger(request: TriggerRequest<TInput>) => Promise<TOutput>
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="request" type="TriggerRequest<TInput>" required>
      The trigger request containing function\_id, payload, and optional action/timeout

      <Expandable title="`TriggerRequest` fields" defaultOpen>
        <ParamField body="action" type="TriggerAction">
          Sets how the trigger is routed. Omit for a synchronous request/response. Specify for a specific routing scheme (e.g. `TriggerAction.Enqueue()`, `TriggerAction.Void()`).
        </ParamField>

        <ParamField body="function_id" type="string" required>
          ID of the function to invoke.
        </ParamField>

        <ParamField body="payload" type="TInput" required>
          Input data passed to the function.
        </ParamField>

        <ParamField body="timeoutMs" type="number">
          Override the default invocation timeout, in milliseconds.
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    // Synchronous invocation
    const result = await worker.trigger<{ name: string }, { message: string }>({
      function_id: 'greet',
      payload: { name: 'World' },
      timeoutMs: 5000,
    })
    console.log(result.message) // "Hello, World!"

    // Fire-and-forget
    await worker.trigger({
      function_id: 'send-email',
      payload: { to: 'user@example.com' },
      action: TriggerAction.Void(),
    })

    // Enqueue for async processing (the queue must be declared in the
    // iii-queue worker's queue_configs)
    const receipt = await worker.trigger({
      function_id: 'process-order',
      payload: { orderId: '123' },
      action: TriggerAction.Enqueue({ queue: 'orders' }),
    })
    ```
  </Tab>
</Tabs>

***

### registerTriggerType

Registers a new trigger type. A trigger type is a way to invoke a function when a certain event occurs.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
registerTriggerType(triggerType: RegisterTriggerTypeInput, handler: TriggerHandler<TConfig>) => TriggerTypeRef<TConfig>
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="triggerType" type="RegisterTriggerTypeInput" required>
      The trigger type to register

      <Expandable title="`RegisterTriggerTypeInput` fields">
        <ParamField body="description" type="string" required>
          Human-readable description of what this trigger type does.
        </ParamField>

        <ParamField body="id" type="string" required>
          Unique identifier for the trigger type (e.g. `state`, `durable:subscriber`).
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="handler" type="TriggerHandler<TConfig>" required>
      The handler for the trigger type

      <Expandable title="`TriggerHandler` fields">
        <ParamField body="registerTrigger" type="(config: TriggerConfig<TConfig>) => Promise<void>" required>
          Called when a trigger instance is registered.
        </ParamField>

        <ParamField body="unregisterTrigger" type="(config: TriggerConfig<TConfig>) => Promise<void>" required>
          Called when a trigger instance is unregistered.
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    type CronConfig = { expression: string }

    worker.registerTriggerType<CronConfig>(
      { id: 'cron', description: 'Fires on a cron schedule' },
      {
        async registerTrigger({ id, function_id, config }) {
          startCronJob(id, config.expression, () =>
            worker.trigger({ function_id, payload: {} }),
          )
        },
        async unregisterTrigger({ id }) {
          stopCronJob(id)
        },
      },
    )
    ```
  </Tab>
</Tabs>

***

### unregisterTriggerType

Unregisters a trigger type.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
unregisterTriggerType(triggerType: RegisterTriggerTypeInput) => void
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="triggerType" type="RegisterTriggerTypeInput" required>
      The trigger type to unregister

      <Expandable title="`RegisterTriggerTypeInput` fields">
        <ParamField body="description" type="string" required>
          Human-readable description of what this trigger type does.
        </ParamField>

        <ParamField body="id" type="string" required>
          Unique identifier for the trigger type (e.g. `state`, `durable:subscriber`).
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    worker.unregisterTriggerType({ id: 'cron', description: 'Fires on a cron schedule' })
    ```
  </Tab>
</Tabs>

***

### addConnectionStateListener

Subscribe to connection-state transitions. The handler is fired immediately
with the current state, then on every transition. Multiple listeners are
supported. Returns an unsubscribe function.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
addConnectionStateListener(handler: (state: IIIConnectionState) => void) => () => void
```

<Tabs>
  <Tab title="Parameters">
    <ParamField body="handler" type="(state: IIIConnectionState) => void" required>
      Callback invoked with the new connection state whenever it changes.
    </ParamField>
  </Tab>

  <Tab title="Example">
    ```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
    const unsub = worker.addConnectionStateListener((state) => {
      console.log('connection state:', state)
    })

    // Later, stop receiving updates
    unsub()
    ```
  </Tab>
</Tabs>

***

### shutdown

Gracefully shutdown the iii, cleaning up all resources.

**Signature**

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
shutdown() => Promise<void>
```

#### Example

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
await worker.shutdown()
```

## Subpath Exports

The `iii-browser-sdk` package provides additional entry points:

| Import path              | Contents                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `iii-browser-sdk`        | `ApiRequest`, `ApiResponse`, `AuthInput`, `AuthResult`, `Channel`, `ChannelReader`, `ChannelWriter`, `EngineFunctions`, `EngineTriggers`, `EnqueueResult`, `FunctionRef`, `IIIConnectionState`, `ISdk`, `InitOptions`, `MessageType`, `MiddlewareFunctionInput`, `OnFunctionRegistrationInput`, `OnFunctionRegistrationResult`, `OnTriggerRegistrationInput`, `OnTriggerRegistrationResult`, `OnTriggerTypeRegistrationInput`, `OnTriggerTypeRegistrationResult`, `RegisterFunctionInput`, `RegisterFunctionMessage`, `RegisterFunctionOptions`, `RegisterTriggerInput`, `RegisterTriggerMessage`, `RegisterTriggerTypeInput`, `RegisterTriggerTypeMessage`, `RemoteFunctionHandler`, `StreamChannelRef`, `Trigger`, `TriggerAction`, `TriggerConfig`, `TriggerHandler`, `TriggerRequest`, `TriggerTypeRef`, `registerWorker` |
| `iii-browser-sdk/state`  | `DeleteResult`, `IState`, `StateDeleteInput`, `StateDeleteResult`, `StateEventData`, `StateEventType`, `StateGetInput`, `StateListInput`, `StateSetInput`, `StateSetResult`, `StateUpdateInput`, `StateUpdateResult`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `iii-browser-sdk/stream` | `DeleteResult`, `IStream`, `MergePath`, `StreamAuthInput`, `StreamAuthResult`, `StreamChangeEvent`, `StreamContext`, `StreamDeleteInput`, `StreamGetInput`, `StreamJoinLeaveEvent`, `StreamJoinLeaveTriggerConfig`, `StreamJoinResult`, `StreamListGroupsInput`, `StreamListInput`, `StreamSetInput`, `StreamSetResult`, `StreamTriggerConfig`, `StreamUpdateInput`, `StreamUpdateResult`, `UpdateAppend`, `UpdateDecrement`, `UpdateIncrement`, `UpdateMerge`, `UpdateOp`, `UpdateOpError`, `UpdateRemove`, `UpdateSet`                                                                                                                                                                                                                                                                                                      |

## Types

### iii-browser-sdk

[`ApiRequest`](#apirequest) · [`ApiResponse`](#apiresponse) · [`AuthInput`](#authinput) · [`AuthResult`](#authresult) · [`Channel`](#channel) · [`ChannelReader`](#channelreader) · [`ChannelWriter`](#channelwriter) · [`EngineFunctions`](#enginefunctions) · [`EngineTriggers`](#enginetriggers) · [`EnqueueResult`](#enqueueresult) · [`FunctionRef`](#functionref) · [`IIIConnectionState`](#iiiconnectionstate) · [`InitOptions`](#initoptions) · [`MessageType`](#messagetype) · [`MiddlewareFunctionInput`](#middlewarefunctioninput) · [`OnFunctionRegistrationInput`](#onfunctionregistrationinput) · [`OnFunctionRegistrationResult`](#onfunctionregistrationresult) · [`OnTriggerRegistrationInput`](#ontriggerregistrationinput) · [`OnTriggerRegistrationResult`](#ontriggerregistrationresult) · [`OnTriggerTypeRegistrationInput`](#ontriggertyperegistrationinput) · [`OnTriggerTypeRegistrationResult`](#ontriggertyperegistrationresult) · [`RegisterFunctionInput`](#registerfunctioninput) · [`RegisterFunctionMessage`](#registerfunctionmessage) · [`RegisterFunctionOptions`](#registerfunctionoptions) · [`RegisterTriggerInput`](#registertriggerinput) · [`RegisterTriggerMessage`](#registertriggermessage) · [`RegisterTriggerTypeInput`](#registertriggertypeinput) · [`RegisterTriggerTypeMessage`](#registertriggertypemessage) · [`RemoteFunctionHandler`](#remotefunctionhandler) · [`StreamChannelRef`](#streamchannelref) · [`Trigger`](#trigger) · [`TriggerAction`](#triggeraction) · [`TriggerConfig`](#triggerconfig) · [`TriggerHandler`](#triggerhandler) · [`TriggerRequest`](#triggerrequest) · [`TriggerTypeRef`](#triggertyperef)

#### ApiRequest

Incoming HTTP request received by a function registered with an HTTP trigger.

| Name           | Type                                 | Required | Description |
| -------------- | ------------------------------------ | -------- | ----------- |
| `body`         | `TBody`                              | Yes      | -           |
| `headers`      | `Record<string, string \| string[]>` | Yes      | -           |
| `method`       | `string`                             | Yes      | -           |
| `path_params`  | `Record<string, string>`             | Yes      | -           |
| `query_params` | `Record<string, string \| string[]>` | Yes      | -           |

***

#### ApiResponse

Structured API response returned from HTTP function handlers.

| Name          | Type                     | Required | Description       |
| ------------- | ------------------------ | -------- | ----------------- |
| `body`        | `TBody`                  | No       | Response body.    |
| `headers`     | `Record<string, string>` | No       | Response headers. |
| `status_code` | `TStatus`                | Yes      | HTTP status code. |

***

#### AuthInput

Input passed to the RBAC auth function during WebSocket upgrade.
Contains the HTTP headers, query parameters, and client IP from the
connecting worker's upgrade request.

| Name           | Type                       | Required | Description                                                                                          |
| -------------- | -------------------------- | -------- | ---------------------------------------------------------------------------------------------------- |
| `headers`      | `Record<string, string>`   | Yes      | HTTP headers from the WebSocket upgrade request.                                                     |
| `ip_address`   | `string`                   | Yes      | IP address of the connecting client.                                                                 |
| `query_params` | `Record<string, string[]>` | Yes      | Query parameters from the upgrade URL. Each key maps to an array of values to support repeated keys. |

***

#### AuthResult

Return value from the RBAC auth function. Controls which functions the
authenticated worker can invoke and what context is forwarded to the
middleware.

| Name                              | Type                      | Required | Description                                                                                                             |
| --------------------------------- | ------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `allow_function_registration`     | `boolean`                 | No       | Whether the worker may register new functions. Defaults to `true` if omitted.                                           |
| `allow_trigger_type_registration` | `boolean`                 | No       | Whether the worker may register new trigger types. Defaults to `false` if omitted.                                      |
| `allowed_functions`               | `string[]`                | No       | Additional function IDs to allow beyond the `expose_functions` config. Defaults to `[]` if omitted.                     |
| `allowed_trigger_types`           | `string[]`                | No       | Trigger type IDs the worker may register triggers for. When omitted, all types are allowed.                             |
| `context`                         | `Record<string, unknown>` | No       | Arbitrary context forwarded to the middleware function on every invocation. Defaults to `{}` if omitted.                |
| `forbidden_functions`             | `string[]`                | No       | Function IDs to deny even if they match `expose_functions`. Takes precedence over allowed. Defaults to `[]` if omitted. |
| `function_registration_prefix`    | `string`                  | No       | Optional prefix applied to all function IDs registered by this worker.                                                  |

***

#### Channel

A streaming channel pair for worker-to-worker data transfer. Created via
the `createChannel` helper from `iii-browser-sdk/helpers`.

| Name        | Type                                    | Required | Description                                                          |
| ----------- | --------------------------------------- | -------- | -------------------------------------------------------------------- |
| `reader`    | [`ChannelReader`](#channelreader)       | Yes      | Reader end of the channel.                                           |
| `readerRef` | [`StreamChannelRef`](#streamchannelref) | Yes      | Serializable reference to the reader (can be sent to other workers). |
| `writer`    | [`ChannelWriter`](#channelwriter)       | Yes      | Writer end of the channel.                                           |
| `writerRef` | [`StreamChannelRef`](#streamchannelref) | Yes      | Serializable reference to the writer (can be sent to other workers). |

***

#### ChannelReader

Read end of a streaming channel. Uses native browser WebSocket.

***

#### ChannelWriter

Write end of a streaming channel. Uses native browser WebSocket.

***

#### EngineFunctions

Engine function paths for internal operations.

Naming note: `LIST_TRIGGERS` / `INFO_TRIGGERS` cover trigger TYPES
(templates). `LIST_REGISTERED_TRIGGERS` / `INFO_REGISTERED_TRIGGERS`
cover trigger INSTANCES (subscriber rows). The old
`engine::trigger-types::list` builtin has been removed and is now
served by `engine::triggers::list`.

| Name                       | Type                                  | Required | Description |
| -------------------------- | ------------------------------------- | -------- | ----------- |
| `INFO_FUNCTIONS`           | `"engine::functions::info"`           | Yes      | -           |
| `INFO_REGISTERED_TRIGGERS` | `"engine::registered-triggers::info"` | Yes      | -           |
| `INFO_TRIGGERS`            | `"engine::triggers::info"`            | Yes      | -           |
| `INFO_WORKERS`             | `"engine::workers::info"`             | Yes      | -           |
| `LIST_FUNCTIONS`           | `"engine::functions::list"`           | Yes      | -           |
| `LIST_REGISTERED_TRIGGERS` | `"engine::registered-triggers::list"` | Yes      | -           |
| `LIST_TRIGGERS`            | `"engine::triggers::list"`            | Yes      | -           |
| `LIST_WORKERS`             | `"engine::workers::list"`             | Yes      | -           |
| `REGISTER_WORKER`          | `"engine::workers::register"`         | Yes      | -           |

***

#### EngineTriggers

Engine trigger types

| Name                  | Type                            | Required | Description |
| --------------------- | ------------------------------- | -------- | ----------- |
| `FUNCTIONS_AVAILABLE` | `"engine::functions-available"` | Yes      | -           |

***

#### EnqueueResult

Result returned when a function is invoked with `TriggerAction.Enqueue`.

| Name               | Type     | Required | Description                                 |
| ------------------ | -------- | -------- | ------------------------------------------- |
| `messageReceiptId` | `string` | Yes      | Unique receipt ID for the enqueued message. |

***

#### FunctionRef

Handle returned by ISdk.registerFunction. Contains the function's
`id` and an `unregister()` method.

| Name         | Type         | Required | Description                            |
| ------------ | ------------ | -------- | -------------------------------------- |
| `id`         | `string`     | Yes      | The unique function identifier.        |
| `unregister` | `() => void` | Yes      | Removes this function from the engine. |

***

#### IIIConnectionState

Connection state for the III WebSocket

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type IIIConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting" | "failed"
```

***

#### InitOptions

Configuration options passed to registerWorker.

| Name                  | Type                             | Required | Description                                                                                                  |
| --------------------- | -------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| `headers`             | `Record<string, string>`         | No       | Browser WebSocket connections authenticate via query parameters or cookies; the `headers` option is ignored. |
| `invocationTimeoutMs` | `number`                         | No       | Default timeout for `worker.trigger()` invocations in milliseconds. Defaults to `30000`.                     |
| `reconnectionConfig`  | `Partial<IIIReconnectionConfig>` | No       | WebSocket reconnection behavior.                                                                             |

***

#### MessageType

| Name                        | Type                          | Required | Description |
| --------------------------- | ----------------------------- | -------- | ----------- |
| `InvocationResult`          | `"invocationresult"`          | Yes      | -           |
| `InvokeFunction`            | `"invokefunction"`            | Yes      | -           |
| `RegisterFunction`          | `"registerfunction"`          | Yes      | -           |
| `RegisterTrigger`           | `"registertrigger"`           | Yes      | -           |
| `RegisterTriggerType`       | `"registertriggertype"`       | Yes      | -           |
| `TriggerRegistrationResult` | `"triggerregistrationresult"` | Yes      | -           |
| `UnregisterFunction`        | `"unregisterfunction"`        | Yes      | -           |
| `UnregisterTrigger`         | `"unregistertrigger"`         | Yes      | -           |
| `UnregisterTriggerType`     | `"unregistertriggertype"`     | Yes      | -           |
| `WorkerRegistered`          | `"workerregistered"`          | Yes      | -           |

***

#### MiddlewareFunctionInput

Input passed to the RBAC middleware function on every function invocation
through the RBAC port. The middleware can inspect, modify, or reject the
call before it reaches the target function.

| Name          | Type                              | Required | Description                                                  |
| ------------- | --------------------------------- | -------- | ------------------------------------------------------------ |
| `action`      | [`TriggerAction`](#triggeraction) | No       | Routing action, if any.                                      |
| `context`     | `Record<string, unknown>`         | Yes      | Auth context returned by the auth function for this session. |
| `function_id` | `string`                          | Yes      | ID of the function being invoked.                            |
| `payload`     | `Record<string, unknown>`         | Yes      | Payload sent by the caller.                                  |

***

#### OnFunctionRegistrationInput

Input passed to the `on_function_registration_function_id` hook
when a worker attempts to register a function through the RBAC port.
Return an OnFunctionRegistrationResult with the (possibly mapped)
fields, or throw to deny the registration.

| Name          | Type                      | Required | Description                                              |
| ------------- | ------------------------- | -------- | -------------------------------------------------------- |
| `context`     | `Record<string, unknown>` | Yes      | Auth context from `AuthResult.context` for this session. |
| `description` | `string`                  | No       | Human-readable description of the function.              |
| `function_id` | `string`                  | Yes      | ID of the function being registered.                     |
| `metadata`    | `Record<string, unknown>` | No       | Arbitrary metadata attached to the function.             |

***

#### OnFunctionRegistrationResult

Result returned from the `on_function_registration_function_id` hook.
All fields are optional; omitted fields keep the original value from the
registration request.

| Name          | Type                      | Required | Description         |
| ------------- | ------------------------- | -------- | ------------------- |
| `description` | `string`                  | No       | Mapped description. |
| `function_id` | `string`                  | No       | Mapped function ID. |
| `metadata`    | `Record<string, unknown>` | No       | Mapped metadata.    |

***

#### OnTriggerRegistrationInput

Input passed to the `on_trigger_registration_function_id` hook
when a worker attempts to register a trigger through the RBAC port.
Return an OnTriggerRegistrationResult with the (possibly mapped)
fields, or throw to deny the registration.

| Name           | Type                      | Required | Description                                              |
| -------------- | ------------------------- | -------- | -------------------------------------------------------- |
| `config`       | `unknown`                 | Yes      | Trigger-specific configuration.                          |
| `context`      | `Record<string, unknown>` | Yes      | Auth context from `AuthResult.context` for this session. |
| `function_id`  | `string`                  | Yes      | ID of the function this trigger is bound to.             |
| `trigger_id`   | `string`                  | Yes      | ID of the trigger being registered.                      |
| `trigger_type` | `string`                  | Yes      | Trigger type identifier.                                 |

***

#### OnTriggerRegistrationResult

Result returned from the `on_trigger_registration_function_id` hook.
All fields are optional; omitted fields keep the original value from the
registration request.

| Name           | Type      | Required | Description                   |
| -------------- | --------- | -------- | ----------------------------- |
| `config`       | `unknown` | No       | Mapped trigger configuration. |
| `function_id`  | `string`  | No       | Mapped function ID.           |
| `trigger_id`   | `string`  | No       | Mapped trigger ID.            |
| `trigger_type` | `string`  | No       | Mapped trigger type.          |

***

#### OnTriggerTypeRegistrationInput

Input passed to the `on_trigger_type_registration_function_id` hook
when a worker attempts to register a new trigger type through the RBAC port.
Return an OnTriggerTypeRegistrationResult with the (possibly mapped)
fields, or throw to deny the registration.

| Name              | Type                      | Required | Description                                              |
| ----------------- | ------------------------- | -------- | -------------------------------------------------------- |
| `context`         | `Record<string, unknown>` | Yes      | Auth context from `AuthResult.context` for this session. |
| `description`     | `string`                  | Yes      | Human-readable description of the trigger type.          |
| `trigger_type_id` | `string`                  | Yes      | ID of the trigger type being registered.                 |

***

#### OnTriggerTypeRegistrationResult

Result returned from the `on_trigger_type_registration_function_id` hook.
All fields are optional; omitted fields keep the original value from the
registration request.

| Name              | Type     | Required | Description             |
| ----------------- | -------- | -------- | ----------------------- |
| `description`     | `string` | No       | Mapped description.     |
| `trigger_type_id` | `string` | No       | Mapped trigger type ID. |

***

#### RegisterFunctionInput

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type RegisterFunctionInput = Omit<RegisterFunctionMessage, "message_type">
```

| Name              | Type                      | Required | Description                                                                  |
| ----------------- | ------------------------- | -------- | ---------------------------------------------------------------------------- |
| `description`     | `string`                  | No       | The description of the function                                              |
| `id`              | `string`                  | Yes      | The path of the function (use :: for namespacing, e.g. external::my\_lambda) |
| `metadata`        | `Record<string, unknown>` | No       | -                                                                            |
| `request_format`  | `RegisterFunctionFormat`  | No       | The request format of the function                                           |
| `response_format` | `RegisterFunctionFormat`  | No       | The response format of the function                                          |

***

#### RegisterFunctionMessage

| Name              | Type                                           | Required | Description                                                                  |
| ----------------- | ---------------------------------------------- | -------- | ---------------------------------------------------------------------------- |
| `description`     | `string`                                       | No       | The description of the function                                              |
| `id`              | `string`                                       | Yes      | The path of the function (use :: for namespacing, e.g. external::my\_lambda) |
| `message_type`    | [`MessageType`](#messagetype).RegisterFunction | Yes      | -                                                                            |
| `metadata`        | `Record<string, unknown>`                      | No       | -                                                                            |
| `request_format`  | `RegisterFunctionFormat`                       | No       | The request format of the function                                           |
| `response_format` | `RegisterFunctionFormat`                       | No       | The response format of the function                                          |

***

#### RegisterFunctionOptions

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type RegisterFunctionOptions = Omit<RegisterFunctionMessage, "message_type" | "id">
```

| Name              | Type                      | Required | Description                         |
| ----------------- | ------------------------- | -------- | ----------------------------------- |
| `description`     | `string`                  | No       | The description of the function     |
| `metadata`        | `Record<string, unknown>` | No       | -                                   |
| `request_format`  | `RegisterFunctionFormat`  | No       | The request format of the function  |
| `response_format` | `RegisterFunctionFormat`  | No       | The response format of the function |

***

#### RegisterTriggerInput

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type RegisterTriggerInput = Omit<RegisterTriggerMessage, "message_type" | "id">
```

| Name          | Type      | Required | Description                                                                                           |
| ------------- | --------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `config`      | `unknown` | Yes      | Trigger-type-specific configuration, matching the shape the trigger type expects.                     |
| `function_id` | `string`  | Yes      | ID of the function this trigger invokes when it fires.                                                |
| `type`        | `string`  | Yes      | Identifier of the registered trigger type this trigger uses (e.g. `storage::object-created`, `http`). |

***

#### RegisterTriggerMessage

| Name           | Type                                          | Required | Description                                                                                           |
| -------------- | --------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `config`       | `unknown`                                     | Yes      | Trigger-type-specific configuration, matching the shape the trigger type expects.                     |
| `function_id`  | `string`                                      | Yes      | ID of the function this trigger invokes when it fires.                                                |
| `id`           | `string`                                      | Yes      | Unique trigger identifier, generated by the SDK during registration.                                  |
| `message_type` | [`MessageType`](#messagetype).RegisterTrigger | Yes      | Wire discriminator; always `MessageType.RegisterTrigger`.                                             |
| `type`         | `string`                                      | Yes      | Identifier of the registered trigger type this trigger uses (e.g. `storage::object-created`, `http`). |

***

#### RegisterTriggerTypeInput

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type RegisterTriggerTypeInput = Omit<RegisterTriggerTypeMessage, "message_type">
```

| Name          | Type     | Required | Description                                                                  |
| ------------- | -------- | -------- | ---------------------------------------------------------------------------- |
| `description` | `string` | Yes      | Human-readable description of what this trigger type does.                   |
| `id`          | `string` | Yes      | Unique identifier for the trigger type (e.g. `state`, `durable:subscriber`). |

***

#### RegisterTriggerTypeMessage

| Name           | Type                                              | Required | Description                                                                  |
| -------------- | ------------------------------------------------- | -------- | ---------------------------------------------------------------------------- |
| `description`  | `string`                                          | Yes      | Human-readable description of what this trigger type does.                   |
| `id`           | `string`                                          | Yes      | Unique identifier for the trigger type (e.g. `state`, `durable:subscriber`). |
| `message_type` | [`MessageType`](#messagetype).RegisterTriggerType | Yes      | -                                                                            |

***

#### RemoteFunctionHandler

Async function handler for a registered function. Receives the invocation
payload and returns the result.

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type RemoteFunctionHandler = (data: TInput) => Promise<TOutput>
```

***

#### StreamChannelRef

Serializable reference to one end of a streaming channel. Can be included
in invocation payloads to pass channel endpoints between workers.

| Name         | Type                | Required | Description                                 |
| ------------ | ------------------- | -------- | ------------------------------------------- |
| `access_key` | `string`            | Yes      | Access key for authentication.              |
| `channel_id` | `string`            | Yes      | Unique channel identifier.                  |
| `direction`  | `"read" \| "write"` | Yes      | Whether this ref is for reading or writing. |

***

#### Trigger

Handle returned by ISdk.registerTrigger. Use `unregister()` to
remove the trigger from the engine.

| Name         | Type         | Required | Description                           |
| ------------ | ------------ | -------- | ------------------------------------- |
| `unregister` | `() => void` | Yes      | Removes this trigger from the engine. |

***

#### TriggerAction

Factory object that constructs routing actions for ISdk.trigger.

| Name      | Type                                                              | Required | Description                                                                                                                                                               |
| --------- | ----------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Enqueue` | `(opts: { queue: string }) => { queue: string; type: "enqueue" }` | Yes      | Routes the invocation through a named queue. The engine enqueues the job,<br />acknowledges the caller with `{ messageReceiptId }`, and processes it<br />asynchronously. |
| `Void`    | `() => { type: "void" }`                                          | Yes      | Fire-and-forget routing. The engine forwards the invocation without<br />waiting for a response or queuing the job.                                                       |

***

#### TriggerConfig

Configuration passed to a trigger handler when a trigger instance is
registered or unregistered.

| Name          | Type      | Required | Description                                |
| ------------- | --------- | -------- | ------------------------------------------ |
| `config`      | `TConfig` | Yes      | Trigger-specific configuration.            |
| `function_id` | `string`  | Yes      | Function to invoke when the trigger fires. |
| `id`          | `string`  | Yes      | Trigger instance ID.                       |

***

#### TriggerHandler

Handler interface for custom trigger types. Passed to
`ISdk.registerTriggerType`.

| Name                | Type                                                                    | Required | Description                                     |
| ------------------- | ----------------------------------------------------------------------- | -------- | ----------------------------------------------- |
| `registerTrigger`   | (config: [`TriggerConfig`](#triggerconfig)\<TConfig>) => Promise\<void> | Yes      | Called when a trigger instance is registered.   |
| `unregisterTrigger` | (config: [`TriggerConfig`](#triggerconfig)\<TConfig>) => Promise\<void> | Yes      | Called when a trigger instance is unregistered. |

***

#### TriggerRequest

Request object passed to ISdk.trigger.

| Name          | Type                              | Required | Description                                                                                                                                                              |
| ------------- | --------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `action`      | [`TriggerAction`](#triggeraction) | No       | Sets how the trigger is routed. Omit for a synchronous request/response. Specify for a specific routing scheme (e.g. `TriggerAction.Enqueue()`, `TriggerAction.Void()`). |
| `function_id` | `string`                          | Yes      | ID of the function to invoke.                                                                                                                                            |
| `payload`     | `TInput`                          | Yes      | Input data passed to the function.                                                                                                                                       |
| `timeoutMs`   | `number`                          | No       | Override the default invocation timeout, in milliseconds.                                                                                                                |

***

#### TriggerTypeRef

Typed handle returned by ISdk.registerTriggerType.

Provides convenience methods to register triggers and functions scoped
to this trigger type, so callers don't need to repeat the `type` field.

| Name               | Type                                                                                                                               | Required | Description                                                       |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------- |
| `id`               | `string`                                                                                                                           | Yes      | The trigger type identifier.                                      |
| `registerFunction` | (functionId: string, handler: [`RemoteFunctionHandler`](#remotefunctionhandler), config: TConfig) => [`FunctionRef`](#functionref) | Yes      | Register a function and immediately bind it to this trigger type. |
| `registerTrigger`  | (functionId: string, config: TConfig) => [`Trigger`](#trigger)                                                                     | Yes      | Register a trigger bound to this trigger type.                    |
| `unregister`       | `() => void`                                                                                                                       | Yes      | Unregister this trigger type from the engine.                     |

### iii-browser-sdk/state

[`DeleteResult`](#deleteresult) · [`IState`](#istate) · [`StateDeleteInput`](#statedeleteinput) · [`StateDeleteResult`](#statedeleteresult) · [`StateEventData`](#stateeventdata) · [`StateEventType`](#stateeventtype) · [`StateGetInput`](#stategetinput) · [`StateListInput`](#statelistinput) · [`StateSetInput`](#statesetinput) · [`StateSetResult`](#statesetresult) · [`StateUpdateInput`](#stateupdateinput) · [`StateUpdateResult`](#stateupdateresult)

#### DeleteResult

Result of a state delete operation.

| Name        | Type  | Required | Description                     |
| ----------- | ----- | -------- | ------------------------------- |
| `old_value` | `any` | No       | Previous value (if it existed). |

***

#### IState

Interface for state management operations. Available via the `iii-browser-sdk/state`
subpath export.

| Name     | Type                                                                                                                    | Required | Description                                      |
| -------- | ----------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------ |
| `delete` | (input: [`StateDeleteInput`](#statedeleteinput)) => Promise\<[`DeleteResult`](#deleteresult)>                           | Yes      | Delete a state value.                            |
| `get`    | (input: [`StateGetInput`](#stategetinput)) => Promise\<TData \| null>                                                   | Yes      | Retrieve a value by scope and key.               |
| `list`   | (input: [`StateListInput`](#statelistinput)) => Promise\<TData\[]>                                                      | Yes      | List all values in a scope.                      |
| `set`    | (input: [`StateSetInput`](#statesetinput)) => Promise\<[`StateSetResult`](#statesetresult)\<TData> \| null>             | Yes      | Set (create or overwrite) a state value.         |
| `update` | (input: [`StateUpdateInput`](#stateupdateinput)) => Promise\<[`StateUpdateResult`](#stateupdateresult)\<TData> \| null> | Yes      | Apply atomic update operations to a state value. |

***

#### StateDeleteInput

Input for deleting a state value.

| Name    | Type     | Required | Description              |
| ------- | -------- | -------- | ------------------------ |
| `key`   | `string` | Yes      | Key within the scope.    |
| `scope` | `string` | Yes      | State scope (namespace). |

***

#### StateDeleteResult

Result of a state delete operation.

| Name        | Type  | Required | Description                     |
| ----------- | ----- | -------- | ------------------------------- |
| `old_value` | `any` | No       | Previous value (if it existed). |

***

#### StateEventData

Payload for state change events.

| Name         | Type                                | Required | Description                                |
| ------------ | ----------------------------------- | -------- | ------------------------------------------ |
| `event_type` | [`StateEventType`](#stateeventtype) | Yes      | Type of state change.                      |
| `key`        | `string`                            | Yes      | Key within the scope.                      |
| `new_value`  | `TData`                             | No       | New value (for create/update events).      |
| `old_value`  | `TData`                             | No       | Previous value (for update/delete events). |
| `scope`      | `string`                            | Yes      | State scope (namespace).                   |
| `type`       | `"state"`                           | Yes      | -                                          |

***

#### StateEventType

Types of state change events.

| Name      | Type              | Required | Description |
| --------- | ----------------- | -------- | ----------- |
| `Created` | `"state:created"` | Yes      | -           |
| `Deleted` | `"state:deleted"` | Yes      | -           |
| `Updated` | `"state:updated"` | Yes      | -           |

***

#### StateGetInput

Input for retrieving a state value.

| Name    | Type     | Required | Description              |
| ------- | -------- | -------- | ------------------------ |
| `key`   | `string` | Yes      | Key within the scope.    |
| `scope` | `string` | Yes      | State scope (namespace). |

***

#### StateListInput

Input for listing all values in a state scope.

| Name    | Type     | Required | Description              |
| ------- | -------- | -------- | ------------------------ |
| `scope` | `string` | Yes      | State scope (namespace). |

***

#### StateSetInput

Input for setting a state value.

| Name    | Type     | Required | Description              |
| ------- | -------- | -------- | ------------------------ |
| `key`   | `string` | Yes      | Key within the scope.    |
| `scope` | `string` | Yes      | State scope (namespace). |
| `value` | `any`    | Yes      | Value to store.          |

***

#### StateSetResult

Result of a state set operation.

| Name        | Type    | Required | Description                     |
| ----------- | ------- | -------- | ------------------------------- |
| `new_value` | `TData` | Yes      | New value that was stored.      |
| `old_value` | `TData` | No       | Previous value (if it existed). |

***

#### StateUpdateInput

Input for atomically updating a state value.

| Name    | Type                       | Required | Description                                            |
| ------- | -------------------------- | -------- | ------------------------------------------------------ |
| `key`   | `string`                   | Yes      | Key within the scope.                                  |
| `ops`   | [`UpdateOp`](#updateop)\[] | Yes      | Ordered list of update operations to apply atomically. |
| `scope` | `string`                   | Yes      | State scope (namespace).                               |

***

#### StateUpdateResult

Result of a state update operation.

| Name        | Type                                 | Required | Description                                                                                                                   |
| ----------- | ------------------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `errors`    | [`UpdateOpError`](#updateoperror)\[] | No       | Per-op errors. Currently emitted only by the `merge` op when<br />input violates validation bounds. Field omitted when empty. |
| `new_value` | `TData`                              | Yes      | New value after the update.                                                                                                   |
| `old_value` | `TData`                              | No       | Previous value (if it existed).                                                                                               |

### iii-browser-sdk/stream

[`IStream`](#istream) · [`MergePath`](#mergepath) · [`StreamAuthInput`](#streamauthinput) · [`StreamAuthResult`](#streamauthresult) · [`StreamChangeEvent`](#streamchangeevent) · [`StreamContext`](#streamcontext) · [`StreamDeleteInput`](#streamdeleteinput) · [`StreamGetInput`](#streamgetinput) · [`StreamJoinLeaveEvent`](#streamjoinleaveevent) · [`StreamJoinLeaveTriggerConfig`](#streamjoinleavetriggerconfig) · [`StreamJoinResult`](#streamjoinresult) · [`StreamListGroupsInput`](#streamlistgroupsinput) · [`StreamListInput`](#streamlistinput) · [`StreamSetInput`](#streamsetinput) · [`StreamSetResult`](#streamsetresult) · [`StreamTriggerConfig`](#streamtriggerconfig) · [`StreamUpdateInput`](#streamupdateinput) · [`StreamUpdateResult`](#streamupdateresult) · [`UpdateAppend`](#updateappend) · [`UpdateDecrement`](#updatedecrement) · [`UpdateIncrement`](#updateincrement) · [`UpdateMerge`](#updatemerge) · [`UpdateOp`](#updateop) · [`UpdateOpError`](#updateoperror) · [`UpdateRemove`](#updateremove) · [`UpdateSet`](#updateset)

#### IStream

Interface for custom stream implementations. Passed to `ISdk.createStream`
to override the engine's built-in stream storage.

| Name         | Type                                                                                                                        | Required | Description                                      |
| ------------ | --------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------ |
| `delete`     | (input: [`StreamDeleteInput`](#streamdeleteinput)) => Promise\<[`DeleteResult`](#deleteresult)>                             | Yes      | Delete a stream item.                            |
| `get`        | (input: [`StreamGetInput`](#streamgetinput)) => Promise\<TData \| null>                                                     | Yes      | Retrieve a single item by group and item ID.     |
| `list`       | (input: [`StreamListInput`](#streamlistinput)) => Promise\<TData\[]>                                                        | Yes      | List all items in a group.                       |
| `listGroups` | (input: [`StreamListGroupsInput`](#streamlistgroupsinput)) => Promise\<string\[]>                                           | Yes      | List all group IDs in a stream.                  |
| `set`        | (input: [`StreamSetInput`](#streamsetinput)) => Promise\<[`StreamSetResult`](#streamsetresult)\<TData> \| null>             | Yes      | Set (create or overwrite) a stream item.         |
| `update`     | (input: [`StreamUpdateInput`](#streamupdateinput)) => Promise\<[`StreamUpdateResult`](#streamupdateresult)\<TData> \| null> | Yes      | Apply atomic update operations to a stream item. |

***

#### MergePath

Path target for a UpdateMerge op. Accepts:

* a single string (legacy / first-level field)
* an array of literal segments (nested path; each element is one
  literal key, dots are NOT interpreted as separators)

Omit `path`, pass `""`, or pass `[]` to target the root value.

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type MergePath = string | string[]
```

***

#### StreamAuthInput

Input for stream authentication.

| Name           | Type                       | Required | Description       |
| -------------- | -------------------------- | -------- | ----------------- |
| `addr`         | `string`                   | Yes      | Client address.   |
| `headers`      | `Record<string, string>`   | Yes      | Request headers.  |
| `path`         | `string`                   | Yes      | Request path.     |
| `query_params` | `Record<string, string[]>` | Yes      | Query parameters. |

***

#### StreamAuthResult

Result of stream authentication.

| Name      | Type  | Required | Description                                                       |
| --------- | ----- | -------- | ----------------------------------------------------------------- |
| `context` | `any` | No       | Arbitrary context passed to stream handlers after authentication. |

***

#### StreamChangeEvent

Handler input for `stream` triggers, fired when an item changes via `stream::set`, `stream::update`, or `stream::delete`.

| Name         | Type                                                    | Required | Description                                                  |
| ------------ | ------------------------------------------------------- | -------- | ------------------------------------------------------------ |
| `event`      | `{ data: any; type: "create" \| "update" \| "delete" }` | Yes      | The event detail object containing `type` and `data` fields. |
| `groupId`    | `string`                                                | Yes      | The group where the change occurred.                         |
| `id`         | `string`                                                | No       | The item ID that changed.                                    |
| `streamName` | `string`                                                | Yes      | The stream where the change occurred.                        |
| `timestamp`  | `number`                                                | Yes      | Unix timestamp of the event.                                 |
| `type`       | `"stream"`                                              | Yes      | The event type.                                              |

***

#### StreamContext

Context type extracted from StreamAuthResult.

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type StreamContext = StreamAuthResult["context"]
```

***

#### StreamDeleteInput

Input for deleting a stream item.

| Name          | Type     | Required | Description         |
| ------------- | -------- | -------- | ------------------- |
| `group_id`    | `string` | Yes      | Group identifier.   |
| `item_id`     | `string` | Yes      | Item identifier.    |
| `stream_name` | `string` | Yes      | Name of the stream. |

***

#### StreamGetInput

Input for retrieving a single stream item.

| Name          | Type     | Required | Description         |
| ------------- | -------- | -------- | ------------------- |
| `group_id`    | `string` | Yes      | Group identifier.   |
| `item_id`     | `string` | Yes      | Item identifier.    |
| `stream_name` | `string` | Yes      | Name of the stream. |

***

#### StreamJoinLeaveEvent

Event payload for stream join/leave events.

| Name              | Type     | Required | Description                         |
| ----------------- | -------- | -------- | ----------------------------------- |
| `context`         | `any`    | No       | Auth context from StreamAuthResult. |
| `group_id`        | `string` | Yes      | Group identifier.                   |
| `id`              | `string` | No       | Item identifier (if applicable).    |
| `stream_name`     | `string` | Yes      | Name of the stream.                 |
| `subscription_id` | `string` | Yes      | Unique subscription identifier.     |

***

#### StreamJoinLeaveTriggerConfig

Trigger config for `stream:join` and `stream:leave` triggers.

| Name                    | Type     | Required | Description                                                                           |
| ----------------------- | -------- | -------- | ------------------------------------------------------------------------------------- |
| `condition_function_id` | `string` | No       | Function ID for conditional execution. If it returns `false`, the handler is skipped. |

***

#### StreamJoinResult

Result of a stream join request.

| Name           | Type      | Required | Description                        |
| -------------- | --------- | -------- | ---------------------------------- |
| `unauthorized` | `boolean` | Yes      | Whether the join was unauthorized. |

***

#### StreamListGroupsInput

Input for listing all groups in a stream.

| Name          | Type     | Required | Description         |
| ------------- | -------- | -------- | ------------------- |
| `stream_name` | `string` | Yes      | Name of the stream. |

***

#### StreamListInput

Input for listing all items in a stream group.

| Name          | Type     | Required | Description         |
| ------------- | -------- | -------- | ------------------- |
| `group_id`    | `string` | Yes      | Group identifier.   |
| `stream_name` | `string` | Yes      | Name of the stream. |

***

#### StreamSetInput

Input for setting a stream item.

| Name          | Type     | Required | Description         |
| ------------- | -------- | -------- | ------------------- |
| `data`        | `any`    | Yes      | Data to store.      |
| `group_id`    | `string` | Yes      | Group identifier.   |
| `item_id`     | `string` | Yes      | Item identifier.    |
| `stream_name` | `string` | Yes      | Name of the stream. |

***

#### StreamSetResult

Result of a stream set operation.

| Name        | Type    | Required | Description                     |
| ----------- | ------- | -------- | ------------------------------- |
| `new_value` | `TData` | Yes      | New value that was stored.      |
| `old_value` | `TData` | No       | Previous value (if it existed). |

***

#### StreamTriggerConfig

Trigger config for `stream` triggers. Filters which item changes fire the handler.

| Name                    | Type     | Required | Description                                                                           |
| ----------------------- | -------- | -------- | ------------------------------------------------------------------------------------- |
| `condition_function_id` | `string` | No       | Function ID for conditional execution. If it returns `false`, the handler is skipped. |
| `group_id`              | `string` | No       | If set, only changes within this group fire the handler.                              |
| `item_id`               | `string` | No       | If set, only changes to this specific item fire the handler.                          |
| `stream_name`           | `string` | Yes      | Stream name to watch. Only changes on this stream fire the handler.                   |

***

#### StreamUpdateInput

Input for atomically updating a stream item.

| Name          | Type                       | Required | Description                                            |
| ------------- | -------------------------- | -------- | ------------------------------------------------------ |
| `group_id`    | `string`                   | Yes      | Group identifier.                                      |
| `item_id`     | `string`                   | Yes      | Item identifier.                                       |
| `ops`         | [`UpdateOp`](#updateop)\[] | Yes      | Ordered list of update operations to apply atomically. |
| `stream_name` | `string`                   | Yes      | Name of the stream.                                    |

***

#### StreamUpdateResult

Result of a stream update operation.

| Name        | Type                                 | Required | Description                                                                                                                                                                                                                                             |
| ----------- | ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `errors`    | [`UpdateOpError`](#updateoperror)\[] | No       | Per-op errors. Emitted by `merge` and `append` for validation<br />rejections (path/value bounds, proto-pollution segments) and by<br />`append` for the `append.type_mismatch` and<br />`append.target_not_object` surfaces. Field omitted when empty. |
| `new_value` | `TData`                              | Yes      | New value after the update.                                                                                                                                                                                                                             |
| `old_value` | `TData`                              | No       | Previous value (if it existed).                                                                                                                                                                                                                         |

***

#### UpdateAppend

Append an element to an array, concatenate a string, or push a new
value at a nested path. The target is the root (when `path` is
omitted, empty, or `[]`), a single first-level key (when `path` is
a non-empty string), or an arbitrary nested location (when `path`
is an array of literal segments). See MergePath.

Engine semantics: missing/null intermediates along a nested path are
auto-created; missing leaves on a nested path always become arrays
(no string-concat tier); existing object/scalar leaves return
`append.type_mismatch`. Each path segment is a literal key,
`["a.b"]` targets a single key named `"a.b"`, not `a → b`.

| Name    | Type                      | Required | Description                                                                                                                                                                                   |
| ------- | ------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `path`  | [`MergePath`](#mergepath) | No       | Optional path to the append target. Accepts a single first-level<br />key (legacy `string`) or an array of literal segments for nested<br />append. See MergePath (the same shape is reused). |
| `type`  | `"append"`                | Yes      | -                                                                                                                                                                                             |
| `value` | `any`                     | Yes      | Value to append. String targets only accept string values.                                                                                                                                    |

***

#### UpdateDecrement

Decrement a numeric field by a given amount.

| Name   | Type          | Required | Description             |
| ------ | ------------- | -------- | ----------------------- |
| `by`   | `number`      | Yes      | Amount to decrement by. |
| `path` | `string`      | Yes      | First-level field path. |
| `type` | `"decrement"` | Yes      | -                       |

***

#### UpdateIncrement

Increment a numeric field by a given amount.

| Name   | Type          | Required | Description             |
| ------ | ------------- | -------- | ----------------------- |
| `by`   | `number`      | Yes      | Amount to increment by. |
| `path` | `string`      | Yes      | First-level field path. |
| `type` | `"increment"` | Yes      | -                       |

***

#### UpdateMerge

Shallow-merge an object into the target. The target is the root
(when `path` is omitted/empty) or an arbitrary nested location
specified by an array of literal segments. See MergePath.

Validation: invalid paths/values (depth > 32, segment > 256 bytes,
value depth > 16, > 1024 top-level keys, or any
`__proto__`/`constructor`/`prototype` segment or top-level key) are
rejected with a structured error in the response's `errors` array.

| Name    | Type                      | Required | Description                                       |
| ------- | ------------------------- | -------- | ------------------------------------------------- |
| `path`  | [`MergePath`](#mergepath) | No       | Optional path to the merge target. See MergePath. |
| `type`  | `"merge"`                 | Yes      | -                                                 |
| `value` | `any`                     | Yes      | Object to merge. Must be a JSON object.           |

***

#### UpdateOp

Union of all atomic update operations supported by streams.

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"dark-plus"}}
type UpdateOp = UpdateSet | UpdateIncrement | UpdateDecrement | UpdateAppend | UpdateRemove | UpdateMerge
```

***

#### UpdateOpError

Per-op error returned by `state::update` / `stream::update`.

| Name       | Type     | Required | Description                                                       |
| ---------- | -------- | -------- | ----------------------------------------------------------------- |
| `code`     | `string` | Yes      | Stable error code, e.g. `"merge.path.too_deep"`.                  |
| `doc_url`  | `string` | No       | Optional documentation URL.                                       |
| `message`  | `string` | Yes      | Human-readable description with concrete numbers when applicable. |
| `op_index` | `number` | Yes      | Index of the offending op within the original `ops` array.        |

***

#### UpdateRemove

Remove a field at the given path.

| Name   | Type       | Required | Description             |
| ------ | ---------- | -------- | ----------------------- |
| `path` | `string`   | Yes      | First-level field path. |
| `type` | `"remove"` | Yes      | -                       |

***

#### UpdateSet

Set a field at the given path to a value.

| Name    | Type     | Required | Description                                                           |
| ------- | -------- | -------- | --------------------------------------------------------------------- |
| `path`  | `string` | Yes      | First-level field path. Use an empty string to target the root value. |
| `type`  | `"set"`  | Yes      | -                                                                     |
| `value` | `any`    | Yes      | Value to set.                                                         |
