@estuary-ai/sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +127 -0
- package/dist/index.d.mts +291 -0
- package/dist/index.d.ts +291 -0
- package/dist/index.js +1164 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1161 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +71 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
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
|
+
/** Delay between reconnect attempts in ms (default: 2000) */
|
|
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
|
+
}
|
|
25
|
+
type VoiceTransport = 'websocket' | 'livekit' | 'auto';
|
|
26
|
+
declare enum ConnectionState {
|
|
27
|
+
Disconnected = "disconnected",
|
|
28
|
+
Connecting = "connecting",
|
|
29
|
+
Connected = "connected",
|
|
30
|
+
Reconnecting = "reconnecting",
|
|
31
|
+
Error = "error"
|
|
32
|
+
}
|
|
33
|
+
interface SessionInfo {
|
|
34
|
+
sessionId: string;
|
|
35
|
+
conversationId: string;
|
|
36
|
+
characterId: string;
|
|
37
|
+
playerId: string;
|
|
38
|
+
}
|
|
39
|
+
interface BotResponse {
|
|
40
|
+
text: string;
|
|
41
|
+
isFinal: boolean;
|
|
42
|
+
partial: string;
|
|
43
|
+
messageId: string;
|
|
44
|
+
chunkIndex: number;
|
|
45
|
+
isInterjection: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface BotVoice {
|
|
48
|
+
audio: string;
|
|
49
|
+
messageId: string;
|
|
50
|
+
chunkIndex: number;
|
|
51
|
+
isFinal: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface SttResponse {
|
|
54
|
+
text: string;
|
|
55
|
+
isFinal: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface InterruptData {
|
|
58
|
+
messageId?: string;
|
|
59
|
+
reason?: string;
|
|
60
|
+
interruptedAt?: string;
|
|
61
|
+
}
|
|
62
|
+
interface QuotaExceededData {
|
|
63
|
+
message: string;
|
|
64
|
+
current: number;
|
|
65
|
+
limit: number;
|
|
66
|
+
remaining: number;
|
|
67
|
+
tier: string;
|
|
68
|
+
}
|
|
69
|
+
interface LiveKitTokenResponse {
|
|
70
|
+
token: string;
|
|
71
|
+
url: string;
|
|
72
|
+
room: string;
|
|
73
|
+
}
|
|
74
|
+
interface CameraCaptureRequest {
|
|
75
|
+
requestId: string;
|
|
76
|
+
text?: string;
|
|
77
|
+
}
|
|
78
|
+
interface MemoryData {
|
|
79
|
+
id: string;
|
|
80
|
+
content: string;
|
|
81
|
+
memoryType: string;
|
|
82
|
+
confidence: number;
|
|
83
|
+
status: string;
|
|
84
|
+
sourceConversationId: string;
|
|
85
|
+
sourceQuote?: string;
|
|
86
|
+
topic?: string;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
}
|
|
89
|
+
interface MemoryUpdatedEvent {
|
|
90
|
+
agentId: string;
|
|
91
|
+
playerId: string;
|
|
92
|
+
memoriesExtracted: number;
|
|
93
|
+
factsExtracted: number;
|
|
94
|
+
conversationId: string;
|
|
95
|
+
newMemories: MemoryData[];
|
|
96
|
+
timestamp: string;
|
|
97
|
+
}
|
|
98
|
+
type EstuaryEventMap = {
|
|
99
|
+
connected: (session: SessionInfo) => void;
|
|
100
|
+
disconnected: (reason: string) => void;
|
|
101
|
+
reconnecting: (attempt: number) => void;
|
|
102
|
+
connectionStateChanged: (state: ConnectionState) => void;
|
|
103
|
+
botResponse: (response: BotResponse) => void;
|
|
104
|
+
botVoice: (voice: BotVoice) => void;
|
|
105
|
+
sttResponse: (response: SttResponse) => void;
|
|
106
|
+
interrupt: (data: InterruptData) => void;
|
|
107
|
+
error: (error: Error) => void;
|
|
108
|
+
authError: (error: string) => void;
|
|
109
|
+
quotaExceeded: (data: QuotaExceededData) => void;
|
|
110
|
+
cameraCaptureRequest: (request: CameraCaptureRequest) => void;
|
|
111
|
+
voiceStarted: () => void;
|
|
112
|
+
voiceStopped: () => void;
|
|
113
|
+
livekitConnected: (room: string) => void;
|
|
114
|
+
livekitDisconnected: () => void;
|
|
115
|
+
audioPlaybackStarted: (messageId: string) => void;
|
|
116
|
+
audioPlaybackComplete: (messageId: string) => void;
|
|
117
|
+
memoryUpdated: (event: MemoryUpdatedEvent) => void;
|
|
118
|
+
};
|
|
119
|
+
interface VoiceManager {
|
|
120
|
+
start(): Promise<void>;
|
|
121
|
+
stop(): Promise<void>;
|
|
122
|
+
toggleMute(): void;
|
|
123
|
+
readonly isMuted: boolean;
|
|
124
|
+
readonly isActive: boolean;
|
|
125
|
+
dispose(): void;
|
|
126
|
+
}
|
|
127
|
+
interface MemoryListOptions {
|
|
128
|
+
memoryType?: string;
|
|
129
|
+
status?: string;
|
|
130
|
+
limit?: number;
|
|
131
|
+
offset?: number;
|
|
132
|
+
sortBy?: 'created_at' | 'confidence' | 'last_accessed_at';
|
|
133
|
+
sortOrder?: 'asc' | 'desc';
|
|
134
|
+
}
|
|
135
|
+
interface MemoryTimelineOptions {
|
|
136
|
+
startDate?: string;
|
|
137
|
+
endDate?: string;
|
|
138
|
+
groupBy?: 'day' | 'week' | 'month';
|
|
139
|
+
}
|
|
140
|
+
interface MemoryGraphOptions {
|
|
141
|
+
includeEntities?: boolean;
|
|
142
|
+
includeCharacterMemories?: boolean;
|
|
143
|
+
}
|
|
144
|
+
interface MemorySearchOptions {
|
|
145
|
+
query: string;
|
|
146
|
+
limit?: number;
|
|
147
|
+
}
|
|
148
|
+
interface MemoryListResponse {
|
|
149
|
+
memories: Record<string, unknown>[];
|
|
150
|
+
total: number;
|
|
151
|
+
limit: number;
|
|
152
|
+
offset: number;
|
|
153
|
+
}
|
|
154
|
+
interface MemoryTimelineResponse {
|
|
155
|
+
timeline: {
|
|
156
|
+
date: string;
|
|
157
|
+
memories: Record<string, unknown>[];
|
|
158
|
+
}[];
|
|
159
|
+
totalMemories: number;
|
|
160
|
+
groupBy: string;
|
|
161
|
+
}
|
|
162
|
+
interface MemoryStatsResponse {
|
|
163
|
+
[key: string]: unknown;
|
|
164
|
+
}
|
|
165
|
+
interface MemoryGraphResponse {
|
|
166
|
+
nodes: Record<string, unknown>[];
|
|
167
|
+
edges: Record<string, unknown>[];
|
|
168
|
+
stats: Record<string, unknown>;
|
|
169
|
+
}
|
|
170
|
+
interface MemorySearchResponse {
|
|
171
|
+
results: {
|
|
172
|
+
memory: Record<string, unknown>;
|
|
173
|
+
score: number;
|
|
174
|
+
similarityScore: number;
|
|
175
|
+
}[];
|
|
176
|
+
query: string;
|
|
177
|
+
total: number;
|
|
178
|
+
}
|
|
179
|
+
interface CoreFactsResponse {
|
|
180
|
+
coreFacts: Record<string, unknown>[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare class RestClient {
|
|
184
|
+
private baseUrl;
|
|
185
|
+
private apiKey;
|
|
186
|
+
constructor(baseUrl: string, apiKey: string);
|
|
187
|
+
get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
188
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
189
|
+
delete<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
190
|
+
dispose(): void;
|
|
191
|
+
private buildUrl;
|
|
192
|
+
private request;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare class MemoryClient {
|
|
196
|
+
private rest;
|
|
197
|
+
private basePath;
|
|
198
|
+
constructor(rest: RestClient, agentId: string, playerId: string);
|
|
199
|
+
getMemories(options?: MemoryListOptions): Promise<MemoryListResponse>;
|
|
200
|
+
getTimeline(options?: MemoryTimelineOptions): Promise<MemoryTimelineResponse>;
|
|
201
|
+
getStats(): Promise<MemoryStatsResponse>;
|
|
202
|
+
getCoreFacts(): Promise<CoreFactsResponse>;
|
|
203
|
+
getGraph(options?: MemoryGraphOptions): Promise<MemoryGraphResponse>;
|
|
204
|
+
search(query: string, limit?: number): Promise<MemorySearchResponse>;
|
|
205
|
+
deleteAll(confirm: boolean): Promise<{
|
|
206
|
+
message: string;
|
|
207
|
+
deletedCount: number;
|
|
208
|
+
}>;
|
|
209
|
+
dispose(): void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare class TypedEventEmitter<T extends Record<string, unknown>> {
|
|
213
|
+
private listeners;
|
|
214
|
+
private onceListeners;
|
|
215
|
+
on<K extends keyof T>(event: K, listener: T[K]): this;
|
|
216
|
+
off<K extends keyof T>(event: K, listener: T[K]): this;
|
|
217
|
+
once<K extends keyof T>(event: K, listener: T[K]): this;
|
|
218
|
+
protected emit<K extends keyof T>(event: K, ...args: T[K] extends (...a: infer A) => void ? A : never[]): boolean;
|
|
219
|
+
removeAllListeners<K extends keyof T>(event?: K): this;
|
|
220
|
+
listenerCount<K extends keyof T>(event: K): number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare class EstuaryClient extends TypedEventEmitter<EstuaryEventMap> {
|
|
224
|
+
private config;
|
|
225
|
+
private logger;
|
|
226
|
+
private socketManager;
|
|
227
|
+
private voiceManager;
|
|
228
|
+
private audioPlayer;
|
|
229
|
+
private _memory;
|
|
230
|
+
private _sessionInfo;
|
|
231
|
+
constructor(config: EstuaryConfig);
|
|
232
|
+
/** Memory API client for querying memories, graphs, and facts */
|
|
233
|
+
get memory(): MemoryClient;
|
|
234
|
+
/** Current session info (null if not connected) */
|
|
235
|
+
get session(): SessionInfo | null;
|
|
236
|
+
/** Current connection state */
|
|
237
|
+
get connectionState(): ConnectionState;
|
|
238
|
+
/** Whether the client is connected and authenticated */
|
|
239
|
+
get isConnected(): boolean;
|
|
240
|
+
/** Connect to the Estuary server and authenticate */
|
|
241
|
+
connect(): Promise<SessionInfo>;
|
|
242
|
+
/** Disconnect from the server */
|
|
243
|
+
disconnect(): void;
|
|
244
|
+
/** Send a text message to the character */
|
|
245
|
+
sendText(text: string, textOnly?: boolean): void;
|
|
246
|
+
/** Interrupt the current bot response */
|
|
247
|
+
interrupt(messageId?: string): void;
|
|
248
|
+
/** Send a camera image for vision processing */
|
|
249
|
+
sendCameraImage(imageBase64: string, mimeType: string, requestId?: string, text?: string): void;
|
|
250
|
+
/** Update session preferences */
|
|
251
|
+
updatePreferences(preferences: {
|
|
252
|
+
enableVisionAcknowledgment?: boolean;
|
|
253
|
+
}): void;
|
|
254
|
+
/** Notify server that audio playback completed for a message */
|
|
255
|
+
notifyAudioPlaybackComplete(messageId?: string): void;
|
|
256
|
+
/** Start voice input (requests microphone permission) */
|
|
257
|
+
startVoice(): Promise<void>;
|
|
258
|
+
/** Stop voice input */
|
|
259
|
+
stopVoice(): void;
|
|
260
|
+
/** Toggle microphone mute */
|
|
261
|
+
toggleMute(): void;
|
|
262
|
+
/** Whether the microphone is muted */
|
|
263
|
+
get isMuted(): boolean;
|
|
264
|
+
/** Whether voice is currently active */
|
|
265
|
+
get isVoiceActive(): boolean;
|
|
266
|
+
private ensureConnected;
|
|
267
|
+
private forwardSocketEvents;
|
|
268
|
+
private handleBotVoice;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
declare enum ErrorCode {
|
|
272
|
+
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
273
|
+
AUTH_FAILED = "AUTH_FAILED",
|
|
274
|
+
CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT",
|
|
275
|
+
QUOTA_EXCEEDED = "QUOTA_EXCEEDED",
|
|
276
|
+
VOICE_NOT_SUPPORTED = "VOICE_NOT_SUPPORTED",
|
|
277
|
+
VOICE_ALREADY_ACTIVE = "VOICE_ALREADY_ACTIVE",
|
|
278
|
+
VOICE_NOT_ACTIVE = "VOICE_NOT_ACTIVE",
|
|
279
|
+
LIVEKIT_UNAVAILABLE = "LIVEKIT_UNAVAILABLE",
|
|
280
|
+
MICROPHONE_DENIED = "MICROPHONE_DENIED",
|
|
281
|
+
NOT_CONNECTED = "NOT_CONNECTED",
|
|
282
|
+
REST_ERROR = "REST_ERROR",
|
|
283
|
+
UNKNOWN = "UNKNOWN"
|
|
284
|
+
}
|
|
285
|
+
declare class EstuaryError extends Error {
|
|
286
|
+
readonly code: ErrorCode;
|
|
287
|
+
readonly details?: unknown;
|
|
288
|
+
constructor(code: ErrorCode, message: string, details?: unknown);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export { type BotResponse, type BotVoice, type CameraCaptureRequest, 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 QuotaExceededData, type SessionInfo, type SttResponse, type VoiceManager, type VoiceTransport };
|