@sovant/sdk 1.0.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 +370 -0
- package/dist/index.d.mts +369 -0
- package/dist/index.d.ts +369 -0
- package/dist/index.js +463 -0
- package/dist/index.mjs +430 -0
- package/package.json +56 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
interface SovantConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
retryDelay?: number;
|
|
7
|
+
}
|
|
8
|
+
interface Memory {
|
|
9
|
+
id: string;
|
|
10
|
+
content: string;
|
|
11
|
+
type: MemoryType;
|
|
12
|
+
importance: number;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at?: string;
|
|
15
|
+
user_id?: string;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
tags?: string[];
|
|
18
|
+
emotion?: EmotionalContext;
|
|
19
|
+
decisions?: string[];
|
|
20
|
+
questions?: string[];
|
|
21
|
+
action_items?: string[];
|
|
22
|
+
follow_up_required?: boolean;
|
|
23
|
+
follow_up_due?: string;
|
|
24
|
+
is_pinned?: boolean;
|
|
25
|
+
is_archived?: boolean;
|
|
26
|
+
title?: string;
|
|
27
|
+
thread_ids?: string[];
|
|
28
|
+
}
|
|
29
|
+
type MemoryType = "observation" | "reflection" | "decision" | "emotion" | "learning" | "preference" | "event" | "conversation" | "task" | "reminder" | "question" | "insight" | "journal" | "routine" | "meta";
|
|
30
|
+
interface EmotionalContext {
|
|
31
|
+
type: EmotionType;
|
|
32
|
+
intensity?: number;
|
|
33
|
+
toneTags?: string[];
|
|
34
|
+
}
|
|
35
|
+
type EmotionType = "neutral" | "happy" | "excited" | "anxious" | "sad" | "stressed" | "calm" | "reflective" | "positive" | "negative";
|
|
36
|
+
interface CreateMemoryInput {
|
|
37
|
+
content: string;
|
|
38
|
+
type?: MemoryType;
|
|
39
|
+
importance?: number;
|
|
40
|
+
metadata?: Record<string, any>;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
emotion?: EmotionalContext;
|
|
43
|
+
decisions?: string[];
|
|
44
|
+
questions?: string[];
|
|
45
|
+
action_items?: string[];
|
|
46
|
+
follow_up_required?: boolean;
|
|
47
|
+
follow_up_due?: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
thread_ids?: string[];
|
|
50
|
+
}
|
|
51
|
+
interface UpdateMemoryInput extends Partial<CreateMemoryInput> {
|
|
52
|
+
is_pinned?: boolean;
|
|
53
|
+
is_archived?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface SearchOptions {
|
|
56
|
+
query: string;
|
|
57
|
+
limit?: number;
|
|
58
|
+
offset?: number;
|
|
59
|
+
type?: MemoryType | MemoryType[];
|
|
60
|
+
tags?: string[];
|
|
61
|
+
created_after?: string;
|
|
62
|
+
created_before?: string;
|
|
63
|
+
search_type?: "semantic" | "keyword" | "hybrid";
|
|
64
|
+
include_archived?: boolean;
|
|
65
|
+
metadata_filters?: Record<string, any>;
|
|
66
|
+
sort_by?: "relevance" | "created_at" | "importance";
|
|
67
|
+
sort_order?: "asc" | "desc";
|
|
68
|
+
}
|
|
69
|
+
interface SearchResult extends Memory {
|
|
70
|
+
relevance_score: number;
|
|
71
|
+
highlights?: string[];
|
|
72
|
+
}
|
|
73
|
+
interface Thread {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
memory_ids: string[];
|
|
78
|
+
status: "active" | "archived" | "completed";
|
|
79
|
+
metadata?: Record<string, any>;
|
|
80
|
+
tags?: string[];
|
|
81
|
+
created_at: string;
|
|
82
|
+
updated_at: string;
|
|
83
|
+
last_activity_at: string;
|
|
84
|
+
user_id?: string;
|
|
85
|
+
}
|
|
86
|
+
interface CreateThreadInput {
|
|
87
|
+
name: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
memory_ids?: string[];
|
|
90
|
+
metadata?: Record<string, any>;
|
|
91
|
+
tags?: string[];
|
|
92
|
+
status?: "active" | "archived" | "completed";
|
|
93
|
+
}
|
|
94
|
+
interface UpdateThreadInput extends Partial<CreateThreadInput> {
|
|
95
|
+
}
|
|
96
|
+
interface ThreadStats {
|
|
97
|
+
memory_count: number;
|
|
98
|
+
memory_types: Record<string, number>;
|
|
99
|
+
emotion_types: Record<string, number>;
|
|
100
|
+
avg_importance: number;
|
|
101
|
+
follow_up_count: number;
|
|
102
|
+
earliest_memory: string;
|
|
103
|
+
latest_memory: string;
|
|
104
|
+
total_decisions: number;
|
|
105
|
+
total_questions: number;
|
|
106
|
+
total_action_items: number;
|
|
107
|
+
}
|
|
108
|
+
interface BatchCreateResult {
|
|
109
|
+
success: Memory[];
|
|
110
|
+
failed: Array<{
|
|
111
|
+
index: number;
|
|
112
|
+
error: string;
|
|
113
|
+
}>;
|
|
114
|
+
success_count: number;
|
|
115
|
+
failed_count: number;
|
|
116
|
+
}
|
|
117
|
+
interface PaginatedResponse<T> {
|
|
118
|
+
data: T[];
|
|
119
|
+
total: number;
|
|
120
|
+
limit: number;
|
|
121
|
+
offset: number;
|
|
122
|
+
has_more: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface APIError {
|
|
125
|
+
error: string;
|
|
126
|
+
message: string;
|
|
127
|
+
status_code: number;
|
|
128
|
+
details?: Record<string, any>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare class BaseClient {
|
|
132
|
+
protected config: Required<SovantConfig>;
|
|
133
|
+
constructor(config: SovantConfig);
|
|
134
|
+
protected request<T>(method: string, path: string, data?: any, retryCount?: number): Promise<T>;
|
|
135
|
+
private handleErrorResponse;
|
|
136
|
+
private delay;
|
|
137
|
+
protected buildQueryString(params: Record<string, any>): string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare class Memories extends BaseClient {
|
|
141
|
+
/**
|
|
142
|
+
* Create a new memory
|
|
143
|
+
*/
|
|
144
|
+
create(data: CreateMemoryInput): Promise<Memory>;
|
|
145
|
+
/**
|
|
146
|
+
* Get a memory by ID
|
|
147
|
+
*/
|
|
148
|
+
get(id: string): Promise<Memory>;
|
|
149
|
+
/**
|
|
150
|
+
* Update a memory
|
|
151
|
+
*/
|
|
152
|
+
update(id: string, data: UpdateMemoryInput): Promise<Memory>;
|
|
153
|
+
/**
|
|
154
|
+
* Delete a memory
|
|
155
|
+
*/
|
|
156
|
+
delete(id: string): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* List memories with pagination
|
|
159
|
+
*/
|
|
160
|
+
list(options?: {
|
|
161
|
+
limit?: number;
|
|
162
|
+
offset?: number;
|
|
163
|
+
type?: string | string[];
|
|
164
|
+
tags?: string[];
|
|
165
|
+
is_archived?: boolean;
|
|
166
|
+
sort_by?: "created_at" | "importance" | "updated_at";
|
|
167
|
+
sort_order?: "asc" | "desc";
|
|
168
|
+
}): Promise<PaginatedResponse<Memory>>;
|
|
169
|
+
/**
|
|
170
|
+
* Search memories
|
|
171
|
+
*/
|
|
172
|
+
search(options: SearchOptions): Promise<SearchResult[]>;
|
|
173
|
+
/**
|
|
174
|
+
* Batch create memories
|
|
175
|
+
*/
|
|
176
|
+
createBatch(memories: CreateMemoryInput[]): Promise<BatchCreateResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Batch delete memories
|
|
179
|
+
*/
|
|
180
|
+
deleteBatch(ids: string[]): Promise<{
|
|
181
|
+
deleted: number;
|
|
182
|
+
}>;
|
|
183
|
+
/**
|
|
184
|
+
* Get memory insights and analytics
|
|
185
|
+
*/
|
|
186
|
+
getInsights(options?: {
|
|
187
|
+
time_range?: "last_7_days" | "last_30_days" | "last_90_days" | "all_time";
|
|
188
|
+
group_by?: "type" | "emotion" | "date";
|
|
189
|
+
}): Promise<{
|
|
190
|
+
total_count: number;
|
|
191
|
+
type_distribution: Record<string, number>;
|
|
192
|
+
emotion_distribution: Record<string, number>;
|
|
193
|
+
importance_stats: {
|
|
194
|
+
avg: number;
|
|
195
|
+
min: number;
|
|
196
|
+
max: number;
|
|
197
|
+
};
|
|
198
|
+
growth_rate: number;
|
|
199
|
+
most_common_tags: Array<{
|
|
200
|
+
tag: string;
|
|
201
|
+
count: number;
|
|
202
|
+
}>;
|
|
203
|
+
}>;
|
|
204
|
+
/**
|
|
205
|
+
* Archive a memory
|
|
206
|
+
*/
|
|
207
|
+
archive(id: string): Promise<Memory>;
|
|
208
|
+
/**
|
|
209
|
+
* Unarchive a memory
|
|
210
|
+
*/
|
|
211
|
+
unarchive(id: string): Promise<Memory>;
|
|
212
|
+
/**
|
|
213
|
+
* Pin a memory
|
|
214
|
+
*/
|
|
215
|
+
pin(id: string): Promise<Memory>;
|
|
216
|
+
/**
|
|
217
|
+
* Unpin a memory
|
|
218
|
+
*/
|
|
219
|
+
unpin(id: string): Promise<Memory>;
|
|
220
|
+
/**
|
|
221
|
+
* Get related memories
|
|
222
|
+
*/
|
|
223
|
+
getRelated(id: string, options?: {
|
|
224
|
+
limit?: number;
|
|
225
|
+
threshold?: number;
|
|
226
|
+
}): Promise<SearchResult[]>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare class Threads extends BaseClient {
|
|
230
|
+
/**
|
|
231
|
+
* Create a new thread
|
|
232
|
+
*/
|
|
233
|
+
create(data: CreateThreadInput): Promise<Thread>;
|
|
234
|
+
/**
|
|
235
|
+
* Get a thread by ID
|
|
236
|
+
*/
|
|
237
|
+
get(id: string, includeMemories?: boolean): Promise<Thread & {
|
|
238
|
+
memories?: Memory[];
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* Update a thread
|
|
242
|
+
*/
|
|
243
|
+
update(id: string, data: UpdateThreadInput): Promise<Thread>;
|
|
244
|
+
/**
|
|
245
|
+
* Delete a thread
|
|
246
|
+
*/
|
|
247
|
+
delete(id: string, deleteMemories?: boolean): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* List threads with pagination
|
|
250
|
+
*/
|
|
251
|
+
list(options?: {
|
|
252
|
+
limit?: number;
|
|
253
|
+
offset?: number;
|
|
254
|
+
status?: "active" | "archived" | "completed";
|
|
255
|
+
tags?: string[];
|
|
256
|
+
sort_by?: "created_at" | "updated_at" | "last_activity_at" | "name";
|
|
257
|
+
sort_order?: "asc" | "desc";
|
|
258
|
+
}): Promise<PaginatedResponse<Thread>>;
|
|
259
|
+
/**
|
|
260
|
+
* Add memories to a thread
|
|
261
|
+
*/
|
|
262
|
+
addMemories(id: string, memoryIds: string[]): Promise<Thread>;
|
|
263
|
+
/**
|
|
264
|
+
* Remove memories from a thread
|
|
265
|
+
*/
|
|
266
|
+
removeMemories(id: string, memoryIds: string[]): Promise<Thread>;
|
|
267
|
+
/**
|
|
268
|
+
* Get memories in a thread
|
|
269
|
+
*/
|
|
270
|
+
getMemories(id: string, options?: {
|
|
271
|
+
limit?: number;
|
|
272
|
+
offset?: number;
|
|
273
|
+
type?: string | string[];
|
|
274
|
+
sort_by?: "created_at" | "importance";
|
|
275
|
+
sort_order?: "asc" | "desc";
|
|
276
|
+
}): Promise<PaginatedResponse<Memory>>;
|
|
277
|
+
/**
|
|
278
|
+
* Get thread statistics
|
|
279
|
+
*/
|
|
280
|
+
getStats(id: string): Promise<ThreadStats>;
|
|
281
|
+
/**
|
|
282
|
+
* Archive a thread
|
|
283
|
+
*/
|
|
284
|
+
archive(id: string): Promise<Thread>;
|
|
285
|
+
/**
|
|
286
|
+
* Unarchive a thread
|
|
287
|
+
*/
|
|
288
|
+
unarchive(id: string): Promise<Thread>;
|
|
289
|
+
/**
|
|
290
|
+
* Complete a thread
|
|
291
|
+
*/
|
|
292
|
+
complete(id: string): Promise<Thread>;
|
|
293
|
+
/**
|
|
294
|
+
* Search threads
|
|
295
|
+
*/
|
|
296
|
+
search(options: {
|
|
297
|
+
query: string;
|
|
298
|
+
limit?: number;
|
|
299
|
+
offset?: number;
|
|
300
|
+
status?: "active" | "archived" | "completed";
|
|
301
|
+
tags?: string[];
|
|
302
|
+
}): Promise<PaginatedResponse<Thread>>;
|
|
303
|
+
/**
|
|
304
|
+
* Merge multiple threads into one
|
|
305
|
+
*/
|
|
306
|
+
merge(targetId: string, sourceIds: string[]): Promise<Thread>;
|
|
307
|
+
/**
|
|
308
|
+
* Clone a thread
|
|
309
|
+
*/
|
|
310
|
+
clone(id: string, options?: {
|
|
311
|
+
name?: string;
|
|
312
|
+
include_memories?: boolean;
|
|
313
|
+
}): Promise<Thread>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
declare class SovantError extends Error {
|
|
317
|
+
statusCode?: number;
|
|
318
|
+
details?: Record<string, any>;
|
|
319
|
+
constructor(message: string, statusCode?: number, details?: Record<string, any>);
|
|
320
|
+
}
|
|
321
|
+
declare class AuthenticationError extends SovantError {
|
|
322
|
+
constructor(message?: string);
|
|
323
|
+
}
|
|
324
|
+
declare class RateLimitError extends SovantError {
|
|
325
|
+
retryAfter?: number;
|
|
326
|
+
constructor(message?: string, retryAfter?: number);
|
|
327
|
+
}
|
|
328
|
+
declare class ValidationError extends SovantError {
|
|
329
|
+
errors?: Record<string, string[]>;
|
|
330
|
+
constructor(message?: string, errors?: Record<string, string[]>);
|
|
331
|
+
}
|
|
332
|
+
declare class NotFoundError extends SovantError {
|
|
333
|
+
constructor(message?: string);
|
|
334
|
+
}
|
|
335
|
+
declare class NetworkError extends SovantError {
|
|
336
|
+
constructor(message?: string);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
declare class SovantClient {
|
|
340
|
+
memories: Memories;
|
|
341
|
+
threads: Threads;
|
|
342
|
+
private config;
|
|
343
|
+
constructor(apiKeyOrConfig: string | SovantConfig);
|
|
344
|
+
/**
|
|
345
|
+
* Test API connection
|
|
346
|
+
*/
|
|
347
|
+
ping(): Promise<{
|
|
348
|
+
status: "ok";
|
|
349
|
+
timestamp: string;
|
|
350
|
+
}>;
|
|
351
|
+
/**
|
|
352
|
+
* Get current API usage and quota
|
|
353
|
+
*/
|
|
354
|
+
getUsage(): Promise<{
|
|
355
|
+
quota: {
|
|
356
|
+
total: number;
|
|
357
|
+
used: number;
|
|
358
|
+
remaining: number;
|
|
359
|
+
reset_at: string;
|
|
360
|
+
};
|
|
361
|
+
usage: {
|
|
362
|
+
memories_created: number;
|
|
363
|
+
searches_performed: number;
|
|
364
|
+
threads_created: number;
|
|
365
|
+
};
|
|
366
|
+
}>;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export { type APIError, AuthenticationError, type BatchCreateResult, type CreateMemoryInput, type CreateThreadInput, type EmotionType, type EmotionalContext, type Memory, type MemoryType, NetworkError, NotFoundError, type PaginatedResponse, RateLimitError, type SearchOptions, type SearchResult, SovantClient, type SovantConfig, SovantError, type Thread, type ThreadStats, type UpdateMemoryInput, type UpdateThreadInput, ValidationError, SovantClient as default };
|