@sovant/sdk 1.1.1 → 1.2.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/dist/index.d.ts CHANGED
@@ -1,433 +1,108 @@
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 {
1
+ export type SovantClientOptions = {
171
2
  apiKey: string;
172
3
  baseUrl?: string;
173
- timeout?: number;
4
+ timeoutMs?: number;
174
5
  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;
6
+ retryDelay?: number;
7
+ onRequest?: (req: {
8
+ method: string;
9
+ path: string;
10
+ body?: any;
11
+ }) => void;
12
+ onResponse?: (res: {
13
+ method: string;
14
+ path: string;
15
+ status: number;
16
+ duration: number;
17
+ }) => void;
18
+ onError?: (err: SovantError) => void;
19
+ };
20
+ export declare class Sovant {
21
+ private apiKey;
22
+ private baseUrl;
23
+ private timeout;
24
+ private maxRetries;
25
+ private retryDelay;
26
+ private onRequest?;
27
+ private onResponse?;
28
+ private onError?;
29
+ constructor(opts: SovantClientOptions);
30
+ private req;
31
+ memory: {
32
+ create: <T = any>(input: {
33
+ data: T;
34
+ type?: "journal" | "insight" | "observation" | "task" | "preference";
35
+ ttl?: string;
36
+ tags?: string[];
37
+ metadata?: Record<string, any>;
38
+ thread_id?: string;
39
+ }) => Promise<unknown>;
40
+ get: (id: string) => Promise<unknown>;
41
+ search: (q: {
42
+ query?: string;
43
+ type?: string;
44
+ tags?: string[];
45
+ thread_id?: string;
46
+ limit?: number;
47
+ from_date?: string;
48
+ to_date?: string;
49
+ }) => Promise<unknown>;
50
+ update: <T = any>(id: string, patch: Partial<{
51
+ data: T;
52
+ type?: string;
53
+ ttl?: string;
54
+ tags?: string[];
55
+ metadata?: Record<string, any>;
56
+ }>) => Promise<unknown>;
57
+ delete: (id: string) => Promise<unknown>;
58
+ /**
59
+ * Batch create multiple memories in a single request
60
+ * @param memories Array of memory objects to create (max 100)
61
+ * @returns BatchResponse with individual results
62
+ */
63
+ createBatch: <T = any>(memories: Array<{
64
+ data: T;
65
+ type?: "journal" | "insight" | "observation" | "task" | "preference";
66
+ tags?: string[];
67
+ metadata?: Record<string, any>;
68
+ thread_id?: string;
69
+ }>) => Promise<{
70
+ results: Array<{
71
+ success: boolean;
72
+ operation: string;
73
+ id?: string;
74
+ error?: {
75
+ code: string;
76
+ message: string;
77
+ };
78
+ index: number;
79
+ }>;
80
+ summary: {
81
+ total: number;
82
+ successful: number;
83
+ failed: number;
84
+ };
85
+ transaction_id: string;
86
+ }>;
87
+ /**
88
+ * Semantic search alias for search()
89
+ * Provides a more intuitive name for vector similarity search
90
+ */
91
+ recall: (q: {
92
+ query?: string;
93
+ type?: string;
94
+ tags?: string[];
95
+ thread_id?: string;
96
+ limit?: number;
97
+ from_date?: string;
98
+ to_date?: string;
99
+ }) => Promise<unknown>;
254
100
  };
255
101
  }
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>;
102
+ export declare class SovantError extends Error {
103
+ code: string;
104
+ status?: number;
105
+ details?: any;
106
+ constructor(message: string, code: string, status?: number, details?: any);
431
107
  }
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 };
108
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAA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