@sovant/sdk 1.0.5 → 1.1.1

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.ts CHANGED
@@ -1,47 +1,433 @@
1
- export type SovantClientOptions = {
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 {
2
171
  apiKey: string;
3
172
  baseUrl?: string;
4
- timeoutMs?: number;
5
- };
6
- export declare class Sovant {
7
- private apiKey;
8
- private baseUrl;
9
- private timeout;
10
- constructor(opts: SovantClientOptions);
11
- private req;
12
- memory: {
13
- create: <T = any>(input: {
14
- data: T;
15
- type?: "journal" | "insight" | "observation" | "task" | "preference";
16
- ttl?: string;
17
- tags?: string[];
18
- metadata?: Record<string, any>;
19
- thread_id?: string;
20
- }) => Promise<unknown>;
21
- get: (id: string) => Promise<unknown>;
22
- search: (q: {
23
- query?: string;
24
- type?: string;
25
- tags?: string[];
26
- thread_id?: string;
27
- limit?: number;
28
- from_date?: string;
29
- to_date?: string;
30
- }) => Promise<unknown>;
31
- update: <T = any>(id: string, patch: Partial<{
32
- data: T;
33
- type?: string;
34
- ttl?: string;
35
- tags?: string[];
36
- metadata?: Record<string, any>;
37
- }>) => Promise<unknown>;
38
- delete: (id: string) => Promise<unknown>;
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
+ message?: string;
203
+ provider?: string;
204
+ model?: string;
205
+ useMemory?: boolean;
206
+ captureToMemory?: boolean;
207
+ stream?: boolean;
208
+ signal?: AbortSignal;
209
+ }
210
+ interface StreamEvent {
211
+ type: 'delta' | 'done' | 'error';
212
+ data?: string;
213
+ }
214
+ interface ApiKey {
215
+ id: string;
216
+ name: string;
217
+ key?: string;
218
+ prefix?: string;
219
+ created_at: string;
220
+ expires_at?: string;
221
+ last_used_at?: string;
222
+ }
223
+ interface UpdateKeyInput {
224
+ name?: string;
225
+ expires_at?: string;
226
+ }
227
+ type ProfileEntity = 'name' | 'age' | 'location' | 'preference';
228
+ interface ProfileExtraction {
229
+ entity: ProfileEntity | null;
230
+ value?: string;
231
+ }
232
+ interface ProfileFacts {
233
+ name?: string;
234
+ age?: string;
235
+ location?: string;
236
+ preferences?: string[];
237
+ }
238
+
239
+ /**
240
+ * Sovant SDK Error Classes - v1 Core
241
+ */
242
+ declare class SovantError extends Error {
243
+ readonly code?: string;
244
+ readonly status?: number;
245
+ readonly requestId?: string;
246
+ constructor(message: string, code?: string, status?: number, requestId?: string);
247
+ static fromResponse(status: number, body: any, requestId?: string): SovantError;
248
+ toJSON(): {
249
+ name: string;
250
+ message: string;
251
+ code: string | undefined;
252
+ status: number | undefined;
253
+ requestId: string | undefined;
39
254
  };
40
255
  }
41
- export declare class SovantError extends Error {
42
- code: string;
43
- status?: number;
44
- details?: any;
45
- constructor(message: string, code: string, status?: number, details?: any);
256
+ declare class NetworkError extends SovantError {
257
+ constructor(message: string, cause?: Error);
258
+ }
259
+ declare class TimeoutError extends SovantError {
260
+ constructor(message?: string);
261
+ }
262
+
263
+ /**
264
+ * Sovant SDK - v1.1.0
265
+ * Universal Memory API for AI Applications
266
+ */
267
+
268
+ /**
269
+ * Main Sovant SDK Client
270
+ */
271
+ declare class Sovant {
272
+ private readonly http;
273
+ readonly memory: MemoryNamespace;
274
+ readonly threads: ThreadsNamespace;
275
+ readonly chat: ChatNamespace;
276
+ readonly keys: KeysNamespace;
277
+ readonly recall: RecallNamespace;
278
+ constructor(config: SovantConfig);
279
+ }
280
+ /**
281
+ * Memory namespace for all memory-related operations
282
+ */
283
+ declare class MemoryNamespace {
284
+ private readonly http;
285
+ constructor(http: HttpClient);
286
+ /**
287
+ * Create a new memory
288
+ */
289
+ create(input: CreateMemoryInput): Promise<MemoryResponse>;
290
+ /**
291
+ * List memories with optional filters
292
+ */
293
+ list(params?: ListParams): Promise<ListResponse>;
294
+ /**
295
+ * Get a specific memory by ID
296
+ */
297
+ get(id: string): Promise<MemoryResponse>;
298
+ /**
299
+ * Update a memory (partial update using PATCH)
300
+ */
301
+ update(id: string, patch: Partial<UpdateMemoryInput>): Promise<MemoryResponse>;
302
+ /**
303
+ * Replace a memory (full update using PUT)
304
+ */
305
+ put(id: string, body: PutMemoryInput): Promise<MemoryResponse>;
306
+ /**
307
+ * Delete a memory
308
+ */
309
+ delete(id: string): Promise<DeleteResponse>;
310
+ /**
311
+ * Search memories using semantic search or filters
312
+ */
313
+ search(params: SearchParams): Promise<SearchResponse>;
314
+ /**
315
+ * Execute batch operations atomically
316
+ */
317
+ batch(body: BatchRequest): Promise<BatchResponse>;
318
+ }
319
+ /**
320
+ * Threads namespace for all thread-related operations
321
+ */
322
+ declare class ThreadsNamespace {
323
+ private readonly http;
324
+ constructor(http: HttpClient);
325
+ /**
326
+ * Create a new thread
327
+ */
328
+ create(input?: CreateThreadInput): Promise<Thread>;
329
+ /**
330
+ * List threads with pagination
331
+ */
332
+ list(params?: {
333
+ limit?: number;
334
+ offset?: number;
335
+ }): Promise<ThreadListResponse>;
336
+ /**
337
+ * Get a thread by ID, optionally with memories
338
+ */
339
+ get(id: string, options?: {
340
+ includeMemories?: boolean;
341
+ limit?: number;
342
+ offset?: number;
343
+ }): Promise<Thread | ThreadWithMemories>;
344
+ /**
345
+ * Update a thread
346
+ */
347
+ update(id: string, input: UpdateThreadInput): Promise<Thread>;
348
+ /**
349
+ * Delete a thread (memories are unlinked, not deleted)
350
+ */
351
+ delete(id: string): Promise<{
352
+ ok: boolean;
353
+ unlinked_memories?: number;
354
+ }>;
355
+ /**
356
+ * Link a memory to a thread
357
+ */
358
+ linkMemory(threadId: string, memoryId: string): Promise<LinkMemoryResponse>;
359
+ }
360
+ /**
361
+ * Chat namespace for session and messaging operations
362
+ */
363
+ declare class ChatNamespace {
364
+ private readonly http;
365
+ constructor(http: HttpClient);
366
+ /**
367
+ * Create a new chat session
368
+ */
369
+ createSession(input?: CreateSessionInput): Promise<Session>;
370
+ /**
371
+ * Get a chat session by ID
372
+ */
373
+ getSession(sessionId: string): Promise<Session>;
374
+ /**
375
+ * List chat sessions
376
+ */
377
+ listSessions(params?: {
378
+ limit?: number;
379
+ offset?: number;
380
+ }): Promise<Session[]>;
381
+ /**
382
+ * Get messages for a session
383
+ */
384
+ getMessages(sessionId: string, limit?: number): Promise<Message[]>;
385
+ /**
386
+ * Send a message with SSE streaming
387
+ */
388
+ sendMessage(sessionId: string, message: string | SendMessageOptions, opts?: SendMessageOptions): AsyncGenerator<StreamEvent, void, unknown>;
389
+ }
390
+ /**
391
+ * Keys namespace for API key management
392
+ */
393
+ declare class KeysNamespace {
394
+ private readonly http;
395
+ constructor(http: HttpClient);
396
+ /**
397
+ * List API keys
398
+ */
399
+ list(): Promise<ApiKey[]>;
400
+ /**
401
+ * Create a new API key
402
+ */
403
+ create(name: string): Promise<ApiKey>;
404
+ /**
405
+ * Update an API key
406
+ */
407
+ update(id: string, patch: UpdateKeyInput): Promise<ApiKey>;
408
+ /**
409
+ * Revoke an API key
410
+ */
411
+ revoke(id: string): Promise<void>;
412
+ }
413
+ /**
414
+ * Recall namespace for profile extraction and facts
415
+ */
416
+ declare class RecallNamespace {
417
+ private readonly http;
418
+ constructor(http: HttpClient);
419
+ /**
420
+ * Extract profile entity from text (client-side)
421
+ */
422
+ extractProfile(text: string): ProfileExtraction;
423
+ /**
424
+ * Get profile facts from memories
425
+ */
426
+ getProfileFacts(): Promise<ProfileFacts>;
427
+ /**
428
+ * Save a profile fact in canonical form
429
+ */
430
+ saveProfileFact(kind: ProfileEntity, value: string): Promise<MemoryResponse>;
46
431
  }
47
- //# sourceMappingURL=index.d.ts.map
432
+
433
+ 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 };