@sovant/sdk 1.0.5 → 1.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.
@@ -0,0 +1,431 @@
1
+ /**
2
+ * HTTP Client for Sovant SDK - v1 Core
3
+ * Handles retries, timeouts, and error handling
4
+ */
5
+ interface HttpOptions {
6
+ method?: string;
7
+ headers?: Record<string, string>;
8
+ body?: any;
9
+ timeout?: number;
10
+ maxRetries?: number;
11
+ debug?: boolean;
12
+ }
13
+ interface HttpResponse<T = any> {
14
+ data: T;
15
+ status: number;
16
+ headers: Record<string, string>;
17
+ requestId?: string;
18
+ }
19
+ declare class HttpClient {
20
+ readonly baseUrl: string;
21
+ readonly apiKey: string;
22
+ private readonly globalOptions;
23
+ constructor(baseUrl: string, apiKey: string, globalOptions?: Partial<HttpOptions>);
24
+ request<T = any>(path: string, options?: HttpOptions): Promise<HttpResponse<T>>;
25
+ private makeRequest;
26
+ private calculateRetryDelay;
27
+ private sleep;
28
+ }
29
+
30
+ /**
31
+ * Sovant SDK Types - v1 Core
32
+ * Single source of truth - DO NOT DEVIATE
33
+ */
34
+ type MemoryType = 'journal' | 'insight' | 'observation' | 'task' | 'preference';
35
+ interface MemoryResponse {
36
+ id: string;
37
+ thread_id: string | null;
38
+ content: string;
39
+ type: MemoryType;
40
+ tags?: string[];
41
+ metadata?: Record<string, unknown>;
42
+ created_at: string;
43
+ updated_at: string;
44
+ }
45
+ interface CreateMemoryInput {
46
+ content: string;
47
+ type: MemoryType;
48
+ tags?: string[];
49
+ metadata?: Record<string, unknown>;
50
+ thread_id?: string;
51
+ }
52
+ interface UpdateMemoryInput {
53
+ content: string;
54
+ type: MemoryType;
55
+ tags?: string[];
56
+ metadata?: Record<string, unknown>;
57
+ is_archived?: boolean;
58
+ thread_id?: string | null;
59
+ }
60
+ interface PutMemoryInput extends CreateMemoryInput {
61
+ }
62
+ interface ListParams {
63
+ limit?: number;
64
+ offset?: number;
65
+ type?: MemoryType;
66
+ tags?: string[];
67
+ thread_id?: string;
68
+ is_archived?: boolean;
69
+ }
70
+ interface ListResponse {
71
+ memories: MemoryResponse[];
72
+ total: number;
73
+ limit: number;
74
+ offset: number;
75
+ has_more: boolean;
76
+ }
77
+ interface SearchParams {
78
+ query?: string;
79
+ type?: MemoryType;
80
+ tags?: string[];
81
+ from_date?: string;
82
+ to_date?: string;
83
+ limit?: number;
84
+ thread_id?: string;
85
+ }
86
+ interface SearchHit extends MemoryResponse {
87
+ score: number;
88
+ }
89
+ interface SearchResponse {
90
+ results: SearchHit[];
91
+ }
92
+ type BatchOp = {
93
+ op: 'create';
94
+ data: CreateMemoryInput;
95
+ } | {
96
+ op: 'update';
97
+ id: string;
98
+ data: Partial<UpdateMemoryInput>;
99
+ } | {
100
+ op: 'delete';
101
+ id: string;
102
+ };
103
+ interface BatchRequest {
104
+ operations: BatchOp[];
105
+ }
106
+ interface BatchResult {
107
+ operation: 'create' | 'update' | 'delete';
108
+ index: number;
109
+ success: boolean;
110
+ id?: string;
111
+ data?: any;
112
+ error?: string;
113
+ }
114
+ interface BatchResponse {
115
+ results: BatchResult[];
116
+ summary: {
117
+ total: number;
118
+ successful: number;
119
+ failed: number;
120
+ operations: {
121
+ create: number;
122
+ update: number;
123
+ delete: number;
124
+ };
125
+ };
126
+ transaction_id: string;
127
+ }
128
+ interface CreateResponse extends MemoryResponse {
129
+ ok: true;
130
+ }
131
+ interface Thread {
132
+ id: string;
133
+ title: string | null;
134
+ metadata?: Record<string, unknown>;
135
+ created_at: string;
136
+ updated_at: string;
137
+ }
138
+ interface CreateThreadInput {
139
+ title?: string;
140
+ metadata?: Record<string, unknown>;
141
+ }
142
+ interface UpdateThreadInput {
143
+ title?: string;
144
+ metadata?: Record<string, unknown>;
145
+ }
146
+ interface ThreadListResponse {
147
+ threads: Thread[];
148
+ total: number;
149
+ limit: number;
150
+ offset: number;
151
+ has_more: boolean;
152
+ }
153
+ interface ThreadWithMemories extends Thread {
154
+ memories: {
155
+ items: MemoryResponse[];
156
+ total: number;
157
+ limit: number;
158
+ offset: number;
159
+ has_more: boolean;
160
+ };
161
+ }
162
+ interface LinkMemoryResponse {
163
+ ok: boolean;
164
+ thread_id: string;
165
+ memory_id: string;
166
+ }
167
+ interface DeleteResponse {
168
+ ok: true;
169
+ }
170
+ interface SovantConfig {
171
+ apiKey: string;
172
+ baseUrl?: string;
173
+ timeout?: number;
174
+ maxRetries?: number;
175
+ debug?: boolean;
176
+ }
177
+ interface Session {
178
+ id: string;
179
+ user_id: string;
180
+ title: string;
181
+ capture_enabled?: boolean;
182
+ use_memory?: boolean;
183
+ summary_data?: Record<string, any>;
184
+ created_at: string;
185
+ updated_at: string;
186
+ }
187
+ interface CreateSessionInput {
188
+ provider?: 'openai' | 'anthropic' | 'google';
189
+ model?: string;
190
+ title?: string;
191
+ }
192
+ interface Message {
193
+ id: string;
194
+ session_id: string;
195
+ role: 'user' | 'assistant' | 'system';
196
+ content: string;
197
+ provider?: string;
198
+ model?: string;
199
+ created_at: string;
200
+ }
201
+ interface SendMessageOptions {
202
+ provider?: string;
203
+ model?: string;
204
+ useMemory?: boolean;
205
+ captureToMemory?: boolean;
206
+ signal?: AbortSignal;
207
+ }
208
+ interface StreamEvent {
209
+ type: 'delta' | 'done' | 'error';
210
+ data?: string;
211
+ }
212
+ interface ApiKey {
213
+ id: string;
214
+ name: string;
215
+ key?: string;
216
+ prefix?: string;
217
+ created_at: string;
218
+ expires_at?: string;
219
+ last_used_at?: string;
220
+ }
221
+ interface UpdateKeyInput {
222
+ name?: string;
223
+ expires_at?: string;
224
+ }
225
+ type ProfileEntity = 'name' | 'age' | 'location' | 'preference';
226
+ interface ProfileExtraction {
227
+ entity: ProfileEntity | null;
228
+ value?: string;
229
+ }
230
+ interface ProfileFacts {
231
+ name?: string;
232
+ age?: string;
233
+ location?: string;
234
+ preferences?: string[];
235
+ }
236
+
237
+ /**
238
+ * Sovant SDK Error Classes - v1 Core
239
+ */
240
+ declare class SovantError extends Error {
241
+ readonly code?: string;
242
+ readonly status?: number;
243
+ readonly requestId?: string;
244
+ constructor(message: string, code?: string, status?: number, requestId?: string);
245
+ static fromResponse(status: number, body: any, requestId?: string): SovantError;
246
+ toJSON(): {
247
+ name: string;
248
+ message: string;
249
+ code: string | undefined;
250
+ status: number | undefined;
251
+ requestId: string | undefined;
252
+ };
253
+ }
254
+ declare class NetworkError extends SovantError {
255
+ constructor(message: string, cause?: Error);
256
+ }
257
+ declare class TimeoutError extends SovantError {
258
+ constructor(message?: string);
259
+ }
260
+
261
+ /**
262
+ * Sovant SDK - v1.1.0
263
+ * Universal Memory API for AI Applications
264
+ */
265
+
266
+ /**
267
+ * Main Sovant SDK Client
268
+ */
269
+ declare class Sovant {
270
+ private readonly http;
271
+ readonly memory: MemoryNamespace;
272
+ readonly threads: ThreadsNamespace;
273
+ readonly chat: ChatNamespace;
274
+ readonly keys: KeysNamespace;
275
+ readonly recall: RecallNamespace;
276
+ constructor(config: SovantConfig);
277
+ }
278
+ /**
279
+ * Memory namespace for all memory-related operations
280
+ */
281
+ declare class MemoryNamespace {
282
+ private readonly http;
283
+ constructor(http: HttpClient);
284
+ /**
285
+ * Create a new memory
286
+ */
287
+ create(input: CreateMemoryInput): Promise<MemoryResponse>;
288
+ /**
289
+ * List memories with optional filters
290
+ */
291
+ list(params?: ListParams): Promise<ListResponse>;
292
+ /**
293
+ * Get a specific memory by ID
294
+ */
295
+ get(id: string): Promise<MemoryResponse>;
296
+ /**
297
+ * Update a memory (partial update using PATCH)
298
+ */
299
+ update(id: string, patch: Partial<UpdateMemoryInput>): Promise<MemoryResponse>;
300
+ /**
301
+ * Replace a memory (full update using PUT)
302
+ */
303
+ put(id: string, body: PutMemoryInput): Promise<MemoryResponse>;
304
+ /**
305
+ * Delete a memory
306
+ */
307
+ delete(id: string): Promise<DeleteResponse>;
308
+ /**
309
+ * Search memories using semantic search or filters
310
+ */
311
+ search(params: SearchParams): Promise<SearchResponse>;
312
+ /**
313
+ * Execute batch operations atomically
314
+ */
315
+ batch(body: BatchRequest): Promise<BatchResponse>;
316
+ }
317
+ /**
318
+ * Threads namespace for all thread-related operations
319
+ */
320
+ declare class ThreadsNamespace {
321
+ private readonly http;
322
+ constructor(http: HttpClient);
323
+ /**
324
+ * Create a new thread
325
+ */
326
+ create(input?: CreateThreadInput): Promise<Thread>;
327
+ /**
328
+ * List threads with pagination
329
+ */
330
+ list(params?: {
331
+ limit?: number;
332
+ offset?: number;
333
+ }): Promise<ThreadListResponse>;
334
+ /**
335
+ * Get a thread by ID, optionally with memories
336
+ */
337
+ get(id: string, options?: {
338
+ includeMemories?: boolean;
339
+ limit?: number;
340
+ offset?: number;
341
+ }): Promise<Thread | ThreadWithMemories>;
342
+ /**
343
+ * Update a thread
344
+ */
345
+ update(id: string, input: UpdateThreadInput): Promise<Thread>;
346
+ /**
347
+ * Delete a thread (memories are unlinked, not deleted)
348
+ */
349
+ delete(id: string): Promise<{
350
+ ok: boolean;
351
+ unlinked_memories?: number;
352
+ }>;
353
+ /**
354
+ * Link a memory to a thread
355
+ */
356
+ linkMemory(threadId: string, memoryId: string): Promise<LinkMemoryResponse>;
357
+ }
358
+ /**
359
+ * Chat namespace for session and messaging operations
360
+ */
361
+ declare class ChatNamespace {
362
+ private readonly http;
363
+ constructor(http: HttpClient);
364
+ /**
365
+ * Create a new chat session
366
+ */
367
+ createSession(input?: CreateSessionInput): Promise<Session>;
368
+ /**
369
+ * Get a chat session by ID
370
+ */
371
+ getSession(sessionId: string): Promise<Session>;
372
+ /**
373
+ * List chat sessions
374
+ */
375
+ listSessions(params?: {
376
+ limit?: number;
377
+ offset?: number;
378
+ }): Promise<Session[]>;
379
+ /**
380
+ * Get messages for a session
381
+ */
382
+ getMessages(sessionId: string, limit?: number): Promise<Message[]>;
383
+ /**
384
+ * Send a message with SSE streaming
385
+ */
386
+ sendMessage(sessionId: string, message: string, opts?: SendMessageOptions): AsyncGenerator<StreamEvent, void, unknown>;
387
+ }
388
+ /**
389
+ * Keys namespace for API key management
390
+ */
391
+ declare class KeysNamespace {
392
+ private readonly http;
393
+ constructor(http: HttpClient);
394
+ /**
395
+ * List API keys
396
+ */
397
+ list(): Promise<ApiKey[]>;
398
+ /**
399
+ * Create a new API key
400
+ */
401
+ create(name: string): Promise<ApiKey>;
402
+ /**
403
+ * Update an API key
404
+ */
405
+ update(id: string, patch: UpdateKeyInput): Promise<ApiKey>;
406
+ /**
407
+ * Revoke an API key
408
+ */
409
+ revoke(id: string): Promise<void>;
410
+ }
411
+ /**
412
+ * Recall namespace for profile extraction and facts
413
+ */
414
+ declare class RecallNamespace {
415
+ private readonly http;
416
+ constructor(http: HttpClient);
417
+ /**
418
+ * Extract profile entity from text (client-side)
419
+ */
420
+ extractProfile(text: string): ProfileExtraction;
421
+ /**
422
+ * Get profile facts from memories
423
+ */
424
+ getProfileFacts(): Promise<ProfileFacts>;
425
+ /**
426
+ * Save a profile fact in canonical form
427
+ */
428
+ saveProfileFact(kind: ProfileEntity, value: string): Promise<MemoryResponse>;
429
+ }
430
+
431
+ export { type ApiKey, type BatchOp, type BatchRequest, type BatchResponse, type BatchResult, type CreateMemoryInput, type CreateResponse, type CreateSessionInput, type CreateThreadInput, type DeleteResponse, type LinkMemoryResponse, type ListParams, type ListResponse, type MemoryResponse, type MemoryType, type Message, NetworkError, type ProfileEntity, type ProfileExtraction, type ProfileFacts, type PutMemoryInput, type SearchHit, type SearchParams, type SearchResponse, type SendMessageOptions, type Session, Sovant, type SovantConfig, SovantError, type StreamEvent, type Thread, type ThreadListResponse, type ThreadWithMemories, TimeoutError, type UpdateKeyInput, type UpdateMemoryInput, type UpdateThreadInput, Sovant as default };