@estuary-ai/sdk 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @estuary-ai/sdk
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@estuary-ai/sdk)](https://www.npmjs.com/package/@estuary-ai/sdk)
4
+
3
5
  TypeScript SDK for the [Estuary](https://www.estuary-ai.com) real-time AI conversation platform. Build applications with persistent AI characters that remember, hear, and see.
4
6
 
5
7
  ## Installation
@@ -274,6 +276,40 @@ import type {
274
276
  } from '@estuary-ai/sdk';
275
277
  ```
276
278
 
279
+ ## React / Next.js
280
+
281
+ The SDK uses browser APIs, so it must be used in client components. In Next.js App Router:
282
+
283
+ ```tsx
284
+ "use client";
285
+
286
+ import { useEffect, useRef } from 'react';
287
+ import { EstuaryClient } from '@estuary-ai/sdk';
288
+
289
+ export default function Chat() {
290
+ const clientRef = useRef<EstuaryClient | null>(null);
291
+
292
+ useEffect(() => {
293
+ const client = new EstuaryClient({
294
+ serverUrl: 'https://api.estuary-ai.com',
295
+ apiKey: 'est_...',
296
+ characterId: '...',
297
+ playerId: 'user-123',
298
+ });
299
+ clientRef.current = client;
300
+ client.connect();
301
+
302
+ return () => {
303
+ client.disconnect();
304
+ };
305
+ }, []);
306
+
307
+ return <div>...</div>;
308
+ }
309
+ ```
310
+
311
+ If using `next/dynamic` with `ssr: false`, the importing page must also be a client component in Next.js 16+.
312
+
277
313
  ## Requirements
278
314
 
279
315
  - Node.js 18+ or modern browser
@@ -1,9 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
1
  // src/errors.ts
8
2
  var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
9
3
  ErrorCode2["CONNECTION_FAILED"] = "CONNECTION_FAILED";
@@ -31,6 +25,6 @@ var EstuaryError = class extends Error {
31
25
  }
32
26
  };
33
27
 
34
- export { ErrorCode, EstuaryError, __export };
35
- //# sourceMappingURL=chunk-ZROWZRQD.mjs.map
36
- //# sourceMappingURL=chunk-ZROWZRQD.mjs.map
28
+ export { ErrorCode, EstuaryError };
29
+ //# sourceMappingURL=chunk-6M5LSBMK.mjs.map
30
+ //# sourceMappingURL=chunk-6M5LSBMK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"names":["ErrorCode"],"mappings":";AAAO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACL,EAAAA,WAAA,mBAAA,CAAA,GAAoB,mBAAA;AACpB,EAAAA,WAAA,aAAA,CAAA,GAAc,aAAA;AACd,EAAAA,WAAA,oBAAA,CAAA,GAAqB,oBAAA;AACrB,EAAAA,WAAA,gBAAA,CAAA,GAAiB,gBAAA;AACjB,EAAAA,WAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,EAAAA,WAAA,sBAAA,CAAA,GAAuB,sBAAA;AACvB,EAAAA,WAAA,kBAAA,CAAA,GAAmB,kBAAA;AACnB,EAAAA,WAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,EAAAA,WAAA,mBAAA,CAAA,GAAoB,mBAAA;AACpB,EAAAA,WAAA,eAAA,CAAA,GAAgB,eAAA;AAChB,EAAAA,WAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,WAAA,SAAA,CAAA,GAAU,SAAA;AAZA,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;AAeL,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EAC7B,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CAAY,IAAA,EAAiB,OAAA,EAAiB,OAAA,EAAmB;AAC/D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF","file":"chunk-6M5LSBMK.mjs","sourcesContent":["export enum ErrorCode {\r\n CONNECTION_FAILED = 'CONNECTION_FAILED',\r\n AUTH_FAILED = 'AUTH_FAILED',\r\n CONNECTION_TIMEOUT = 'CONNECTION_TIMEOUT',\r\n QUOTA_EXCEEDED = 'QUOTA_EXCEEDED',\r\n VOICE_NOT_SUPPORTED = 'VOICE_NOT_SUPPORTED',\r\n VOICE_ALREADY_ACTIVE = 'VOICE_ALREADY_ACTIVE',\r\n VOICE_NOT_ACTIVE = 'VOICE_NOT_ACTIVE',\r\n LIVEKIT_UNAVAILABLE = 'LIVEKIT_UNAVAILABLE',\r\n MICROPHONE_DENIED = 'MICROPHONE_DENIED',\r\n NOT_CONNECTED = 'NOT_CONNECTED',\r\n REST_ERROR = 'REST_ERROR',\r\n UNKNOWN = 'UNKNOWN',\r\n}\r\n\r\nexport class EstuaryError extends Error {\r\n readonly code: ErrorCode;\r\n readonly details?: unknown;\r\n\r\n constructor(code: ErrorCode, message: string, details?: unknown) {\r\n super(message);\r\n this.name = 'EstuaryError';\r\n this.code = code;\r\n this.details = details;\r\n }\r\n}\r\n"]}
package/dist/index.d.mts CHANGED
@@ -13,7 +13,7 @@ interface EstuaryConfig {
13
13
  autoReconnect?: boolean;
14
14
  /** Max reconnect attempts (default: 5) */
15
15
  maxReconnectAttempts?: number;
16
- /** Delay between reconnect attempts in ms (default: 2000) */
16
+ /** Base delay between reconnect attempts in ms (default: 2000). Actual delay is baseDelay × attemptNumber (linear backoff). */
17
17
  reconnectDelayMs?: number;
18
18
  /** Enable debug logging (default: false) */
19
19
  debug?: boolean;
@@ -82,14 +82,23 @@ interface CameraCaptureRequest {
82
82
  }
83
83
  interface MemoryData {
84
84
  id: string;
85
+ userId: string;
86
+ agentId: string;
87
+ playerId: string;
85
88
  content: string;
86
89
  memoryType: string;
87
90
  confidence: number;
88
91
  status: string;
89
92
  sourceConversationId: string;
90
93
  sourceQuote?: string;
94
+ source?: string;
91
95
  topic?: string;
92
- createdAt: string;
96
+ secondaryTopics?: string[];
97
+ lastAccessedAt?: string | null;
98
+ accessCount?: number;
99
+ extractedAt?: string | null;
100
+ createdAt?: string | null;
101
+ updatedAt?: string | null;
93
102
  }
94
103
  interface MemoryUpdatedEvent {
95
104
  agentId: string;
@@ -162,7 +171,7 @@ interface MemorySearchOptions {
162
171
  limit?: number;
163
172
  }
164
173
  interface MemoryListResponse {
165
- memories: Record<string, unknown>[];
174
+ memories: MemoryData[];
166
175
  total: number;
167
176
  limit: number;
168
177
  offset: number;
@@ -170,36 +179,93 @@ interface MemoryListResponse {
170
179
  interface MemoryTimelineResponse {
171
180
  timeline: {
172
181
  date: string;
173
- memories: Record<string, unknown>[];
182
+ memories: MemoryData[];
174
183
  }[];
175
184
  totalMemories: number;
176
185
  groupBy: string;
177
186
  }
178
187
  interface MemoryStatsResponse {
179
- [key: string]: unknown;
188
+ totalActive: number;
189
+ totalSuperseded: number;
190
+ totalDecayed: number;
191
+ byType: Record<string, number>;
192
+ coreFacts: number;
193
+ }
194
+ interface MemoryGraphNode {
195
+ id: string;
196
+ type: 'user' | 'cluster' | 'memory' | 'entity';
197
+ label?: string;
198
+ /** Cluster fields */
199
+ level?: number;
200
+ memoryCount?: number;
201
+ typeDistribution?: Record<string, number>;
202
+ expanded?: boolean;
203
+ parentClusterId?: string | null;
204
+ childClusterIds?: string[];
205
+ labelPending?: boolean;
206
+ /** Memory fields */
207
+ memoryType?: string;
208
+ content?: string;
209
+ confidence?: number;
210
+ clusterId?: string;
211
+ sourceQuote?: string | null;
212
+ sourceConversationId?: string | null;
213
+ createdAt?: string | null;
214
+ accessCount?: number;
215
+ /** Entity fields */
216
+ entityType?: string | null;
217
+ name?: string;
218
+ mentionCount?: number;
219
+ extraData?: Record<string, string>;
220
+ }
221
+ interface MemoryGraphEdge {
222
+ source: string;
223
+ target: string;
224
+ type: 'has_cluster' | 'contains' | 'mentions' | 'relationship';
225
+ relationshipType?: string;
226
+ label?: string | null;
227
+ confidence?: number;
180
228
  }
181
229
  interface MemoryGraphResponse {
182
- nodes: Record<string, unknown>[];
183
- edges: Record<string, unknown>[];
184
- stats: Record<string, unknown>;
230
+ nodes: MemoryGraphNode[];
231
+ edges: MemoryGraphEdge[];
232
+ stats: {
233
+ totalMemories: number;
234
+ totalEntities: number;
235
+ clusterCount: number;
236
+ clusters: Record<string, number>;
237
+ };
238
+ stale?: boolean;
185
239
  }
186
240
  interface MemorySearchResponse {
187
241
  results: {
188
- memory: Record<string, unknown>;
242
+ memory: MemoryData;
189
243
  score: number;
190
244
  similarityScore: number;
191
245
  }[];
192
246
  query: string;
193
247
  total: number;
194
248
  }
249
+ interface CoreFact {
250
+ id: string;
251
+ userId: string;
252
+ agentId: string;
253
+ playerId: string;
254
+ factKey: string;
255
+ factValue: string;
256
+ sourceMemoryId?: string | null;
257
+ createdAt?: string | null;
258
+ updatedAt?: string | null;
259
+ }
195
260
  interface CoreFactsResponse {
196
- coreFacts: Record<string, unknown>[];
261
+ coreFacts: CoreFact[];
197
262
  }
198
263
 
199
264
  declare class RestClient {
200
265
  private baseUrl;
201
266
  private apiKey;
202
- constructor(baseUrl: string, apiKey: string);
267
+ private timeoutMs;
268
+ constructor(baseUrl: string, apiKey: string, timeoutMs?: number);
203
269
  get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
204
270
  post<T>(path: string, body?: unknown): Promise<T>;
205
271
  delete<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
@@ -259,8 +325,8 @@ declare class EstuaryClient extends TypedEventEmitter<EstuaryEventMap> {
259
325
  /** Connect to the Estuary server and authenticate */
260
326
  connect(): Promise<SessionInfo>;
261
327
  /** Disconnect from the server */
262
- disconnect(): void;
263
- /** Send a text message to the character */
328
+ disconnect(): Promise<void>;
329
+ /** Send a text message to the character. Defaults to textOnly=true (no TTS audio response). Pass textOnly=false to receive voice audio. */
264
330
  sendText(text: string, textOnly?: boolean): void;
265
331
  /** Interrupt the current bot response */
266
332
  interrupt(messageId?: string): void;
@@ -275,7 +341,7 @@ declare class EstuaryClient extends TypedEventEmitter<EstuaryEventMap> {
275
341
  /** Start voice input (requests microphone permission) */
276
342
  startVoice(): Promise<void>;
277
343
  /** Stop voice input */
278
- stopVoice(): void;
344
+ stopVoice(): Promise<void>;
279
345
  /** Toggle microphone mute */
280
346
  toggleMute(): void;
281
347
  /** Whether the microphone is muted */
@@ -328,4 +394,4 @@ declare function parseActions(text: string): {
328
394
  cleanText: string;
329
395
  };
330
396
 
331
- export { type BotResponse, type BotVoice, type CameraCaptureRequest, type CharacterAction, ConnectionState, type CoreFactsResponse, ErrorCode, EstuaryClient, type EstuaryConfig, EstuaryError, type EstuaryEventMap, type InterruptData, type LiveKitTokenResponse, MemoryClient, type MemoryData, type MemoryGraphOptions, type MemoryGraphResponse, type MemoryListOptions, type MemoryListResponse, type MemorySearchOptions, type MemorySearchResponse, type MemoryStatsResponse, type MemoryTimelineOptions, type MemoryTimelineResponse, type MemoryUpdatedEvent, type ParsedAction, type QuotaExceededData, type SessionInfo, type SttResponse, type VoiceManager, type VoiceTransport, parseActions };
397
+ export { type BotResponse, type BotVoice, type CameraCaptureRequest, type CharacterAction, ConnectionState, type CoreFact, type CoreFactsResponse, ErrorCode, EstuaryClient, type EstuaryConfig, EstuaryError, type EstuaryEventMap, type InterruptData, type LiveKitTokenResponse, MemoryClient, type MemoryData, type MemoryGraphEdge, type MemoryGraphNode, type MemoryGraphOptions, type MemoryGraphResponse, type MemoryListOptions, type MemoryListResponse, type MemorySearchOptions, type MemorySearchResponse, type MemoryStatsResponse, type MemoryTimelineOptions, type MemoryTimelineResponse, type MemoryUpdatedEvent, type ParsedAction, type QuotaExceededData, type SessionInfo, type SttResponse, type VoiceManager, type VoiceTransport, parseActions };
@@ -0,0 +1,397 @@
1
+ interface EstuaryConfig {
2
+ /** Base URL of the Estuary server (e.g., "https://api.estuary-ai.com") */
3
+ serverUrl: string;
4
+ /** API key (starts with "est_") */
5
+ apiKey: string;
6
+ /** Character (agent) ID */
7
+ characterId: string;
8
+ /** Unique identifier for the end user */
9
+ playerId: string;
10
+ /** Audio sample rate in Hz (default: 16000) */
11
+ audioSampleRate?: number;
12
+ /** Auto-reconnect on disconnect (default: true) */
13
+ autoReconnect?: boolean;
14
+ /** Max reconnect attempts (default: 5) */
15
+ maxReconnectAttempts?: number;
16
+ /** Base delay between reconnect attempts in ms (default: 2000). Actual delay is baseDelay × attemptNumber (linear backoff). */
17
+ reconnectDelayMs?: number;
18
+ /** Enable debug logging (default: false) */
19
+ debug?: boolean;
20
+ /** Voice transport: 'websocket' | 'livekit' | 'auto' (default: 'auto') */
21
+ voiceTransport?: VoiceTransport;
22
+ /** Enable real-time memory extraction after each response (default: false) */
23
+ realtimeMemory?: boolean;
24
+ /** Suppress mic during TTS playback (software AEC fallback, disables barge-in). Default: false */
25
+ suppressMicDuringPlayback?: boolean;
26
+ /** Proactively interrupt bot audio when user starts speaking (default: true) */
27
+ autoInterruptOnSpeech?: boolean;
28
+ }
29
+ type VoiceTransport = 'websocket' | 'livekit' | 'auto';
30
+ declare enum ConnectionState {
31
+ Disconnected = "disconnected",
32
+ Connecting = "connecting",
33
+ Connected = "connected",
34
+ Reconnecting = "reconnecting",
35
+ Error = "error"
36
+ }
37
+ interface SessionInfo {
38
+ sessionId: string;
39
+ conversationId: string;
40
+ characterId: string;
41
+ playerId: string;
42
+ }
43
+ interface BotResponse {
44
+ text: string;
45
+ isFinal: boolean;
46
+ partial: string;
47
+ messageId: string;
48
+ chunkIndex: number;
49
+ isInterjection: boolean;
50
+ tokenStream?: boolean;
51
+ }
52
+ interface BotVoice {
53
+ audio: string;
54
+ messageId: string;
55
+ chunkIndex: number;
56
+ isFinal: boolean;
57
+ }
58
+ interface SttResponse {
59
+ text: string;
60
+ isFinal: boolean;
61
+ }
62
+ interface InterruptData {
63
+ messageId?: string;
64
+ reason?: string;
65
+ interruptedAt?: string;
66
+ }
67
+ interface QuotaExceededData {
68
+ message: string;
69
+ current: number;
70
+ limit: number;
71
+ remaining: number;
72
+ tier: string;
73
+ }
74
+ interface LiveKitTokenResponse {
75
+ token: string;
76
+ url: string;
77
+ room: string;
78
+ }
79
+ interface CameraCaptureRequest {
80
+ requestId: string;
81
+ text?: string;
82
+ }
83
+ interface MemoryData {
84
+ id: string;
85
+ userId: string;
86
+ agentId: string;
87
+ playerId: string;
88
+ content: string;
89
+ memoryType: string;
90
+ confidence: number;
91
+ status: string;
92
+ sourceConversationId: string;
93
+ sourceQuote?: string;
94
+ source?: string;
95
+ topic?: string;
96
+ secondaryTopics?: string[];
97
+ lastAccessedAt?: string | null;
98
+ accessCount?: number;
99
+ extractedAt?: string | null;
100
+ createdAt?: string | null;
101
+ updatedAt?: string | null;
102
+ }
103
+ interface MemoryUpdatedEvent {
104
+ agentId: string;
105
+ playerId: string;
106
+ memoriesExtracted: number;
107
+ factsExtracted: number;
108
+ conversationId: string;
109
+ newMemories: MemoryData[];
110
+ timestamp: string;
111
+ }
112
+ interface CharacterAction {
113
+ /** Action name (e.g., "follow_user", "sit", "look_at") */
114
+ name: string;
115
+ /** Action parameters as key-value pairs */
116
+ params: Record<string, string>;
117
+ /** Message ID of the bot response that contained this action */
118
+ messageId: string;
119
+ }
120
+ type EstuaryEventMap = {
121
+ connected: (session: SessionInfo) => void;
122
+ disconnected: (reason: string) => void;
123
+ reconnecting: (attempt: number) => void;
124
+ connectionStateChanged: (state: ConnectionState) => void;
125
+ botResponse: (response: BotResponse) => void;
126
+ botVoice: (voice: BotVoice) => void;
127
+ sttResponse: (response: SttResponse) => void;
128
+ interrupt: (data: InterruptData) => void;
129
+ error: (error: Error) => void;
130
+ authError: (error: string) => void;
131
+ quotaExceeded: (data: QuotaExceededData) => void;
132
+ cameraCaptureRequest: (request: CameraCaptureRequest) => void;
133
+ characterAction: (action: CharacterAction) => void;
134
+ voiceStarted: () => void;
135
+ voiceStopped: () => void;
136
+ livekitConnected: (room: string) => void;
137
+ livekitDisconnected: () => void;
138
+ audioPlaybackStarted: (messageId: string) => void;
139
+ audioPlaybackComplete: (messageId: string) => void;
140
+ memoryUpdated: (event: MemoryUpdatedEvent) => void;
141
+ };
142
+ interface VoiceManager {
143
+ start(): Promise<void>;
144
+ stop(): Promise<void>;
145
+ toggleMute(): void;
146
+ /** Suppress audio sending (software AEC). No-op if not supported. */
147
+ setSuppressed?(suppressed: boolean): void;
148
+ readonly isMuted: boolean;
149
+ readonly isActive: boolean;
150
+ dispose(): void;
151
+ }
152
+ interface MemoryListOptions {
153
+ memoryType?: string;
154
+ status?: string;
155
+ limit?: number;
156
+ offset?: number;
157
+ sortBy?: 'created_at' | 'confidence' | 'last_accessed_at';
158
+ sortOrder?: 'asc' | 'desc';
159
+ }
160
+ interface MemoryTimelineOptions {
161
+ startDate?: string;
162
+ endDate?: string;
163
+ groupBy?: 'day' | 'week' | 'month';
164
+ }
165
+ interface MemoryGraphOptions {
166
+ includeEntities?: boolean;
167
+ includeCharacterMemories?: boolean;
168
+ }
169
+ interface MemorySearchOptions {
170
+ query: string;
171
+ limit?: number;
172
+ }
173
+ interface MemoryListResponse {
174
+ memories: MemoryData[];
175
+ total: number;
176
+ limit: number;
177
+ offset: number;
178
+ }
179
+ interface MemoryTimelineResponse {
180
+ timeline: {
181
+ date: string;
182
+ memories: MemoryData[];
183
+ }[];
184
+ totalMemories: number;
185
+ groupBy: string;
186
+ }
187
+ interface MemoryStatsResponse {
188
+ totalActive: number;
189
+ totalSuperseded: number;
190
+ totalDecayed: number;
191
+ byType: Record<string, number>;
192
+ coreFacts: number;
193
+ }
194
+ interface MemoryGraphNode {
195
+ id: string;
196
+ type: 'user' | 'cluster' | 'memory' | 'entity';
197
+ label?: string;
198
+ /** Cluster fields */
199
+ level?: number;
200
+ memoryCount?: number;
201
+ typeDistribution?: Record<string, number>;
202
+ expanded?: boolean;
203
+ parentClusterId?: string | null;
204
+ childClusterIds?: string[];
205
+ labelPending?: boolean;
206
+ /** Memory fields */
207
+ memoryType?: string;
208
+ content?: string;
209
+ confidence?: number;
210
+ clusterId?: string;
211
+ sourceQuote?: string | null;
212
+ sourceConversationId?: string | null;
213
+ createdAt?: string | null;
214
+ accessCount?: number;
215
+ /** Entity fields */
216
+ entityType?: string | null;
217
+ name?: string;
218
+ mentionCount?: number;
219
+ extraData?: Record<string, string>;
220
+ }
221
+ interface MemoryGraphEdge {
222
+ source: string;
223
+ target: string;
224
+ type: 'has_cluster' | 'contains' | 'mentions' | 'relationship';
225
+ relationshipType?: string;
226
+ label?: string | null;
227
+ confidence?: number;
228
+ }
229
+ interface MemoryGraphResponse {
230
+ nodes: MemoryGraphNode[];
231
+ edges: MemoryGraphEdge[];
232
+ stats: {
233
+ totalMemories: number;
234
+ totalEntities: number;
235
+ clusterCount: number;
236
+ clusters: Record<string, number>;
237
+ };
238
+ stale?: boolean;
239
+ }
240
+ interface MemorySearchResponse {
241
+ results: {
242
+ memory: MemoryData;
243
+ score: number;
244
+ similarityScore: number;
245
+ }[];
246
+ query: string;
247
+ total: number;
248
+ }
249
+ interface CoreFact {
250
+ id: string;
251
+ userId: string;
252
+ agentId: string;
253
+ playerId: string;
254
+ factKey: string;
255
+ factValue: string;
256
+ sourceMemoryId?: string | null;
257
+ createdAt?: string | null;
258
+ updatedAt?: string | null;
259
+ }
260
+ interface CoreFactsResponse {
261
+ coreFacts: CoreFact[];
262
+ }
263
+
264
+ declare class RestClient {
265
+ private baseUrl;
266
+ private apiKey;
267
+ private timeoutMs;
268
+ constructor(baseUrl: string, apiKey: string, timeoutMs?: number);
269
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
270
+ post<T>(path: string, body?: unknown): Promise<T>;
271
+ delete<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
272
+ dispose(): void;
273
+ private buildUrl;
274
+ private request;
275
+ }
276
+
277
+ declare class MemoryClient {
278
+ private rest;
279
+ private basePath;
280
+ constructor(rest: RestClient, agentId: string, playerId: string);
281
+ getMemories(options?: MemoryListOptions): Promise<MemoryListResponse>;
282
+ getTimeline(options?: MemoryTimelineOptions): Promise<MemoryTimelineResponse>;
283
+ getStats(): Promise<MemoryStatsResponse>;
284
+ getCoreFacts(): Promise<CoreFactsResponse>;
285
+ getGraph(options?: MemoryGraphOptions): Promise<MemoryGraphResponse>;
286
+ search(query: string, limit?: number): Promise<MemorySearchResponse>;
287
+ deleteAll(confirm: boolean): Promise<{
288
+ message: string;
289
+ deletedCount: number;
290
+ }>;
291
+ dispose(): void;
292
+ }
293
+
294
+ declare class TypedEventEmitter<T extends Record<string, unknown>> {
295
+ private listeners;
296
+ private onceListeners;
297
+ on<K extends keyof T>(event: K, listener: T[K]): this;
298
+ off<K extends keyof T>(event: K, listener: T[K]): this;
299
+ once<K extends keyof T>(event: K, listener: T[K]): this;
300
+ protected emit<K extends keyof T>(event: K, ...args: T[K] extends (...a: infer A) => void ? A : never[]): boolean;
301
+ removeAllListeners<K extends keyof T>(event?: K): this;
302
+ listenerCount<K extends keyof T>(event: K): number;
303
+ }
304
+
305
+ declare class EstuaryClient extends TypedEventEmitter<EstuaryEventMap> {
306
+ private config;
307
+ private logger;
308
+ private socketManager;
309
+ private voiceManager;
310
+ private audioPlayer;
311
+ private _memory;
312
+ private _sessionInfo;
313
+ private actionParsers;
314
+ private _hasAutoInterrupted;
315
+ private _autoInterruptGraceTimer;
316
+ constructor(config: EstuaryConfig);
317
+ /** Memory API client for querying memories, graphs, and facts */
318
+ get memory(): MemoryClient;
319
+ /** Current session info (null if not connected) */
320
+ get session(): SessionInfo | null;
321
+ /** Current connection state */
322
+ get connectionState(): ConnectionState;
323
+ /** Whether the client is connected and authenticated */
324
+ get isConnected(): boolean;
325
+ /** Connect to the Estuary server and authenticate */
326
+ connect(): Promise<SessionInfo>;
327
+ /** Disconnect from the server */
328
+ disconnect(): Promise<void>;
329
+ /** Send a text message to the character. Defaults to textOnly=true (no TTS audio response). Pass textOnly=false to receive voice audio. */
330
+ sendText(text: string, textOnly?: boolean): void;
331
+ /** Interrupt the current bot response */
332
+ interrupt(messageId?: string): void;
333
+ /** Send a camera image for vision processing */
334
+ sendCameraImage(imageBase64: string, mimeType: string, requestId?: string, text?: string): void;
335
+ /** Update session preferences */
336
+ updatePreferences(preferences: {
337
+ enableVisionAcknowledgment?: boolean;
338
+ }): void;
339
+ /** Notify server that audio playback completed for a message */
340
+ notifyAudioPlaybackComplete(messageId?: string): void;
341
+ /** Start voice input (requests microphone permission) */
342
+ startVoice(): Promise<void>;
343
+ /** Stop voice input */
344
+ stopVoice(): Promise<void>;
345
+ /** Toggle microphone mute */
346
+ toggleMute(): void;
347
+ /** Whether the microphone is muted */
348
+ get isMuted(): boolean;
349
+ /** Whether voice is currently active */
350
+ get isVoiceActive(): boolean;
351
+ private ensureConnected;
352
+ private forwardSocketEvents;
353
+ private handleBotResponse;
354
+ private handleBotVoice;
355
+ private maybeAutoInterrupt;
356
+ }
357
+
358
+ declare enum ErrorCode {
359
+ CONNECTION_FAILED = "CONNECTION_FAILED",
360
+ AUTH_FAILED = "AUTH_FAILED",
361
+ CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT",
362
+ QUOTA_EXCEEDED = "QUOTA_EXCEEDED",
363
+ VOICE_NOT_SUPPORTED = "VOICE_NOT_SUPPORTED",
364
+ VOICE_ALREADY_ACTIVE = "VOICE_ALREADY_ACTIVE",
365
+ VOICE_NOT_ACTIVE = "VOICE_NOT_ACTIVE",
366
+ LIVEKIT_UNAVAILABLE = "LIVEKIT_UNAVAILABLE",
367
+ MICROPHONE_DENIED = "MICROPHONE_DENIED",
368
+ NOT_CONNECTED = "NOT_CONNECTED",
369
+ REST_ERROR = "REST_ERROR",
370
+ UNKNOWN = "UNKNOWN"
371
+ }
372
+ declare class EstuaryError extends Error {
373
+ readonly code: ErrorCode;
374
+ readonly details?: unknown;
375
+ constructor(code: ErrorCode, message: string, details?: unknown);
376
+ }
377
+
378
+ /**
379
+ * Parses `<action name="..." .../>` XML tags from bot response text.
380
+ *
381
+ * Designed for streaming: call `parse()` with the accumulated text on each
382
+ * chunk and it returns only newly-discovered actions since the last call.
383
+ */
384
+ interface ParsedAction {
385
+ name: string;
386
+ params: Record<string, string>;
387
+ }
388
+ /**
389
+ * One-shot parse: extract all actions and return clean text.
390
+ * Useful for non-streaming contexts.
391
+ */
392
+ declare function parseActions(text: string): {
393
+ actions: ParsedAction[];
394
+ cleanText: string;
395
+ };
396
+
397
+ export { type BotResponse, type BotVoice, type CameraCaptureRequest, type CharacterAction, ConnectionState, type CoreFact, type CoreFactsResponse, ErrorCode, EstuaryClient, type EstuaryConfig, EstuaryError, type EstuaryEventMap, type InterruptData, type LiveKitTokenResponse, MemoryClient, type MemoryData, type MemoryGraphEdge, type MemoryGraphNode, type MemoryGraphOptions, type MemoryGraphResponse, type MemoryListOptions, type MemoryListResponse, type MemorySearchOptions, type MemorySearchResponse, type MemoryStatsResponse, type MemoryTimelineOptions, type MemoryTimelineResponse, type MemoryUpdatedEvent, type ParsedAction, type QuotaExceededData, type SessionInfo, type SttResponse, type VoiceManager, type VoiceTransport, parseActions };