Skip to main content

Component Layer

High-level components designed for Lens Studio integration.

EstuaryManager

Singleton manager for SDK connections. Routes events to registered characters.

import { EstuaryManager } from 'estuary-lens-studio-sdk';

Access

// Get instance (creates if needed)
const manager = EstuaryManager.instance;

// Check if exists
if (EstuaryManager.hasInstance) { ... }

Methods

MethodParametersDescription
connect()-Connect using current config
disconnect()-Disconnect from server
registerCharacter()characterRegister a character handler
unregisterCharacter()characterUnregister a character
setActiveCharacter()characterSet active character
sendText()text: stringSend text message
streamAudio()audioBase64: stringStream audio
notifyAudioPlaybackComplete()-Notify playback done
dispose()-Clean up resources

Properties

PropertyTypeDescription
configEstuaryConfig | nullCurrent configuration
isConnectedbooleanConnection status
connectionStateConnectionStateCurrent state
debugLoggingbooleanDebug mode

EstuaryCharacter

Represents an AI character for conversations.

import { EstuaryCharacter } from 'estuary-lens-studio-sdk';

Constructor

const character = new EstuaryCharacter(characterId, playerId);

Methods

MethodParametersDescription
initialize()config: EstuaryConfigInitialize and optionally connect
connect()-Connect to server
disconnect()-Disconnect
sendText()message: stringSend text message
startVoiceSession()-Enable voice streaming
endVoiceSession()-Disable voice streaming
streamAudio()audioBase64: stringStream audio data
interrupt()-Interrupt current response
dispose()-Clean up resources

Properties

PropertyTypeDescription
characterIdstringCharacter UUID
playerIdstringUser identifier
autoConnectbooleanAuto-connect on init
autoReconnectbooleanAuto-reconnect on disconnect
isConnectedbooleanConnection status
currentSessionSessionInfo | nullSession info
isVoiceSessionActivebooleanVoice session status
currentPartialResponsestringStreaming response text
currentMessageIdstringCurrent message ID
microphoneIEstuaryMicrophoneControllerMicrophone controller

Events

EventDataDescription
connectedSessionInfoConnected to server
disconnected-Disconnected
botResponseBotResponseAI text response
voiceReceivedBotVoiceAI voice audio
transcriptSttResponseUser speech transcription
interruptInterruptDataResponse interrupted
errorstringError occurred
connectionStateChangedConnectionStateState changed

EstuaryCredentials

Lens Studio component for centralized credential management with automatic User ID persistence.

import { EstuaryCredentials, IEstuaryCredentials } from 'estuary-lens-studio-sdk';

Inspector Inputs

InputTypeDescription
apiKeystringEstuary API key
characterIdstringCharacter UUID
debugModebooleanEnable debug logging
userIdFieldstringOptional manual User ID

Properties

PropertyTypeDescription
serverUrlstringServer URL (default: wss://api.estuary-ai.com)
userIdstringResolved User ID

Static Access

// Singleton access
if (EstuaryCredentials.hasInstance) {
const creds = EstuaryCredentials.instance;
print(creds.apiKey);
print(creds.userId);
}

Interface

interface IEstuaryCredentials {
apiKey: string;
characterId: string;
serverUrl: string;
debugMode: boolean;
userId: string;
}

EstuaryMicrophone

Handles microphone input for voice chat.

import { EstuaryMicrophone, MicrophoneRecorder } from 'estuary-lens-studio-sdk';

Constructor

const mic = new EstuaryMicrophone(character);

Methods

MethodParametersDescription
setMicrophoneRecorder()recorder: MicrophoneRecorderSet audio source
startRecording()-Start capturing audio
stopRecording()-Stop capturing
toggleRecording()-Toggle recording state
dispose()-Clean up resources

Properties

PropertyTypeDescription
sampleRatenumberRecording sample rate (16000)
debugLoggingbooleanDebug mode
isRecordingbooleanRecording status
targetCharacterEstuaryCharacterTarget character

Events

EventDescription
recordingStartedRecording began
recordingStoppedRecording ended
audioChunkSentAudio chunk transmitted

MicrophoneRecorder Interface

interface MicrophoneRecorder {
setSampleRate(sampleRate: number): void;
onAudioFrame: {
add(callback: (audioFrame: Float32Array) => void): void;
};
startRecording(): void;
stopRecording(): void;
}