@estuary-ai/sdk 0.1.21 → 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/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 };
package/dist/index.d.ts 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 };
package/dist/index.js CHANGED
@@ -44,11 +44,7 @@ var init_errors = __esm({
44
44
  }
45
45
  });
46
46
 
47
- // src/voice/websocket-voice.ts
48
- var websocket_voice_exports = {};
49
- __export(websocket_voice_exports, {
50
- WebSocketVoiceManager: () => WebSocketVoiceManager
51
- });
47
+ // src/audio/audio-utils.ts
52
48
  function resample(input, fromRate, toRate) {
53
49
  const ratio = fromRate / toRate;
54
50
  const outputLength = Math.round(input.length / ratio);
@@ -80,10 +76,21 @@ function uint8ArrayToBase64(bytes) {
80
76
  }
81
77
  return Buffer.from(bytes).toString("base64");
82
78
  }
79
+ var init_audio_utils = __esm({
80
+ "src/audio/audio-utils.ts"() {
81
+ }
82
+ });
83
+
84
+ // src/voice/websocket-voice.ts
85
+ var websocket_voice_exports = {};
86
+ __export(websocket_voice_exports, {
87
+ WebSocketVoiceManager: () => WebSocketVoiceManager
88
+ });
83
89
  var WebSocketVoiceManager;
84
90
  var init_websocket_voice = __esm({
85
91
  "src/voice/websocket-voice.ts"() {
86
92
  init_errors();
93
+ init_audio_utils();
87
94
  WebSocketVoiceManager = class {
88
95
  socketManager;
89
96
  sampleRate;
@@ -770,12 +777,15 @@ async function createVoiceManager(transport, socketManager, sampleRate, logger)
770
777
 
771
778
  // src/rest/rest-client.ts
772
779
  init_errors();
780
+ var DEFAULT_TIMEOUT_MS = 1e4;
773
781
  var RestClient = class {
774
782
  baseUrl;
775
783
  apiKey;
776
- constructor(baseUrl, apiKey) {
784
+ timeoutMs;
785
+ constructor(baseUrl, apiKey, timeoutMs = DEFAULT_TIMEOUT_MS) {
777
786
  this.baseUrl = baseUrl.replace(/\/+$/, "");
778
787
  this.apiKey = apiKey;
788
+ this.timeoutMs = timeoutMs;
779
789
  }
780
790
  async get(path, params) {
781
791
  const url = this.buildUrl(path, params);
@@ -810,7 +820,11 @@ var RestClient = class {
810
820
  async request(url, init) {
811
821
  const headers = new Headers(init.headers);
812
822
  headers.set("X-API-Key", this.apiKey);
813
- const response = await fetch(url, { ...init, headers });
823
+ const response = await fetch(url, {
824
+ ...init,
825
+ headers,
826
+ signal: AbortSignal.timeout(this.timeoutMs)
827
+ });
814
828
  if (!response.ok) {
815
829
  let detail;
816
830
  try {
@@ -1153,20 +1167,20 @@ var EstuaryClient = class extends TypedEventEmitter {
1153
1167
  return session;
1154
1168
  }
1155
1169
  /** Disconnect from the server */
1156
- disconnect() {
1170
+ async disconnect() {
1157
1171
  this.logger.info("Disconnecting...");
1158
1172
  if (this._autoInterruptGraceTimer) {
1159
1173
  clearTimeout(this._autoInterruptGraceTimer);
1160
1174
  this._autoInterruptGraceTimer = null;
1161
1175
  }
1162
- this.stopVoice();
1176
+ await this.stopVoice();
1163
1177
  this.audioPlayer?.dispose();
1164
1178
  this.audioPlayer = null;
1165
1179
  this.socketManager.disconnect();
1166
1180
  this._sessionInfo = null;
1167
1181
  }
1168
- /** Send a text message to the character */
1169
- sendText(text, textOnly = false) {
1182
+ /** Send a text message to the character. Defaults to textOnly=true (no TTS audio response). Pass textOnly=false to receive voice audio. */
1183
+ sendText(text, textOnly = true) {
1170
1184
  this.ensureConnected();
1171
1185
  this.socketManager.emitEvent("text", { text, textOnly });
1172
1186
  }
@@ -1244,9 +1258,9 @@ var EstuaryClient = class extends TypedEventEmitter {
1244
1258
  this.emit("voiceStarted");
1245
1259
  }
1246
1260
  /** Stop voice input */
1247
- stopVoice() {
1261
+ async stopVoice() {
1248
1262
  if (this.voiceManager?.isActive) {
1249
- this.voiceManager.stop();
1263
+ await this.voiceManager.stop();
1250
1264
  this.voiceManager.dispose();
1251
1265
  this.voiceManager = null;
1252
1266
  this.emit("voiceStopped");