A11 TypeScript API - v0.2.1
    Preparing search index...

    Class AsyncNode

    One ordered, typed value sequence flowing through an A11 application.

    Action inputs and outputs are AsyncNodes. The writer serializes application values into sequenced chunks, persists them through a ChunkStore, and optionally tees stored fragments over a wire stream. The reader follows that same ordered log and deserializes values as they arrive, so an agent can expose tokens, audio frames, tool events, or a unary result through one protocol.

    Mark the logical end explicitly with putFinal or putNullFinal. Afterwards, drainAndClose waits for buffered work and closes storage. Failures should use abortWithStatus so local and remote readers see why the sequence ended.

    Index
    chunkStore: ChunkStore

    Ordered storage shared by the node's reader and writer.

    nodeMap: NodeMap | null

    Owning node map, or null for a standalone node.

    • Returns AsyncGenerator<unknown, void, void>

    • Consume and deserialize exactly one whole unary value.

      Type Parameters

      • T = unknown

      Parameters

      • options: {
            allowNone?: boolean;
            expectedTag?: string;
            mimetypePatterns?: string | readonly string[];
            raw?: "fragment" | "chunk";
            timeoutMs?: number;
        } = {}

      Returns Promise<StatusOr<Chunk | NodeFragment | T | null>>

    • Parameters

      • options: { allowNone?: boolean; timeoutMs?: number } = {}

      Returns Promise<StatusOr<Chunk | null>>

    • Consume exactly one whole value's fragment and validate its terminator. Use this for unary action ports; streaming ports should call next.

      Parameters

      • options: { allowNone?: boolean; timeoutMs?: number } = {}

      Returns Promise<StatusOr<NodeFragment | null>>

    • Flush queued writes and close the writer without adding a final fragment.

      Call putFinal or putNullFinal first when readers must synchronise on a definite end-of-stream sequence.

      Returns Promise<Status>

    • Read one value, or null at finality, clean closure, or the reader limit.

      Type Parameters

      • T = unknown

      Parameters

      • optionsOrTimeout:
            | number
            | {
                expectedTag?: string;
                mimetypePatterns?: string
                | readonly string[];
                timeoutMs?: number;
            } = {}

      Returns Promise<StatusOr<T | null>>

    • Read the next inline chunk without deserializing its payload.

      Parameters

      • OptionaltimeoutMs: number

      Returns Promise<StatusOr<Chunk | null>>

    • Serialize and persist one application value, respecting writer backpressure.

      Parameters

      • value: unknown
      • options: { final?: boolean; mimetype?: string; seq?: number | null } = {}

      Returns Promise<StatusOr<number>>

    • Persist a raw chunk, optionally at an explicit sequence and/or as final.

      Parameters

      • chunk: Chunk
      • seq: number | null = null
      • final: boolean = false

      Returns Promise<StatusOr<number>>

    • Write the last application value and establish the final sequence.

      Parameters

      • value: unknown
      • seq: number | null = null
      • mimetype: string = ''

      Returns Promise<StatusOr<number>>

    • Establish a final sequence with an explicit null marker and no value.

      Parameters

      • seq: number | null = null

      Returns Promise<StatusOr<number>>

    • Set default MIME/type constraints for subsequent typed reads.

      Parameters

      • mimetypePatterns: string | readonly string[] = ''
      • OptionalexpectedTag: string

      Returns Status

    • Iterate to the clean reader end, yielding at most one terminal error.

      Type Parameters

      • T = unknown

      Parameters

      • options: {
            expectedTag?: string;
            mimetypePatterns?: string | readonly string[];
            timeoutMs?: number;
        } = {}

      Returns AsyncGenerator<StatusOr<T>, void, void>