Skip to main content

Documentation Index

Fetch the complete documentation index at: https://dev.docs.inworld.ai/llms.txt

Use this file to discover all available pages before exploring further.

Examples

// Voice Agent example: Extracting audio with metadata
class AudioExtractorNode extends CustomNode {
  async process(context: ProcessContext, input: DataStreamWithMetadata): Promise<GraphTypes.Audio> {
    const metadata = input.getMetadata();

    // Check metadata to determine if processing is complete
    if (!metadata.interaction_complete) {
      throw new Error('Interaction not complete');
    }

    // Extract completed audio from metadata
    return metadata.completed_audio as GraphTypes.Audio;
  }
}

Constructors

Methods


Constructors

constructor

new DataStreamWithMetadata(streamOrWrapper: object, metadata?: { [x: string]: any; }): DataStreamWithMetadata
Creates a new DataStreamWithMetadata instance.

Parameters

streamOrWrapper
object
required
The stream to wrap. Can be a raw stream or any typed stream wrapper.
metadata
{ [x: string]: any; }
Metadata object containing contextual information. Common fields include iteration, completed, elementType, and any custom application data.

Returns

DataStreamWithMetadata

Methods

getMetadata

getMetadata(): { [x: string]: any; }
Gets the metadata object containing all contextual information.

Returns

{ [x: string]: any; }

getElementType

getElementType(): string
Gets the element type of the stream if specified in metadata. Indicates what type of data elements the stream contains.

Returns

string

toStream

toStream(): AudioChunkStream | TextStream | ...
Converts the wrapped stream to its appropriate typed stream wrapper. Automatically detects the stream type from metadata and returns the correct stream class. Detection order: 1. metadata.elementType (most reliable, set when wrapping) 2. stream.type property (fallback)

Returns

AudioChunkStream | TextStream | ...

toTextStream

toTextStream(): TextStream
Reconstructs a TextStream from the underlying NAPI stream.

Returns

TextStream

toAudioChunkStream

toAudioChunkStream(): AudioChunkStream
Reconstructs an AudioChunkStream from the underlying NAPI stream.

Returns

AudioChunkStream

toContentStream

toContentStream(): ContentStream
Reconstructs a ContentStream from the underlying NAPI stream.

Returns

ContentStream

toTTSOutputStream

toTTSOutputStream(): TTSOutputStream
Reconstructs a TTSOutputStream from the underlying NAPI stream.

Returns

TTSOutputStream