For AI agents: the complete documentation index is available at https://scriptedalchemy.github.io/agent-bundle/llms.txt, the full documentation bundle is available at https://scriptedalchemy.github.io/agent-bundle/llms-full.txt, and this page is available as Markdown at https://scriptedalchemy.github.io/agent-bundle/api/app.md.
Skip to main content
  • English
  • Module: app

    Classes

    AppClientError

    Extends

    • Error

    Constructors

    Constructor

    new AppClientError(code, message, options?): AppClientError

    Parameters
    code

    AppClientErrorCode

    message

    string

    options?

    Readonly<{ data?: JsonValue; rpcCode?: number; }>

    Returns

    AppClientError

    Overrides

    Error.constructor

    Properties

    ~effect/ErrorReporter/attributes?

    readonly optional ~effect/ErrorReporter/attributes?: ReadonlyRecord<string, unknown>

    Inherited from

    Error.~effect/ErrorReporter/attributes

    ~effect/ErrorReporter/ignore?

    readonly optional ~effect/ErrorReporter/ignore?: boolean

    Inherited from

    Error.~effect/ErrorReporter/ignore

    ~effect/ErrorReporter/severity?

    readonly optional ~effect/ErrorReporter/severity?: Severity

    Inherited from

    Error.~effect/ErrorReporter/severity

    ~effect/Runtime/errorExitCode?

    readonly optional ~effect/Runtime/errorExitCode?: number

    Inherited from

    Error.~effect/Runtime/errorExitCode

    ~effect/Runtime/errorReported?

    readonly optional ~effect/Runtime/errorReported?: boolean

    Inherited from

    Error.~effect/Runtime/errorReported

    cause?

    optional cause?: unknown

    Inherited from

    Error.cause

    code

    readonly code: AppClientErrorCode

    data?

    readonly optional data?: JsonValue

    message

    message: string

    Inherited from

    Error.message

    name

    name: string

    Inherited from

    Error.name

    rpcCode?

    readonly optional rpcCode?: number

    stack?

    optional stack?: string

    Inherited from

    Error.stack

    stackTraceLimit

    static stackTraceLimit: number

    The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

    The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

    If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

    Inherited from

    Error.stackTraceLimit

    Methods

    captureStackTrace()

    static captureStackTrace(targetObject, constructorOpt?): void

    Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

    const myObject = {};
    Error.captureStackTrace(myObject);
    myObject.stack;  // Similar to `new Error().stack`

    The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

    The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

    The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

    function a() {
      b();
    }
    
    function b() {
      c();
    }
    
    function c() {
      // Create an error without stack trace to avoid calculating the stack trace twice.
      const { stackTraceLimit } = Error;
      Error.stackTraceLimit = 0;
      const error = new Error();
      Error.stackTraceLimit = stackTraceLimit;
    
      // Capture the stack trace above function b
      Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
      throw error;
    }
    
    a();
    Parameters
    targetObject

    object

    constructorOpt?

    Function

    Returns

    void

    Inherited from

    Error.captureStackTrace

    prepareStackTrace()

    static prepareStackTrace(err, stackTraces): any

    Parameters
    err

    Error

    stackTraces

    CallSite[]

    Returns

    any

    See

    https://v8.dev/docs/stack-trace-api#customizing-stack-traces

    Inherited from

    Error.prepareStackTrace

    Interfaces

    AppAbortSignal

    Properties

    aborted

    readonly aborted: boolean

    Methods

    addEventListener()

    addEventListener(type, listener, options?): void

    Parameters
    type

    "abort"

    listener

    () => void

    options?

    Readonly<{ once?: boolean; }>

    Returns

    void

    removeEventListener()

    removeEventListener(type, listener): void

    Parameters
    type

    "abort"

    listener

    () => void

    Returns

    void


    AppClient

    Properties

    connected

    readonly connected: boolean

    disposed

    readonly disposed: boolean

    Methods

    call()

    call<Id>(routeId, input, options?): Promise<AppRouteResult<Id>>

    Type Parameters
    Id

    Id extends `tool:${string}/${string}`

    Parameters
    routeId

    Id

    input

    AppRouteInput<Id>

    options?

    AppRequestOptions

    Returns

    Promise<AppRouteResult<Id>>

    connect()

    connect(options?): Promise<AppInitializeResult>

    Parameters
    options?

    AppRequestOptions

    Returns

    Promise<AppInitializeResult>

    dispose()

    dispose(): void

    Returns

    void

    onToolCancelled()

    onToolCancelled(listener): () => void

    Parameters
    listener

    AppToolCancelledListener

    Returns

    () => void

    onToolError()

    onToolError<Id>(routeId, listener): () => void

    Type Parameters
    Id

    Id extends `tool:${string}/${string}`

    Parameters
    routeId

    Id

    listener

    AppToolErrorListener

    Returns

    () => void

    onToolInput()

    onToolInput<Id>(routeId, listener): () => void

    Type Parameters
    Id

    Id extends `tool:${string}/${string}`

    Parameters
    routeId

    Id

    listener

    AppToolInputListener<Id>

    Returns

    () => void

    onToolResult()

    onToolResult<Id>(routeId, listener): () => void

    Type Parameters
    Id

    Id extends `tool:${string}/${string}`

    Parameters
    routeId

    Id

    listener

    AppToolResultListener<Id>

    Returns

    () => void

    rebind()

    rebind(options?): Promise<AppInitializeResult>

    Parameters
    options?

    AppConnectOptions

    Returns

    Promise<AppInitializeResult>

    request()

    request<Result>(method, params?, options?): Promise<Result>

    Type Parameters
    Result

    Result extends JsonValue = JsonValue

    Parameters
    method

    string

    params?

    JsonObject

    options?

    AppRequestOptions

    Returns

    Promise<Result>


    AppConnectOptions

    Extended by

    Properties

    parent?

    readonly optional parent?: AppMessageTarget

    targetOrigin?

    readonly optional targetOrigin?: string

    window?

    readonly optional window?: AppWindow


    AppImplementation

    Properties

    name

    readonly name: string

    version

    readonly version: string


    AppInitializeResult

    Extends

    • JsonObject

    Indexable

    [key: string]: JsonValue

    Properties

    hostCapabilities

    readonly hostCapabilities: JsonObject

    hostContext

    readonly hostContext: JsonObject

    hostInfo

    readonly hostInfo: JsonObject

    protocolVersion

    readonly protocolVersion: "2026-01-26"


    AppMessageEvent

    Properties

    data

    readonly data: unknown

    origin

    readonly origin: string

    source

    readonly source: unknown


    AppMessageTarget

    Methods

    postMessage()

    postMessage(message, targetOrigin): void

    Parameters
    message

    JsonObject

    targetOrigin

    string

    Returns

    void


    AppRegister

    Project-generated declarations augment this interface with routes.


    AppRequestOptions

    Properties

    signal?

    readonly optional signal?: AppAbortSignal

    timeoutMs?

    readonly optional timeoutMs?: number


    AppRouteContract

    Properties

    input

    readonly input: unknown

    result

    readonly result: unknown


    AppWindow

    Properties

    parent

    readonly parent: AppMessageTarget

    Methods

    addEventListener()

    addEventListener(type, listener): void

    Parameters
    type

    "message"

    listener

    (event) => void

    Returns

    void

    removeEventListener()

    removeEventListener(type, listener): void

    Parameters
    type

    "message"

    listener

    (event) => void

    Returns

    void


    CreateAppClientOptions

    Extends

    Properties

    appCapabilities?

    readonly optional appCapabilities?: JsonObject

    appInfo?

    readonly optional appInfo?: AppImplementation

    parent?

    readonly optional parent?: AppMessageTarget

    Inherited from

    AppConnectOptions.parent

    targetOrigin?

    readonly optional targetOrigin?: string

    Inherited from

    AppConnectOptions.targetOrigin

    timeoutMs?

    readonly optional timeoutMs?: number

    window?

    readonly optional window?: AppWindow

    Inherited from

    AppConnectOptions.window

    Type Aliases

    AppClientErrorCode

    AppClientErrorCode = "timeout" | "aborted" | "disposed" | "connection-rebound" | "invalid-message" | "rpc" | "capability-unavailable" | "consent-required"


    AppRouteId

    AppRouteId = unknown extends AppRoutes ? `tool:${string}/${string}` : Extract<keyof AppRoutes, `tool:${string}/${string}`> & string


    AppRouteInput

    AppRouteInput<Id> = Id extends keyof AppRoutes ? AppRoutes[Id] extends AppRouteContract ? AppRoutes[Id]["input"] : unknown : unknown

    What a caller sends for one route: the registered inputSchema input type (defaults optional, transforms as the wire carries them), before the server parses it.

    Type Parameters

    Id

    Id extends string


    AppRouteResult

    AppRouteResult<Id> = Id extends keyof AppRoutes ? AppRoutes[Id] extends AppRouteContract ? AppRoutes[Id]["result"] : unknown : unknown

    The structured result one route resolves with: the registered resultSchema output.

    Type Parameters

    Id

    Id extends string


    AppRoutes

    AppRoutes = AppRegister extends object ? Routes extends { readonly [Id in keyof Routes]: AppRouteContract } ? Routes : never : unknown


    AppToolCancelledListener

    AppToolCancelledListener = (event) => Promise<void> | void

    Parameters

    event

    Readonly<{ reason?: string; }>

    Returns

    Promise<void> | void


    AppToolErrorListener

    AppToolErrorListener = (error) => Promise<void> | void

    Parameters

    error

    AppClientError

    Returns

    Promise<void> | void


    AppToolInputListener

    AppToolInputListener<Id> = (input) => Promise<void> | void

    Type Parameters

    Id

    Id extends string

    Parameters

    input

    AppRouteInput<Id>

    Returns

    Promise<void> | void


    AppToolResultListener

    AppToolResultListener<Id> = (result) => Promise<void> | void

    Type Parameters

    Id

    Id extends string

    Parameters

    result

    AppRouteResult<Id>

    Returns

    Promise<void> | void

    Variables

    APP_PROTOCOL_VERSION

    const APP_PROTOCOL_VERSION: "2026-01-26" = "2026-01-26"


    createAppClient

    const createAppClient: (options?) => AppClient

    Parameters

    options?

    CreateAppClientOptions

    Returns

    AppClient