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
| Method | Parameters | Description |
|---|---|---|
connect() | - | Connect using current config |
disconnect() | - | Disconnect from server |
registerCharacter() | character | Register a character handler |
unregisterCharacter() | character | Unregister a character |
setActiveCharacter() | character | Set active character |
sendText() | text: string | Send text message |
streamAudio() | audioBase64: string | Stream audio |
notifyAudioPlaybackComplete() | - | Notify playback done |
dispose() | - | Clean up resources |
Properties
| Property | Type | Description |
|---|---|---|
config | EstuaryConfig | null | Current configuration |
isConnected | boolean | Connection status |
connectionState | ConnectionState | Current state |
debugLogging | boolean | Debug mode |
EstuaryCharacter
Represents an AI character for conversations.
import { EstuaryCharacter } from 'estuary-lens-studio-sdk';
Constructor
const character = new EstuaryCharacter(characterId, playerId);
Methods
| Method | Parameters | Description |
|---|---|---|
initialize() | config: EstuaryConfig | Initialize and optionally connect |
connect() | - | Connect to server |
disconnect() | - | Disconnect |
sendText() | message: string | Send text message |
startVoiceSession() | - | Enable voice streaming |
endVoiceSession() | - | Disable voice streaming |
streamAudio() | audioBase64: string | Stream audio data |
interrupt() | - | Interrupt current response |
dispose() | - | Clean up resources |
Properties
| Property | Type | Description |
|---|---|---|
characterId | string | Character UUID |
playerId | string | User identifier |
autoConnect | boolean | Auto-connect on init |
autoReconnect | boolean | Auto-reconnect on disconnect |
isConnected | boolean | Connection status |
currentSession | SessionInfo | null | Session info |
isVoiceSessionActive | boolean | Voice session status |
currentPartialResponse | string | Streaming response text |
currentMessageId | string | Current message ID |
microphone | IEstuaryMicrophoneController | Microphone controller |
Events
| Event | Data | Description |
|---|---|---|
connected | SessionInfo | Connected to server |
disconnected | - | Disconnected |
botResponse | BotResponse | AI text response |
voiceReceived | BotVoice | AI voice audio |
transcript | SttResponse | User speech transcription |
interrupt | InterruptData | Response interrupted |
error | string | Error occurred |
connectionStateChanged | ConnectionState | State changed |
EstuaryCredentials
Lens Studio component for centralized credential management with automatic User ID persistence.
import { EstuaryCredentials, IEstuaryCredentials } from 'estuary-lens-studio-sdk';
Inspector Inputs
| Input | Type | Description |
|---|---|---|
apiKey | string | Estuary API key |
characterId | string | Character UUID |
debugMode | boolean | Enable debug logging |
userIdField | string | Optional manual User ID |
Properties
| Property | Type | Description |
|---|---|---|
serverUrl | string | Server URL (default: wss://api.estuary-ai.com) |
userId | string | Resolved 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
| Method | Parameters | Description |
|---|---|---|
setMicrophoneRecorder() | recorder: MicrophoneRecorder | Set audio source |
startRecording() | - | Start capturing audio |
stopRecording() | - | Stop capturing |
toggleRecording() | - | Toggle recording state |
dispose() | - | Clean up resources |
Properties
| Property | Type | Description |
|---|---|---|
sampleRate | number | Recording sample rate (16000) |
debugLogging | boolean | Debug mode |
isRecording | boolean | Recording status |
targetCharacter | EstuaryCharacter | Target character |
Events
| Event | Description |
|---|---|
recordingStarted | Recording began |
recordingStopped | Recording ended |
audioChunkSent | Audio chunk transmitted |
MicrophoneRecorder Interface
interface MicrophoneRecorder {
setSampleRate(sampleRate: number): void;
onAudioFrame: {
add(callback: (audioFrame: Float32Array) => void): void;
};
startRecording(): void;
stopRecording(): void;
}